[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] unify update_runstate_area()
commit 32ae027f81aed2812ac4025c403f0b32ecfac7f7 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Dec 5 13:37:54 2022 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Dec 5 13:37:54 2022 +0100 unify update_runstate_area() x86'es variant is a superset of Arm's, with CONFIG_COMPAT parts already properly marked. The only other missing piece is update_guest_memory_policy(): For the time being Arm simply gains an empty struct and inline function. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx> --- xen/arch/arm/domain.c | 32 --------------------- xen/arch/arm/include/asm/domain.h | 5 ++++ xen/arch/x86/domain.c | 58 --------------------------------------- xen/arch/x86/include/asm/domain.h | 1 - xen/common/domain.c | 58 +++++++++++++++++++++++++++++++++++++++ xen/include/xen/domain.h | 2 ++ 6 files changed, 65 insertions(+), 91 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 38e22f12af..476f4f29f8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -281,38 +281,6 @@ static void ctxt_switch_to(struct vcpu *n) WRITE_SYSREG(n->arch.mdcr_el2, MDCR_EL2); } -/* Update per-VCPU guest runstate shared memory area (if registered). */ -static void update_runstate_area(struct vcpu *v) -{ - void __user *guest_handle = NULL; - struct vcpu_runstate_info runstate; - - if ( guest_handle_is_null(runstate_guest(v)) ) - return; - - memcpy(&runstate, &v->runstate, sizeof(runstate)); - - if ( VM_ASSIST(v->domain, runstate_update_flag) ) - { - guest_handle = &v->runstate_guest.p->state_entry_time + 1; - guest_handle--; - runstate.state_entry_time |= XEN_RUNSTATE_UPDATE; - __raw_copy_to_guest(guest_handle, - (void *)(&runstate.state_entry_time + 1) - 1, 1); - smp_wmb(); - } - - __copy_to_guest(runstate_guest(v), &runstate, 1); - - if ( guest_handle ) - { - runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE; - smp_wmb(); - __raw_copy_to_guest(guest_handle, - (void *)(&runstate.state_entry_time + 1) - 1, 1); - } -} - static void schedule_tail(struct vcpu *prev) { ASSERT(prev != current); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index 2ce6764322..0e310601e8 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -295,6 +295,11 @@ struct arch_vcpu_io { struct instr_details dabt_instr; /* when the instruction is decoded */ }; +struct guest_memory_policy {}; +static inline void update_guest_memory_policy(struct vcpu *v, + struct guest_memory_policy *gmp) +{} + #endif /* __ASM_DOMAIN_H__ */ /* diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5a119eec3a..d7a8237f01 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1831,64 +1831,6 @@ void cf_check paravirt_ctxt_switch_to(struct vcpu *v) wrmsr_tsc_aux(v->arch.msrs->tsc_aux); } -/* Update per-VCPU guest runstate shared memory area (if registered). */ -bool update_runstate_area(struct vcpu *v) -{ - bool rc; - struct guest_memory_policy policy = { .nested_guest_mode = false }; - void __user *guest_handle = NULL; - struct vcpu_runstate_info runstate; - - if ( guest_handle_is_null(runstate_guest(v)) ) - return true; - - update_guest_memory_policy(v, &policy); - - memcpy(&runstate, &v->runstate, sizeof(runstate)); - - if ( VM_ASSIST(v->domain, runstate_update_flag) ) - { -#ifdef CONFIG_COMPAT - guest_handle = has_32bit_shinfo(v->domain) - ? &v->runstate_guest.compat.p->state_entry_time + 1 - : &v->runstate_guest.native.p->state_entry_time + 1; -#else - guest_handle = &v->runstate_guest.p->state_entry_time + 1; -#endif - guest_handle--; - runstate.state_entry_time |= XEN_RUNSTATE_UPDATE; - __raw_copy_to_guest(guest_handle, - (void *)(&runstate.state_entry_time + 1) - 1, 1); - smp_wmb(); - } - -#ifdef CONFIG_COMPAT - if ( has_32bit_shinfo(v->domain) ) - { - struct compat_vcpu_runstate_info info; - - XLAT_vcpu_runstate_info(&info, &runstate); - __copy_to_guest(v->runstate_guest.compat, &info, 1); - rc = true; - } - else -#endif - rc = __copy_to_guest(runstate_guest(v), &runstate, 1) != - sizeof(runstate); - - if ( guest_handle ) - { - runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE; - smp_wmb(); - __raw_copy_to_guest(guest_handle, - (void *)(&runstate.state_entry_time + 1) - 1, 1); - } - - update_guest_memory_policy(v, &policy); - - return rc; -} - static void _update_runstate_area(struct vcpu *v) { if ( !update_runstate_area(v) && is_pv_vcpu(v) && diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index 4e59ca8c4e..43ace233d7 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -681,7 +681,6 @@ void update_guest_memory_policy(struct vcpu *v, void domain_cpu_policy_changed(struct domain *d); -bool update_runstate_area(struct vcpu *); bool update_secondary_system_time(struct vcpu *, struct vcpu_time_info *); diff --git a/xen/common/domain.c b/xen/common/domain.c index c06d72ad64..626debbae0 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1592,6 +1592,64 @@ int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) return rc; } +/* Update per-VCPU guest runstate shared memory area (if registered). */ +bool update_runstate_area(struct vcpu *v) +{ + bool rc; + struct guest_memory_policy policy = { }; + void __user *guest_handle = NULL; + struct vcpu_runstate_info runstate; + + if ( guest_handle_is_null(runstate_guest(v)) ) + return true; + + update_guest_memory_policy(v, &policy); + + memcpy(&runstate, &v->runstate, sizeof(runstate)); + + if ( VM_ASSIST(v->domain, runstate_update_flag) ) + { +#ifdef CONFIG_COMPAT + guest_handle = has_32bit_shinfo(v->domain) + ? &v->runstate_guest.compat.p->state_entry_time + 1 + : &v->runstate_guest.native.p->state_entry_time + 1; +#else + guest_handle = &v->runstate_guest.p->state_entry_time + 1; +#endif + guest_handle--; + runstate.state_entry_time |= XEN_RUNSTATE_UPDATE; + __raw_copy_to_guest(guest_handle, + (void *)(&runstate.state_entry_time + 1) - 1, 1); + smp_wmb(); + } + +#ifdef CONFIG_COMPAT + if ( has_32bit_shinfo(v->domain) ) + { + struct compat_vcpu_runstate_info info; + + XLAT_vcpu_runstate_info(&info, &runstate); + __copy_to_guest(v->runstate_guest.compat, &info, 1); + rc = true; + } + else +#endif + rc = __copy_to_guest(runstate_guest(v), &runstate, 1) != + sizeof(runstate); + + if ( guest_handle ) + { + runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE; + smp_wmb(); + __raw_copy_to_guest(guest_handle, + (void *)(&runstate.state_entry_time + 1) - 1, 1); + } + + update_guest_memory_policy(v, &policy); + + return rc; +} + long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 0de9cbc169..26f9c4f6dd 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -101,6 +101,8 @@ int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg); int arch_get_paging_mempool_size(struct domain *d, uint64_t *size /* bytes */); int arch_set_paging_mempool_size(struct domain *d, uint64_t size /* bytes */); +bool update_runstate_area(struct vcpu *); + int domain_relinquish_resources(struct domain *d); void dump_pageframe_info(struct domain *d); -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |