[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 12:05:03 +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=j125z2HDXRtpcsdhI2ouh3rxd17JDqaQEi7qlgRm4EY=; b=XQ6vKvmavLcxaXlS1+Urc2KBw/ujAuOm7jF0ccCKbrZYiqVKKyTSYBICvMKgYEX63xjZbhULDSI2wfs3ywwVPNFIHFfe10toa3xvAqPlPbWykGBT/T0yj4ET4jjWR+af6wZ1iRcR2KWwWdx6CqveQ+WC3bf3O98MgPEgdOmNFAJf4mjgpnBjoezmylNB6EQ5VH+ROd20a0mE8whBSHfkZFHUB3unddDK23Xx+DXJ8TtfJqLclhhnjiFgKIlgyoGjipcfzvEHUHk4cRM42pHDJsLLMhLwHEbn/a4HRVhKdK/jjehQpRhapaRWhHunE8TWgcw0bj7yQYIR6Uv4HxVuhQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x/vmejaeSvRsPHpxYfGqSBojoVMtKrXNW21IOpFEGAv8deBpPLWjQTPaputaVbEsbrKPBgn0Y0xwh7iGiaIcrq4wL4/UWeuuLBngZ/Xwjt/OJEjnA7v7jmpojuE/pgJY9V1XDFwFBPj9qJpya8Yo5EtTD41eUnBBc9RO5ifqmG5cmPlEjJY1GHX0KExWLiAjLGZ4C1o7crR3NRqABFrJuRLelgDrmS2h4pkGlpHHt/JP8aUfQQi71ltFKzuf4KS86oPtVGdwgQF3E6CaprsQOi1zOoL2OBxSIe+DGSF59a6BY9FjH0BPEo0H6sF8klYMsmIwjssdymMZ+/PM0U/9LA==
  • 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 12:05:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Ross



 


Rackspace

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