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

[xen master] x86/nestedsvm: Don't restore L1's CR2 during VMEXIT



commit 33f84110ed0e379b7ba2c63f72b11186296508f5
Author:     Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
AuthorDate: Wed Nov 25 09:43:29 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 25 09:43:29 2026 +0100

    x86/nestedsvm: Don't restore L1's CR2 during VMEXIT
    
    According to the APM, the host CR2 is not restored during a VMEXIT.
    
    The state of CR2 after a VMRUN that exits with VMEXIT_INVALID is not
    explicitly defined by the APM. After this change, CR2 in L1 after a
    failed VMRUN may contain either the original L1 CR2 or the L2 CR2. This
    is in line with the observed behaviour of real hardware.
    
    Fixes: 9a779e4fc161 ("Implement SVM specific part for Nested 
Virtualization")
    Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/hvm/svm/nestedsvm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 7bc5710c82..0c1fa583d5 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -178,7 +178,6 @@ static int nsvm_vcpu_hostsave(struct vcpu *v, unsigned int 
inst_len)
      */
     n1vmcb->_efer = v->arch.hvm.guest_efer;
     n1vmcb->_cr0 = v->arch.hvm.guest_cr[0];
-    n1vmcb->_cr2 = v->arch.hvm.guest_cr[2];
     n1vmcb->_cr4 = v->arch.hvm.guest_cr[4];
 
     /* Remember the host interrupt flag */
@@ -232,8 +231,7 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct 
cpu_user_regs *regs)
     if ( rc != X86EMUL_OKAY )
         gdprintk(XENLOG_ERR, "hvm_set_cr0 failed, rc: %u\n", rc);
 
-    /* CR2 */
-    v->arch.hvm.guest_cr[2] = n1vmcb->_cr2;
+    /* Sync the current CR2 to L1's VMCB */
     hvm_update_guest_cr(v, 2);
 
     /* CR3 */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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