[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] x86/nestedsvm: Don't restore L1's CR2 during VMEXIT
- To: xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
- Date: Wed, 18 Nov 2026 17:58:52 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uqQC8AAFnYdY/4wAeXiy43w4qzvIT5S/km0gWO5UOY8=; b=lrQwdQ80jAJO99gLDBFgkgN3ugB1OSfh8WmYeHptQoVC8CmvOXQBuQRTyhIvvUJtEWCeq3/X0Wl2N3+xiUCMnFiXtBnngX/j8A8LWQD/SJNpOU9jAal5I2oucE4NPwPtBydlzMTxSuphp5LelhKrXbiJyNPV7OqWT66D42ds0Vjq+aFt1AbQaOFPPjFOBNmKiEAqO9u/39dJxWhl1nYa3AxEd/7Y4LdyE3CKy7T3GLfWpCiUsZHbverOw7DOS1wpvqcYnVP7sFiquzjZR9M46UW6fCkrwduM0BBszTs7QiCr7JAnUWf0OxLUTldbn6OUkJFvUxR033aPlQu3Gy2Qbw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dWrQAaAJwwg2LNiBHRoLoEfXenv23iaqK3oxbqfpEbJ76SaHewqhK23rU4Fdj0Dz8JDV3zwlSTGplY99hso7cz5G8wY7FAa02pLdYBVOkr+yhLnACh84fBrSDuRvUnKHGNwqcppns+QlZ8/1CRUs9FhhtogcrbZgyQXQhCeBGsum53shkUOcToQf21JuNPlcBox8j5CpnM6Pcc1KyVY5ZfyCre+fmVElFRZ7tZETWra4jmsVeykn9IajEuL0x9IbWpGvF7/1O6HIx2Q0r37W8jlr7vLqPirAQZ+tM6QS5vIf+RJqmSoh1y49sQg6/FZ6vfIGhv/2GpydUgEVS+aWyw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
- Delivery-date: Wed, 18 Nov 2026 17:59:21 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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>
---
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 81cae929dd05..5ddb0cda55bb 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 */
--
2.56.0
|