[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.11] x86/vmx: correctly gather gs_shadow value for current vCPU



commit 18af067ae3c2b12b4330e495ce471cc51d3c3f5a
Author:     Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
AuthorDate: Thu Jun 6 14:07:54 2019 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jun 6 14:07:54 2019 +0200

    x86/vmx: correctly gather gs_shadow value for current vCPU
    
    Currently the gs_shadow value is only cached when the vCPU is being 
scheduled
    out by Xen. Reporting this (usually) stale value through vm_event is 
incorrect,
    since it doesn't represent the actual state of the vCPU at the time the 
event
    was recorded. This prevents vm_event subscribers from correctly finding 
kernel
    structures in the guest when it is trapped while in ring3.
    
    Refresh shadow_gs value when the context being saved is for the current 
vCPU.
    
    Signed-off-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
    Acked-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Kevin Tian <kevin.tian@xxxxxxxxx>
    master commit: f69fc1c2f36e8a74ba54c9c8fa5c904ea1ad319e
    master date: 2019-05-13 09:55:59 +0200
---
 xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 2c7d194cd2..912903339a 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -802,12 +802,18 @@ static void vmx_load_cpu_state(struct vcpu *v, struct 
hvm_hw_cpu *data)
 
 static void vmx_save_vmcs_ctxt(struct vcpu *v, struct hvm_hw_cpu *ctxt)
 {
+    if ( v == current )
+        vmx_save_guest_msrs(v);
+
     vmx_save_cpu_state(v, ctxt);
     vmx_vmcs_save(v, ctxt);
 }
 
 static int vmx_load_vmcs_ctxt(struct vcpu *v, struct hvm_hw_cpu *ctxt)
 {
+    /* Not currently safe to use in current context. */
+    ASSERT(v != current);
+
     vmx_load_cpu_state(v, ctxt);
 
     if ( vmx_vmcs_restore(v, ctxt) )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.11

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.