[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] nestedsvm: Don't set CR2 while injecting VMEXIT_EXCEPTION_PF
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
- Date: Mon, 16 Nov 2026 13:39:16 +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=uRt/fw+90IMNJF8m8npxh7/HWwfijV3rYA/UKFvnKME=; b=bqwH6OFAW+mVA3hlMf0h7XXT3krzWDVfRFdZByEmQmK16FhhCGfypzxbvgESbl0FLgVvXoPuWzVppvdSydJxT1vfB6XUeQpdMUT/rUWV6/TPWCHwYNhvFPxRGUPatVeXd6ZZdz1Cp9B/HxaH1z2EcnEHFrsni2At2Gg2AyL93husrStTXLijoYZKjIHdo16Ulx2Pyy7qVT5FVs2cMNndx4gGH40OZQEJdc4wV96pza4jAStLyRsgluXGm2KC5sJ4fZeZ7L7hbPUaL4odUYAy0x7/8aNEeGfhXpquInlfJT6JuSC2FvyUtUZP4xcmImI2veEQwBICI6ZncmRVw5H1iQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E94qRotpBBb7KePzmWu5CMX9ogvZ8fOSfIVXQv4Zx7xxNm+CRftQIrO+nJ8lnkr1JY9kKuYswCMxG8POYqsXROTWnkLmVR6nBeV2bVQBELoz7bCHZxQh6O6m77pJsNvlzUQ6R7UBBfSQm1kWcZzPuMHIjXMS/YgmVLHNH3yi7zn4JxlDDcU/k47PNO9vr3WACiWByA2g31nnjxKqEsR+6NpaH8FSlePLB4vByHA8cZ4Ypa4/ssW9UOgpwESUstg4YhVNg9GI3a7jGmdp6/5JijtxDw6F78VU4kJgm/LSSD/UkyeQRFNuYLQTpgjhRlJ/PDNfI6P/y0UC0PU+hTHH1Q==
- 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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Mon, 16 Nov 2026 13:39:28 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 11/16/26 12:23 PM, Jan Beulich wrote:
On 16.11.2026 13:05, Ross Lagerwall wrote:
On 11/16/26 11:42 AM, Jan Beulich wrote:
On 13.11.2026 18:24, Ross Lagerwall wrote:
According to the APM, the #PF intercept is tested before CR2 is written
so don't write CR2 while injecting VMEXIT_EXCEPTION_PF into L1.
The faulting address is available to L1 in EXITINFO2.
Fixes: 9a779e4fc161 ("Implement SVM specific part for Nested Virtualization")
Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
Thanks
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -741,8 +741,6 @@ nsvm_vcpu_vmexit_inject(struct vcpu *v, struct
cpu_user_regs *regs,
ns_vmcb->exit_int_info = ns_vmcb->event_inj;
break;
case VMEXIT_EXCEPTION_PF:
- ns_vmcb->_cr2 = ns_vmcb->ei.exc.cr2;
Further to what you say in the description, isn't this also a stale value,
as ...
- fallthrough;
case VMEXIT_NPF:
ns_vmcb->exitinfo2 = svm->ns_vmexit.exitinfo2;
... the correct one is written only here? If you agree, I'd be inclined to
have the description say "... so don't write CR2 (with a stale value) while
..." (happy to adjust while committing).
In most cases it wouldn't be stale because ei.exc.cr2 is the same as exitinfo2
and ns_vmcb->exitinfo2 is updated before this in prepare4vmexit(). However, I
think it may be stale in some cases, e.g. if the #PF was raised by the L0
emulator.
So further add "possibly" to what I suggested? (If ns_vmcb->exitinfo2 was always
updated earlier on, the updating here could be avoided.)
Yes, I agree with that adjustment.
Ross
|