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

[PATCH] nestedsvm: Ignore attempts to clear EFER.SVME from L2


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Fri, 13 Nov 2026 16:02:42 +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=6WEGX3dxr11L8I+8jU/dkpXhCeQM7QLbWd2A7YuVelY=; b=Zv5tSXX2zGBm2RUbCz81B11Pk3f0hSk/PHq+S9DPnMurodn8ESr6JRp+3l2ZckbmYJocgJKzObH4anZpbFNxCJzvcLanVtupSSXawDtXl4hgRrOopvlCuSXS4JBV3biT/c1hAEL2OgLadorptEAJi5MRynp0a01YfAheqfaGPKtd3yyIV5Vjn36XjBgCEK8Oo1EgIViDel3G8WdOwVEyS14BxFPTUhsybYwTngNRYkt3EBvBR9cTn+4+LOtoJ6wXuKYnzIX+r+4TsAnX4L93T2t6ndNRqMzJlOuSOEaa0FIDS2oZI3OFOuhLHXV/lVj1vCZvxdm1VI1kPvkxhuoO6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w8BLuHOOrZXkeO1QXIFR7PfPvuH2QawlhPq1+K/QnDfl/BFReN6k/yQZrawwT+IufSbbbCbiXnTz08abahGrP5pkKZfUqUDPnY+hr6Qt1oQKCP1pUXgd7/7JOoJgs7pm9Q3fURlWsQzIov4JY+cfjSn8PQ92nldy2ldpvNjezHK64jVhjIqVbF9EvjckRAyp4TB7z1BU0SeoiAohCjwkjX+z+le2Sy5Y8zMhwG96DtkYD6XTQllzU1qemauYvuBO/k/rcMZ8rHIc9boGzcf8057SohZfvjyZ2SOWBh9ht37dm55i7fchYA37bJfZ08QZmX42D4ydgVJjs8pfwbu4Bg==
  • 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>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Fri, 13 Nov 2026 16:03:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The APM leaves it undefined what happens when the VMM doesn't intercept
writes to EFER and EFER.SVME is cleared. The current implementation in
Xen resets the nested state without doing a VMEXIT which is unexpected
and may potentially hit a BUG or assertion failure.

Therefore, implement the same behaviour as the APM documents for SEV-ES
guests; ignore the attempt to clear it.

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

Another option here could be to fail VMRUN if L1 does not intercept
writes to EFER. However, this wouldn't match the behaviour of real
processors and may cause incomplete toy hypervisors to unexpectedly
fail.

 xen/arch/x86/hvm/hvm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 71da15c0a4ed..f4155f523598 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2156,9 +2156,15 @@ int hvm_set_efer(uint64_t value)
        ((value & EFER_SVME) == 0 ) &&
        ((value ^ v->arch.hvm.guest_efer) & EFER_SVME) )
     {
-        /* Cleared EFER.SVME: Flush all nestedp2m tables */
-        p2m_flush_nestedp2m(v->domain);
-        nestedhvm_vcpu_reset(v);
+        if ( nestedhvm_vcpu_in_guestmode(v) )
+            /* Ignore attempts to clear EFER.SVME from L2 */
+            value |= EFER_SVME;
+        else
+        {
+            /* Cleared EFER.SVME: Flush all nestedp2m tables */
+            p2m_flush_nestedp2m(v->domain);
+            nestedhvm_vcpu_reset(v);
+        }
     }
 
     value |= v->arch.hvm.guest_efer & EFER_LMA;
-- 
2.56.0




 


Rackspace

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