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

Re: [PATCH] x86/nSVM: Ignore bits 11:0 of L1's MSRPM base address


  • To: Stephen Cheng <stephen.cheng@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Mon, 26 Oct 2026 10:05:39 +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=IkgMGXHgq+whQ54tDu7rb8WaTh0/w/JBnU2v8L9bT4k=; b=tnPQ67prVzVLtu8rutxYrePg9BAqm6CZ5VtbYwfk4XBNv5azj0ycB2+0C9Ip6QeF9rZpdXK3Q5RsvkEiAGmH6pJFv/pCBcRDJbchrvgS7ZeSfnZWbgtzX316ZTXIT6ir/+4T/8kVOUjYXparVW36JCm/XZu2Ef8wMemIrNY/1KGi/LshkgQwytJw6JQUWcWj1cZr8ChAl9ivpYcY46VoGAAsDDwZyH8Xuq/c1gcoQm2yJuf9NZtFrmsK0l0htVl02LdrRtl0JxFW8DgdzavYx1pzo53H2jp8sBpSMs7RCEXsizPsaAXfbHVJA71c4Qlx//Q+Yc5kOdrIXkdQaFAa+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q7aNocEFJvS2lFha0B7svs8bzD+tRFKxrZUCDeQW0IyAuljBXVTDokoeayrMZT9f319TiRb6orevBVXdZ7CuK4zGD0z2Vg+ssVEB082cgNMFY6RjnRWCaIDMPZrc+OejD6reVJ6tQJyVOwgKG+xdxdGkOuOh7FGf3Nbqz2+QHf52bq8Mq7Mzwt06j4x73885LpFKswX63Z2G5EXtta3U6HyRYdu/vU+pm2WgIyOc0ihRV4UTG0om7N+zJI2t2nd00wOxtXqaT1UkjzSyJ6VG+ozK4T8hErYu4TtV10NpL1c0d0jQc/X9BX/SgpUpQJivqsaIgwa6M4LjBlhoA50JAQ==
  • 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: 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: Mon, 26 Oct 2026 10:05:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10/26/26 2:38 AM, Stephen Cheng wrote:
VMRUN ignores bits 11:0 of MSRPM_BASE_PA (APM volume 2, 24593 Rev. 3.44,
section 15.11), but nsvm_vmrun_permissionmap() copies L1's MSR permission
map from the address exactly as L1 wrote it.  With any of those bits set,
the copy starts at the wrong offset, so both the merged map and the
intercept check on #VMEXIT use the wrong bits: L1 can miss intercepts it
set or see ones it didn't, and the copy may run into the following page,
giving a spurious VMEXIT_INVALID if that isn't RAM.

Mask the address before copying.

Fixes: 9a779e4fc161 ("Implement SVM specific part for Nested Virtualization")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Stephen Cheng <stephen.cheng@xxxxxxxxxx>
---

Notes:
     To reproduce, in L1: set MSR_PROT, set only FS_BASE's read bit in a
     page-aligned MSRPM, point MSRPM_BASE_PA at the map + 0x800, and run L2
     doing RDMSR of FS_BASE.  L1 should get VMEXIT_MSR; without this patch the
     RDMSR completes in L2 instead.
The IOPM base, handled in the same function, doesn't need the same fix:
     all of its users convert it to a frame number first.

  xen/arch/x86/hvm/svm/nestedsvm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 2b998e26bc..56d0f0fa4d 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -309,8 +309,10 @@ static int nsvm_vmrun_permissionmap(struct vcpu *v)
ns_msrpm_ptr = (unsigned long *)svm->ns_cached_msrpm; + /* VMRUN ignores bits 11:0 of MSRPM_BASE_PA. */
      ret = hvm_copy_from_guest_phys(svm->ns_cached_msrpm,
-                                   ns_vmcb->_msrpm_base_pa, MSRPM_SIZE);
+                                   ns_vmcb->_msrpm_base_pa & PAGE_MASK,
+                                   MSRPM_SIZE);
      if ( ret != HVMTRANS_okay )
      {
          gdprintk(XENLOG_ERR, "hvm_copy_from_guest_phys msrpm %u\n", ret);

base-commit: 4e3c0eeac5761c505f8229e82d265eb29957ca5c

The commit title and message could perhaps be more precise - writing L1's MSR
permission map, etc. is vague and could refer to either L0-L1 or L1-L2 (or
sometimes even L0-L2) depending on the context.

With that tweaked,

Reviewed-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>



 


Rackspace

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