]> xenbits.xensource.com Git - xen.git/commitdiff
x86: fix GS-base-dirty determination
authorJan Beulich <jbeulich@suse.com>
Thu, 16 Nov 2017 10:58:10 +0000 (11:58 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 16 Nov 2017 10:58:10 +0000 (11:58 +0100)
load_segments() writes the two MSRs in their "canonical" positions
(GS_BASE for the user base, SHADOW_GS_BASE for the kernel one) and uses
SWAPGS to switch them around if the incoming vCPU is in kernel mode. In
order to not leave a stale kernel address in GS_BASE when the incoming
guest is in user mode, the check on the outgoing vCPU needs to be
dependent upon the mode it is currently in, rather than blindly looking
at the user base.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 91f85280b9b80852352fcad73d94ed29fafb88da
master date: 2017-10-24 18:12:31 +0200

xen/arch/x86/domain.c

index b7550d35f5cb61ebe8f81817911b54fd2fd1f708..ceeadabbfd60c4bea44a79cbdb2aaa1063b39a8d 100644 (file)
@@ -1921,7 +1921,8 @@ static void save_segments(struct vcpu *v)
         if ( regs->gs & ~3 )
             v->arch.pv_vcpu.gs_base_user = 0;
     }
-    if ( v->arch.pv_vcpu.gs_base_user )
+    if ( v->arch.flags & TF_kernel_mode ? v->arch.pv_vcpu.gs_base_kernel
+                                        : v->arch.pv_vcpu.gs_base_user )
         dirty_segment_mask |= DIRTY_GS_BASE_USER;
 
     this_cpu(dirty_segment_mask) = dirty_segment_mask;