x86/nestedsvm: Don't restore L1's CR2 during VMEXIT
PATCH 1/1 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 <[email protected]>
--- xen/arch/x86/hvm/svm/nestedsvm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +1 -3
@@ -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 */
Signature · 1 line
2.56.0
Quoted 9 lines · Ross Lagerwall
According to the APM, the host CR2 is not restored during a VMEXIT.
The state of CR2 after a VMRUN that exits with
VMEXIT_INVALIDis 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 <[email protected]>
Reviewed-by Jan Beulich <[email protected]>