[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.3] x86: don't drop guest visible state updates when 64-bit PV guest is in user mode
commit c450908dc9168c3f20787aab268fcc295feaed7d Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Wed Jan 29 11:56:17 2014 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Jan 29 11:56:17 2014 +0100 x86: don't drop guest visible state updates when 64-bit PV guest is in user mode Since 64-bit PV uses separate kernel and user mode page tables, kernel addresses (as usually provided via VCPUOP_register_runstate_memory_area and possibly via VCPUOP_register_vcpu_time_memory_area) aren't necessarily accessible when the respective updating occurs. Add logic for toggle_guest_mode() to take care of this (if necessary) the next time the vCPU switches to kernel mode. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> master commit: 231d7f4098c8ac9cdb78f18fcb820d8618c8b0c2 master date: 2014-01-23 10:30:08 +0100 --- xen/arch/x86/domain.c | 24 ++++++++++++++++-------- xen/arch/x86/time.c | 39 +++++++++++++++++++++++++-------------- xen/arch/x86/x86_64/traps.c | 12 ++++++++++++ xen/include/asm-x86/domain.h | 8 ++++++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index f01c7e3..c0a11c0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1287,10 +1287,10 @@ static void paravirt_ctxt_switch_to(struct vcpu *v) } /* Update per-VCPU guest runstate shared memory area (if registered). */ -static void update_runstate_area(struct vcpu *v) +bool_t update_runstate_area(const struct vcpu *v) { if ( guest_handle_is_null(runstate_guest(v)) ) - return; + return 1; if ( has_32bit_shinfo(v->domain) ) { @@ -1298,10 +1298,18 @@ static void update_runstate_area(struct vcpu *v) XLAT_vcpu_runstate_info(&info, &v->runstate); __copy_to_guest(v->runstate_guest.compat, &info, 1); - return; + return 1; } - __copy_to_guest(runstate_guest(v), &v->runstate, 1); + return __copy_to_guest(runstate_guest(v), &v->runstate, 1) != + sizeof(v->runstate); +} + +static void _update_runstate_area(struct vcpu *v) +{ + if ( !update_runstate_area(v) && !is_hvm_vcpu(v) && + !(v->arch.flags & TF_kernel_mode) ) + v->arch.pv_vcpu.need_update_runstate_area = 1; } static inline int need_full_gdt(struct vcpu *v) @@ -1407,8 +1415,8 @@ void context_switch(struct vcpu *prev, struct vcpu *next) flush_tlb_mask(&dirty_mask); } - if (prev != next) - update_runstate_area(prev); + if ( prev != next ) + _update_runstate_area(prev); if ( is_hvm_vcpu(prev) ) { @@ -1461,8 +1469,8 @@ void context_switch(struct vcpu *prev, struct vcpu *next) context_saved(prev); - if (prev != next) - update_runstate_area(next); + if ( prev != next ) + _update_runstate_area(next); /* Ensure that the vcpu has an up-to-date time base. */ update_vcpu_system_time(next); diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index c31029c..7809bc9 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -805,7 +805,6 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) { struct cpu_time *t; struct vcpu_time_info *u, _u; - XEN_GUEST_HANDLE(vcpu_time_info_t) user_u; struct domain *d = v->domain; s_time_t tsc_stamp = 0; @@ -870,19 +869,31 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) /* 3. Update guest kernel version. */ u->version = version_update_end(u->version); - user_u = v->arch.time_info_guest; - if ( !guest_handle_is_null(user_u) ) - { - /* 1. Update userspace version. */ - __copy_field_to_guest(user_u, &_u, version); - wmb(); - /* 2. Update all other userspavce fields. */ - __copy_to_guest(user_u, &_u, 1); - wmb(); - /* 3. Update userspace version. */ - _u.version = version_update_end(_u.version); - __copy_field_to_guest(user_u, &_u, version); - } + if ( !update_secondary_system_time(v, &_u) && !is_hvm_domain(d) && + !is_pv_32bit_domain(d) && !(v->arch.flags & TF_kernel_mode) ) + v->arch.pv_vcpu.pending_system_time = _u; +} + +bool_t update_secondary_system_time(const struct vcpu *v, + struct vcpu_time_info *u) +{ + XEN_GUEST_HANDLE(vcpu_time_info_t) user_u = v->arch.time_info_guest; + + if ( guest_handle_is_null(user_u) ) + return 1; + + /* 1. Update userspace version. */ + if ( __copy_field_to_guest(user_u, u, version) == sizeof(u->version) ) + return 0; + wmb(); + /* 2. Update all other userspace fields. */ + __copy_to_guest(user_u, u, 1); + wmb(); + /* 3. Update userspace version. */ + u->version = version_update_end(u->version); + __copy_field_to_guest(user_u, u, version); + + return 1; } void update_vcpu_system_time(struct vcpu *v) diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index fe02261..81705f9 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -265,6 +265,18 @@ void toggle_guest_mode(struct vcpu *v) #else write_ptbase(v); #endif + + if ( !(v->arch.flags & TF_kernel_mode) ) + return; + + if ( v->arch.pv_vcpu.need_update_runstate_area && + update_runstate_area(v) ) + v->arch.pv_vcpu.need_update_runstate_area = 0; + + if ( v->arch.pv_vcpu.pending_system_time.version && + update_secondary_system_time(v, + &v->arch.pv_vcpu.pending_system_time) ) + v->arch.pv_vcpu.pending_system_time.version = 0; } unsigned long do_iret(void) diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index eaec0137..1df8ea9 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -373,6 +373,10 @@ struct pv_vcpu /* Current LDT details. */ unsigned long shadow_ldt_mapcnt; spinlock_t shadow_ldt_lock; + + /* Deferred VA-based update state. */ + bool_t need_update_runstate_area; + struct vcpu_time_info pending_system_time; }; struct arch_vcpu @@ -445,6 +449,10 @@ struct arch_vcpu #define hvm_vmx hvm_vcpu.u.vmx #define hvm_svm hvm_vcpu.u.svm +bool_t update_runstate_area(const struct vcpu *); +bool_t update_secondary_system_time(const struct vcpu *, + struct vcpu_time_info *); + void vcpu_show_execution_state(struct vcpu *); void vcpu_show_registers(const struct vcpu *); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.3 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |