wallclock time on arm
v4 cover wallclock time on arm
Hi all,
this small series enables the wallclock time on arm and it consists mostly in code movement from x86 to common.
Now build tested with XSM_ENABLE=y.
Changes in v4:
- remove spurious change to ticks_to_ns
- move flask_platform_op out of ifdef CONFIG_X86
- move set_to_dummy_if_null out of ifdef CONFIG_X86 for platform_op
- dropped previous ack from Daniel
- add patch "move ticks conversions function declarations"
Changes in v3:
- remove stray blank lines
- move update_domain_wallclock_time() call to arch_domain_create
- move setting time_offset_seconds to domain_vtimer_init
- use spin_trylock(&xenpf_lock) loop in do_platform_op
Changes in v2:
- remove stray blank lines
- remove include <xen/config.h>
- move version_update_* to include/xen/time.h
- introduce ifdef to fix build issue in common/time.c
- define wc_sec and sec as uint64_t
- pass u64 to do_settime
- drop XENPF_settime32
- set time_offset_seconds
- modify xen/xsm/flask/hooks.c
Stefano Stabellini (3):
xen: move wallclock functions from x86 to common
arm: export platform_op XENPF_settime64
xen/arm: move ticks conversions function declarations to the header file
xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 2 + xen/arch/arm/platform_hypercall.c | 70 +++++++++++++++++++ xen/arch/arm/time.c | 5 -- xen/arch/arm/traps.c | 1 + xen/arch/arm/vtimer.c | 6 +- xen/arch/x86/time.c | 96 +------------------------ xen/common/time.c | 95 ++++++++++++++++++++++++- xen/include/asm-arm/time.h | 3 + xen/include/xen/time.h | 5 +- xen/include/xsm/dummy.h | 12 ++-- xen/include/xsm/xsm.h | 13 ++-- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 140 ++++++++++++++++++------------------- 14 files changed, 263 insertions(+), 188 deletions(-) create mode 100644 xen/arch/arm/platform_hypercall.c
Cheers,
Stefano
PATCH v4 1/3 xen: move wallclock functions from x86 to common
Remove dummy arm implementation of wallclock_time.
Use shared_info() in common code rather than x86-ism to access it, when possible.
Define the static variable wc_sec, and the local variale sec in update_domain_wallclock_time, as uint64_t instead of unsigned long, to avoid size issue on arm.
Take a uint64_t sec paramter in do_settime for the same reason.
---
Changes in v3:
- remove stray blank lines
Changes in v2:
- remove stray blank lines
- remove include <xen/config.h>
- move version_update_* to include/xen/time.h
- introduce ifdef to fix build issue in common/time.c
- define wc_sec and sec as uint64_t
- pass u64 to do_settime
--- xen/arch/arm/time.c | 5 --- xen/arch/x86/time.c | 96 +----------------------------------------------- xen/common/time.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++- xen/include/xen/time.h | 5 ++- 4 files changed, 99 insertions(+), 102 deletions(-)
xen/arch/arm/time.c +0 -5
@@ -280,11 +280,6 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)/* XXX update guest visible wallclock time */ } -struct tm wallclock_time (uint64_t *ns) -{ -return (struct tm ) {0 }; -} -/* * Local variables: * mode: C
xen/arch/x86/time.c +1 -95
138 lines not on this page · raw message
xen/common/time.c +94 -1
111 lines not on this page · raw message
xen/include/xen/time.h +4 -1
@@ -60,11 +60,14 @@ struct tm wallclock_time(uint64_t *ns);/* Chosen so (NOW() + delta) wont overflow without an uptime of 200 years */ #define STIME_DELTA_MAX ((s_time_t)((uint64_t)~0ull>>2)) +/* Explicitly OR with 1 just in case version number gets out of sync. */ +#define version_update_begin (v) (((v) + 1) | 1) +#define version_update_end (v) ((v) + 1)extern void update_vcpu_system_time (struct vcpu *v);extern void update_domain_wallclock_time (struct domain *d);extern void do_settime ( -unsigned long secs,unsigned int nsecs,u64 system_time_base); +u64 secs,unsigned int nsecs,u64 system_time_base);extern void send_timer_event (struct vcpu *v);
Signature · 1 line
1.7.10.4
Re: [PATCH v4 1/3] xen: move wallclock functions from x86 to common
Quoted 5 lines · Stefano Stabellini
Remove dummy arm implementation of
wallclock_time.
Useshared_info()in common code rather than x86-ism to access it, when possible.Define the static variable
wc_sec, and the local variale sec in
variable
Quoted 2 lines
update_domain_wallclock_time, asuint64_tinstead of unsigned long, to avoid size issue on arm.
issues
Quoted 1 line
Take a
uint64_tsec paramter indo_settimefor the same reason.
parameter
Quoted 3 lines
Signed-off-by Stefano Stabellini <[email protected]>Acked-by Jan Beulich <[email protected]>
Apart from the typos:
Quoted 323 lines
---
Changes in v3:
- remove stray blank linesChanges in v2:
- remove stray blank lines
- remove include <xen/config.h>
- move version_update_* toinclude/xen/time.h
- introduce ifdef to fix build issue incommon/time.c
- definewc_secand sec asuint64_t
- pass u64 todo_settime
---
xen/arch/arm/time.c | 5 ---
xen/arch/x86/time.c | 96 +-----------------------------------------
------
xen/common/time.c | 95
++++++++++++++++++++++++++++++++++++++++++++++-
xen/include/xen/time.h | 5 ++-4 files changed, 99 insertions(+), 102 deletions(-)xen/arch/arm/time.c +0
-0@@ -280,11 +280,6 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds) /* XXX update guest visible wallclock time */ }xen/arch/arm/time.c +0
-5-struct tm wallclock_time (uint64_t *ns) -{ - return (struct tm) { 0 }; -} -/*
* Local variables:
* mode: Cxen/arch/x86/time.c +0
-0@@ -47,9 +47,6 @@ string_param("clocksource", opt_clocksource);unsigned long
__read_mostlycpu_khz; /* CPU clock frequency in kHz. */DEFINE_SPINLOCK(rtc_lock);
unsigned longpit0_ticks;xen/arch/x86/time.c +0
-3-static unsigned long wc_sec;/* UTC time at last 'time update'. */ -static unsigned int wc_nsec; -static DEFINE_SPINLOCK (wc_lock);
structcpu_time{
u64local_tsc_stamp;xen/arch/x86/time.c +0
-0@@ -783,10 +780,6 @@ uint64_t tsc_ticks2ns(uint64_t ticks) return scale_delta(ticks, &t->tsc_scale); }xen/arch/x86/time.c +0
-4-/* Explicitly OR with 1 just in case version number gets out of sync. */ -#define version_update_begin (v) (((v)+1)|1) -#define version_update_end (v) ((v)+1) -static void
__update_vcpu_system_time(struct vcpu *v, int force){
struct cpu_time *t;xen/arch/x86/time.c +0
-0@@ -900,37 +893,6 @@ void force_update_vcpu_system_time(struct vcpu *v) __update_vcpu_system_time(v, 1); }xen/arch/x86/time.c +0
-31-void update_domain_wallclock_time (struct domain *d) -{ - uint32_t *wc_version; - unsigned long sec; - - spin_lock(&wc_lock); - - wc_version = &shared_info(d, wc_version); - *wc_version = version_update_begin(*wc_version); - wmb(); - - sec = wc_sec + d->time_offset_seconds; - if ( likely(!has_32bit_shinfo(d)) ) - { - d->shared_info->native.wc_sec = sec; - d->shared_info->native.wc_nsec = wc_nsec; - d->shared_info->native.wc_sec_hi = sec >> 32; - } - else - { - d->shared_info->compat.wc_sec = sec; - d->shared_info->compat.wc_nsec = wc_nsec; - d->shared_info->compat.arch.wc_sec_hi = sec >> 32; - } - - wmb(); - *wc_version = version_update_end(*wc_version); - - spin_unlock(&wc_lock); -} -static void
update_domain_rtc(void)
{
struct domain *d;xen/arch/x86/time.c +0
-0@@ -988,27 +950,6 @@ int cpu_frequency_change(u64 freq) return 0; }xen/arch/x86/time.c +0
-2-/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */ -void do_settime(unsigned long secs, unsigned int nsecs, u64
system_time_base)xen/arch/x86/time.c +0
-19-{ - u64 x; - u32 y; - struct domain *d; - - x = SECONDS(secs) + nsecs - system_time_base; - y = do_div(x, 1000000000); - - spin_lock(&wc_lock); - wc_sec = x; - wc_nsec = y; - spin_unlock(&wc_lock); - - rcu_read_lock(&domlist_read_lock); - for_each_domain ( d ) - update_domain_wallclock_time(d); - rcu_read_unlock(&domlist_read_lock); -} -/* Per-CPU communication between rendezvous IRQ and softirq handler. */ struct
cpu_calibration{
u64local_tsc_stamp;xen/arch/x86/time.c +0
-0@@ -1608,25 +1549,6 @@ void send_timer_event(struct vcpu *v) send_guest_vcpu_virq(v, VIRQ_TIMER); }xen/arch/x86/time.c +0
-19-/* Return secs after 00:00:00 localtime, 1 January, 1970. */ -unsigned long get_localtime (struct domain *d) -{ - return wc_sec + (wc_nsec + NOW()) / 1000000000ULL - + d->time_offset_seconds; -} - -/* Return microsecs after 00:00:00 localtime, 1 January, 1970. */ -uint64_t get_localtime_us (struct domain *d) -{ - return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW()) - / 1000UL; -} - -unsigned long get_sec (void ) -{ - return wc_sec + (wc_nsec + NOW()) / 1000000000ULL; -} -/* "
cmos_utc_offset" is the difference between UTC time and CMOS time. */
static longcmos_utc_offset; /* in seconds */xen/arch/x86/time.c +1
-1@@ -1635,7 +1557,7 @@ int time_suspend(void) if ( smp_processor_id() == 0 ) { cmos_utc_offset = -get_cmos_time(); - cmos_utc_offset += (wc_sec + (wc_nsec + NOW()) / 1000000000ULL); + cmos_utc_offset += get_sec(); kill_timer(&calibration_timer);
/* Sync platform timer stamps. */xen/arch/x86/time.c +0
-0@@ -1715,22 +1637,6 @@ int hwdom_pit_access(struct ioreq *ioreq) return 0; }xen/arch/x86/time.c +0
-16-struct tm wallclock_time (uint64_t *ns) -{ - uint64_t seconds, nsec; - - if ( !wc_sec ) - return (struct tm) { 0 }; - - seconds = NOW() + SECONDS(wc_sec) + wc_nsec; - nsec = do_div(seconds, 1000000000); - - if ( ns ) - *ns = nsec; - - return gmtime(seconds); -} -/*
* PV SoftTSC Emulation.
*/xen/common/time.c +0
-0@@ -15,8 +15,12 @@* along with this program; If not, see <http://www.gnu.org/licenses/>. */ xen/common/time.c +3
-1-#include <xen/config.h> +#include <xen/sched.h> +#include <xen/shared.h> +#include <xen/spinlock.h> #include <
xen/time.h>xen/common/time.c +2
-0+#include <asm/div64.h> +#include <asm/domain.h>
/* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */xen/common/time.c +0
-0@@ -34,6 +38,10 @@ const unsigned short int __mon_lengths[2][12] = { #define SECS_PER_HOUR (60 * 60) #define SECS_PER_DAY (SECS_PER_HOUR * 24)xen/common/time.c +4
-0+static uint64_t wc_sec;/* UTC time at last 'time update'. */ +static unsigned int wc_nsec; +static DEFINE_SPINLOCK (wc_lock); +struct tm gmtime(unsigned long t)
{
struct tm tbuf;xen/common/time.c +0
-0@@ -85,3 +93,88 @@ struct tm gmtime(unsigned long t)
return tbuf;
}xen/common/time.c +85
-0+ +void update_domain_wallclock_time (struct domain *d) +{ + uint32_t *wc_version; + uint64_t sec; + + spin_lock(&wc_lock); + + wc_version = &shared_info(d, wc_version); + *wc_version = version_update_begin(*wc_version); + wmb(); + + sec = wc_sec + d->time_offset_seconds; + shared_info(d, wc_sec) = sec; + shared_info(d, wc_nsec) = wc_nsec; +#ifdef CONFIG_X86 + if ( likely(!has_32bit_shinfo(d)) ) + d->shared_info->native.wc_sec_hi = sec >> 32; + else + d->shared_info->compat.arch.wc_sec_hi = sec >> 32; +#else + shared_info(d, wc_sec_hi) = sec >> 32; +#endif + + wmb(); + *wc_version = version_update_end(*wc_version); + + spin_unlock(&wc_lock); +} + +/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */ +void do_settime (u64 secs,unsigned int nsecs,u64 system_time_base) +{ + u64 x; + u32 y; + struct domain *d; + + x = SECONDS(secs) + nsecs - system_time_base; + y = do_div(x, 1000000000); + + spin_lock(&wc_lock); + wc_sec = x; + wc_nsec = y; + spin_unlock(&wc_lock); + + rcu_read_lock(&domlist_read_lock); + for_each_domain ( d ) + update_domain_wallclock_time(d); + rcu_read_unlock(&domlist_read_lock); +} + +/* Return secs after 00:00:00 localtime, 1 January, 1970. */ +unsigned long get_localtime (struct domain *d) +{ + return wc_sec + (wc_nsec + NOW()) / 1000000000ULL + + d->time_offset_seconds; +} + +/* Return microsecs after 00:00:00 localtime, 1 January, 1970. */ +uint64_t get_localtime_us (struct domain *d) +{ + return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW()) + / 1000UL; +} + +unsigned long get_sec (void ) +{ + return wc_sec + (wc_nsec + NOW()) / 1000000000ULL; +} + +struct tm wallclock_time (uint64_t *ns) +{ + uint64_t seconds, nsec; + + if ( !wc_sec ) + return (struct tm) { 0 }; + + seconds = NOW() + SECONDS(wc_sec) + wc_nsec; + nsec = do_div(seconds, 1000000000); + + if ( ns ) + *ns = nsec; + + return gmtime(seconds); +}xen/include/xen/time.h +0
-0@@ -60,11 +60,14 @@ struct tm wallclock_time(uint64_t *ns); /* Chosen so (NOW() + delta) wont overflow without an uptime of 200years */
#defineSTIME_DELTA_MAX((s_time_t)((uint64_t)~0ull>>2))xen/include/xen/time.h +3
-0+/* Explicitly OR with 1 just in case version number gets out of sync. */ +#define version_update_begin (v) (((v) + 1) | 1) +#define version_update_end (v) ((v) + 1)extern void
update_vcpu_system_time(struct vcpu *v);
Quoted 8 lines
extern void
update_domain_wallclock_time(struct domain *d);
extern void do_settime(
- unsigned long secs, unsigned int nsecs, u64system_time_base); + u64 secs, unsigned int nsecs, u64system_time_base);
extern voidsend_timer_event(struct vcpu *v);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 2/3 arm: export platform_op XENPF_settime64
In reply to Stefano StabelliniCall update_domain_wallclock_time at domain initialization. Set time_offset_seconds to the number of seconds between physical boot and domain initialization: it is going to be used to get/set the wallclock time.
Add time_offset_seconds to system_time when before calling do_settime, so that system_time actually accounts for all the time in nsec between machine boot and when the wallclock was set.
Expose xsm_platform_op to ARM.
---
Changes in v4:
- remove spurious change to ticks_to_ns
- move flask_platform_op out of ifdef CONFIG_X86
- move set_to_dummy_if_null out of ifdef CONFIG_X86 for platform_op
- dropped previous ack from Daniel
Changes in v3:
- move update_domain_wallclock_time() call to arch_domain_create
- move setting time_offset_seconds to domain_vtimer_init
- use spin_trylock(&xenpf_lock) loop in do_platform_op
Changes in v2:
- drop XENPF_settime32
- set time_offset_seconds
- modify xen/xsm/flask/hooks.c
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 2 + xen/arch/arm/platform_hypercall.c | 70 +++++++++++++++++++ xen/arch/arm/traps.c | 1 + xen/arch/arm/vtimer.c | 3 + xen/include/xsm/dummy.h | 12 ++-- xen/include/xsm/xsm.h | 13 ++-- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 140 ++++++++++++++++++------------------- 9 files changed, 161 insertions(+), 83 deletions(-) create mode 100644 xen/arch/arm/platform_hypercall.c
xen/arch/arm/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-y += percpu.o obj-y += guestcopy.o obj-y += physdev.o obj-y += platform.o +obj-y += platform_hypercall.o obj-y += setup.o obj-y += bootfdt.o obj-y += time.o
xen/arch/arm/domain.c +2 -0
@@ -598,6 +598,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,if ( (rc =domain_vtimer_init (d, config)) !=0 ) goto fail; +update_domain_wallclock_time (d); +/* * The hardware domain will get a PPI later in * arch/arm/domain_build.c depending on the
xen/arch/arm/platform_hypercall.c new file +70 -0
70 lines not on this page · raw message
xen/arch/arm/traps.c +1 -0
@@ -1233,6 +1233,7 @@ static arm_hypercall_t arm_hypercall_table[] = {HYPERCALL (hvm_op,2 ),HYPERCALL (grant_table_op,3 ),HYPERCALL (multicall,2 ), +HYPERCALL (platform_op,1 ), HYPERCALL_ARM(vcpu_op, 3), };
xen/arch/arm/vtimer.c +3 -0
@@ -22,6 +22,7 @@#include <xen/timer.h> #include <xen/sched.h> #include <xen/perfc.h> +#include <asm/div64.h> #include <asm/irq.h> #include <asm/time.h> #include <asm/gic.h>
@@ -64,6 +65,8 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) { d->arch.phys_timer_base.offset =NOW (); d->arch.virt_timer_base.offset =READ_SYSREG64 (CNTPCT_EL0 ); + d->time_offset_seconds =ticks_to_ns (d->arch.virt_timer_base.offset - boot_count); +do_div (d->time_offset_seconds,1000000000 ); config->clock_frequency = timer_dt_clock_frequency;
xen/include/xsm/dummy.h +6 -6
@@ -584,6 +584,12 @@ static XSM_INLINE int xsm_mem_sharing(XSM_DEFAULT_ARG struct domain *d) }#endif +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op) +{ +XSM_ASSERT_ACTION (XSM_PRIV ); +return xsm_default_action (action, current->domain,NULL ); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_do_mca(XSM_DEFAULT_VOID) {
@@ -639,12 +645,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)return xsm_default_action (action, d,NULL ); } -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op) -{ -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); -} - static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID) {XSM_ASSERT_ACTION (XSM_PRIV );
xen/include/xsm/xsm.h +7 -6
@@ -164,6 +164,8 @@ struct xsm_operations {int (*mem_sharing) (struct domain *d);#endif +int (*platform_op) (uint32_t cmd); +#ifdef CONFIG_X86 int (*do_mca) (void );int (*shadow_control) (struct domain *d,uint32_t op);
@@ -175,7 +177,6 @@ struct xsm_operations {int (*mem_sharing_op) (struct domain *d,struct domain *cd,int op);int (*apic) (struct domain *d,int cmd);int (*memtype) (uint32_t access); -int (*platform_op) (uint32_t cmd);int (*machine_memory_map) (void );int (*domain_memory_map) (struct domain *d);#define XSM_MMU_UPDATE_READ 1
@@ -624,6 +625,11 @@ static inline int xsm_mem_sharing (xsm_default_t def, struct domain *d) }#endif +static inline int xsm_platform_op (xsm_default_t def,uint32_t op) +{ +return xsm_ops->platform_op (op); +} +#ifdef CONFIG_X86 static inline int xsm_do_mca (xsm_default_t def) {
@@ -675,11 +681,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)return xsm_ops->memtype (access); } -static inline int xsm_platform_op (xsm_default_t def,uint32_t op) -{ -return xsm_ops->platform_op (op); -} -static inline int xsm_machine_memory_map (xsm_default_t def) {return xsm_ops->machine_memory_map ();
xen/xsm/dummy.c +1 -1
@@ -141,6 +141,7 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mem_sharing);#endif +set_to_dummy_if_null (ops, platform_op);#ifdef CONFIG_X86 set_to_dummy_if_null (ops, do_mca);set_to_dummy_if_null (ops, shadow_control);
@@ -151,7 +152,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, hvm_ioreq_server);set_to_dummy_if_null (ops, mem_sharing_op);set_to_dummy_if_null (ops, apic); -set_to_dummy_if_null (ops, platform_op);set_to_dummy_if_null (ops, machine_memory_map);set_to_dummy_if_null (ops, domain_memory_map);set_to_dummy_if_null (ops, mmu_update);
xen/xsm/flask/hooks.c +70 -70
164 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH v4 2/3] arm: export platform_op XENPF_settime64
Quoted 8 lines · Stefano Stabellini
Call
update_domain_wallclock_timeat domain initialization. Settime_offset_secondsto the number of seconds between physical boot and domain initialization: it is going to be used to get/set the wallclock time.
Addtime_offset_secondstosystem_timewhen before callingdo_settime, so thatsystem_timeactually accounts for all the time in nsec between machine boot and when the wallclock was set.
Quoted 4 lines
Expose
xsm_platform_opto ARM.Signed-off-by Stefano Stabellini <[email protected]>
Re: [PATCH v4 2/3] arm: export platform_op XENPF_settime64
In reply to Stefano StabelliniHi Stefano,
Quoted 11 lines · Stefano Stabellini
Call
update_domain_wallclock_timeat domain initialization. Settime_offset_secondsto the number of seconds between physical boot and domain initialization: it is going to be used to get/set the wallclock time.
Addtime_offset_secondstosystem_timewhen before callingdo_settime, so thatsystem_timeactually accounts for all the time in nsec between machine boot and when the wallclock was set.Expose
xsm_platform_opto ARM.Signed-off-by Stefano Stabellini <[email protected]>
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v4 2/3] arm: export platform_op XENPF_settime64
In reply to Stefano StabelliniQuoted 11 lines · Stefano Stabellini
Call
update_domain_wallclock_timeat domain initialization. Settime_offset_secondsto the number of seconds between physical boot and domain initialization: it is going to be used to get/set the wallclock time.
Addtime_offset_secondstosystem_timewhen before callingdo_settime, so thatsystem_timeactually accounts for all the time in nsec between machine boot and when the wallclock was set.Expose
xsm_platform_opto ARM.Signed-off-by Stefano Stabellini <[email protected]>
An aside:[...]
@@ -1332,6 +1332,75 @@ static int flask_deassign_dtdevice(struct domain
Quoted 5 lines
*d, const char *dtpath)
}
#endif /*HAS_PASSTHROUGH&&HAS_DEVICE_TREE*/xen/xsm/flask/hooks.c +1
-0+static int flask_platform_op (uint32_t op)
xen/xsm/flask/hooks.c static int flask_deassign_dtdevice(struct domain *d, const char *dtpath) · line 1345
Quoted 10 lines
xen/xsm/flask/hooks.c +10
-0+{ + switch ( op ) + { +#ifdef CONFIG_X86 + /* These operations have their own XSM hooks */ + case XENPF_cpu_online: + case XENPF_cpu_offline: + case XENPF_cpu_hotadd: + case XENPF_mem_hotadd: + return 0;
Should this not then be an error (e.g. fail closed)?
Also, although only implemented today for x86 they don't seem inherently any more x86 specific than many of the other things below, so maybe the ifdef could be ditched?
Quoted 48 lines
xen/xsm/flask/hooks.c +48
-0+#endif + + case XENPF_settime32: + case XENPF_settime64: + return domain_has_xen(current->domain, XEN__SETTIME); + + case XENPF_add_memtype: + return domain_has_xen(current->domain, XEN__MTRR_ADD); + + case XENPF_del_memtype: + return domain_has_xen(current->domain, XEN__MTRR_DEL); + + case XENPF_read_memtype: + return domain_has_xen(current->domain, XEN__MTRR_READ); + + case XENPF_microcode_update: + return domain_has_xen(current->domain, XEN__MICROCODE); + + case XENPF_platform_quirk: + return domain_has_xen(current->domain, XEN__QUIRK); + + case XENPF_firmware_info: + return domain_has_xen(current->domain, XEN__FIRMWARE); + + case XENPF_efi_runtime_call: + return domain_has_xen(current->domain, XEN__FIRMWARE); + + case XENPF_enter_acpi_sleep: + return domain_has_xen(current->domain, XEN__SLEEP); + + case XENPF_change_freq: + return domain_has_xen(current->domain, XEN__FREQUENCY); + + case XENPF_getidletime: + return domain_has_xen(current->domain, XEN__GETIDLE); + + case XENPF_set_processor_pminfo: + case XENPF_core_parking: + return domain_has_xen(current->domain, XEN__PM_OP); + + case XENPF_get_cpu_version: + case XENPF_get_cpuinfo: + return domain_has_xen(current->domain, XEN__GETCPUINFO); + + case XENPF_resource_op: + return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2, + XEN2__RESOURCE_OP, NULL); +
xen/xsm/flask/hooks.c static int flask_deassign_dtdevice(struct domain *d, const char *dtpath) · line 1403
Quoted 10 lines
xen/xsm/flask/hooks.c +10
-0+ case XENPF_get_symbol: + return avc_has_perm(domain_sid(current->domain), SECINITSID_XEN, + SECCLASS_XEN2, XEN2__GET_SYMBOL, NULL); + + default: + printk("flask_platform_op: Unknown op %d\n", op); + return -EPERM; + } +} +
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 2/3] arm: export platform_op XENPF_settime64
Quoted 21 lines · Ian Campbell
Quoted 11 lines · Stefano Stabellini
Call
update_domain_wallclock_timeat domain initialization. Settime_offset_secondsto the number of seconds between physical boot and domain initialization: it is going to be used to get/set the wallclock time.
Addtime_offset_secondstosystem_timewhen before callingdo_settime, so thatsystem_timeactually accounts for all the time in nsec between machine boot and when the wallclock was set.Expose
xsm_platform_opto ARM.Signed-off-by Stefano Stabellini <[email protected]>Acked-by Ian Campbell <[email protected]>An aside:[...]
(quoted diff) +0
-0@@ -1332,6 +1332,75 @@ static int flask_deassign_dtdevice(struct domain > *d, const char *dtpath) > }Quoted 2 lines
#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */
Quoted 13 lines
xen/xsm/flask/hooks.c static int flask_deassign_dtdevice(struct domain *d, const char *dtpath) · line 1345
Quoted 11 lines
xen/xsm/flask/hooks.c +11
-0+static int flask_platform_op (uint32_t op) +{ +switch ( op ) + { +#ifdef CONFIG_X86 +/* These operations have their own XSM hooks */ +case XENPF_cpu_online: +case XENPF_cpu_offline: +case XENPF_cpu_hotadd: +case XENPF_mem_hotadd: +return 0 ;Should this not then be an error (e.g. fail closed)?
During the invocation of these operations, two XSM hooks are called: this one (from above the switch) and the individual hook (inside the switch). This hook needs to allow access so that the more detailed hook is called.
Quoted 3 lines
Also, although only implemented today for x86 they don't seem inherently any more x86 specific than many of the other things below, so maybe the ifdef could be ditched?
The #ifdef is there mostly as a failsafe reminder to ensure that the implementation for other architectures actually calls the same XSM hooks that the x86 version does.
Signature · 2 lines
Daniel De Graaf National Security Agency
Re: [PATCH v4 2/3] arm: export platform_op XENPF_settime64
Quoted 39 lines · Daniel De Graaf
Quoted 24 lines · Ian Campbell
Quoted 11 lines · Stefano Stabellini
Call
update_domain_wallclock_timeat domain initialization. Settime_offset_secondsto the number of seconds between physical boot
and domain initialization: it is going to be used to get/set the wallclock time.
Addtime_offset_secondstosystem_timewhen before callingdo_settime,
so thatsystem_timeactually accounts for all the time in nsec between
machine boot and when the wallclock was set.Quoted 3 lines
Expose
xsm_platform_opto ARM.Signed-off-by Stefano Stabellini <[email protected]>Acked-by Ian Campbell <[email protected]>An aside:[...]
(quoted diff) +0
-0@@ -1332,6 +1332,75 @@ static int flask_deassign_dtdevice(struct domain > *d, const char *dtpath) > }Quoted 2 lines
#endif /*
HAS_PASSTHROUGH&&HAS_DEVICE_TREE*/Quoted 13 lines
xen/xsm/flask/hooks.c static int flask_deassign_dtdevice(struct domain *d, const char *dtpath) · line 1345
Quoted 11 lines
xen/xsm/flask/hooks.c +11
-0+static int flask_platform_op (uint32_t op) +{ + switch ( op ) + { +#ifdef CONFIG_X86 + /* These operations have their own XSM hooks */ + case XENPF_cpu_online: + case XENPF_cpu_offline: + case XENPF_cpu_hotadd: + case XENPF_mem_hotadd: + return 0;Should this not then be an error (e.g. fail closed)?
Quoted 3 lines
During the invocation of these operations, two XSM hooks are called: this one (from above the switch) and the individual hook (inside the switch). This hook needs to allow access so that the more detailed hook is called.
I see, thanks for the explanation.
Quoted 8 lines
Quoted 4 lines
Also, although only implemented today for x86 they don't seem inherently
any more x86 specific than many of the other things below, so maybe the ifdef could be ditched?The #ifdef is there mostly as a failsafe reminder to ensure that the implementation for other architectures actually calls the same XSM hooks that the x86 version does.
OK.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 3/3 xen/arm: move ticks conversions function declarations to the header file
In reply to Stefano StabelliniThis is just a cleanup, not required at the moment.
--- xen/arch/arm/vtimer.c | 3 --- xen/include/asm-arm/time.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/vtimer.c +0 -3
@@ -29,9 +29,6 @@#include <asm/vgic.h> #include <asm/regs.h> -extern s_time_t ticks_to_ns (uint64_t ticks); -extern uint64_t ns_to_ticks (s_time_t ns); -/* * Check if regs is allowed access, user_gate is tail end of a * CNTKCTL_EL1_ bit name which gates user access
xen/include/asm-arm/time.h +3 -0
@@ -37,6 +37,9 @@ extern void __cpuinit init_timer_interrupt(void);/* Counter value at boot time */ extern uint64_t boot_count; +extern s_time_t ticks_to_ns (uint64_t ticks); +extern uint64_t ns_to_ticks (s_time_t ns); +void preinit_xen_time (void );#endif /* __ARM_TIME_H__ */
Signature · 1 line
1.7.10.4
Re: [PATCH v4 3/3] xen/arm: move ticks conversions function declarations to the header file
Hi Stefano,
Quoted 3 lines · Stefano Stabellini
This is just a cleanup, not required at the moment.
Signed-off-by Stefano Stabellini <[email protected]>
Quoted 34 lines
--- xen/arch/arm/vtimer.c | 3 --- xen/include/asm-arm/time.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/vtimer.c +0
-3@@ -29,9 +29,6 @@#include <asm/vgic.h> #include <asm/regs.h> -extern s_time_t ticks_to_ns (uint64_t ticks); -extern uint64_t ns_to_ticks (s_time_t ns); -/* * Check if regs is allowed access, user_gate is tail end of a * CNTKCTL_EL1_ bit name which gates user access xen/include/asm-arm/time.h +3
-0@@ -37,6 +37,9 @@ extern void __cpuinit init_timer_interrupt(void);/* Counter value at boot time */ extern uint64_t boot_count; +extern s_time_t ticks_to_ns (uint64_t ticks); +extern uint64_t ns_to_ticks (s_time_t ns); +void preinit_xen_time (void );#endif /* __ARM_TIME_H__ */
Signature · 1 line
Julien Grall
Re: [PATCH v4 3/3] xen/arm: move ticks conversions function declarations to the header file
In reply to Stefano StabelliniQuoted 3 lines · Stefano Stabellini
This is just a cleanup, not required at the moment.
Signed-off-by Stefano Stabellini <[email protected]>
Quoted 4 lines · Stefano Stabellini
Hi all,
this small series enables the wallclock time on arm and it consists mostly in code movement from x86 to common.
AFAICT this is all now suitably acked, but I wanted to coordinate with you on the guest side changes before applying.
Ian.
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini
Hi all,
this small series enables the wallclock time on arm and it consists mostly in code movement from x86 to common.
AFAICT this is all now suitably acked, but I wanted to coordinate with you on the guest side changes before applying.
They can be applied independently from the Linux changes (if the guest doesn't know how to read the wallclock, it won't).
Ian Campbell
AppliedQuoted 5 lines · Stefano Stabellini
Stefano Stabellini (3):
xen: move wallclock functions from x86 to common
arm: exportplatform_opXENPF_settime64
xen/arm: move ticks conversions function declarations to the header file
Applied, thanks.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel