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

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



commit bf28617ffa6dc7c4bfaf629931ad3525a1cacec5
Author:     Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
AuthorDate: Thu Nov 19 10:37:08 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 19 10:37:08 2026 +0100

    nestedsvm: Ignore attempts to clear EFER.SVME from L2
    
    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>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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 7eb4957e16..4334ff678d 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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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