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

[PATCH v2 1/2] x86/svm: Don't toggle local event delivery on stgi/clgi


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Thu, 7 May 2026 11:55:06 +0100
  • 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=KvcyAkenR48qSLtBoZxitzffCgvZelNVs/f82QPSUT8=; b=aWpETBmUbRplB8UdtImrQ2D0xIr3vKN8lcRHWsSX1TMMVO7vNMbVpNFNMm2nz/KuneI7dIlrOFaPEfdHcTUihmWMMvawo7fDd91D/1cOg/66d1BaTRQwOL5ZtyACFNeOrbA74HlYNJVWW29u/XnMYL5CwufXqWnbpwrODeCfC5CnLPcqVLmJ8+FRNp7s/AQxr0/2fCIcOz6B8rvdgmWGDd/SltcuAO5x8r0uvjFVgO9rArpNnc1775GpieaXHb91VrArNvzFljfIKDT3fX9AooJqFJVvJmFzuZc72X2hB6mvamHPrJF++6dKbAvPmtR6+YNT24cLeJkDMiVWyJpo+w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KgblRAlhqfq5pWmnp9Lmal2yUHFx62ZeCIaR7ZSjTWo+HAJNsw9VAaZ5JQxZ4jjN/l3SiiM6b6AwRTcdsobRw3bMK66Seh0xAyCNyYwd5/ZhkA7zh/ZmHYlIcGpxN6TJZcLJS8iFbX2t/m4nf84be2jr+hh2xEpmEhYXfGboC3QRfjakrWLASTwxVAIPgpmVFKk6/ZfwfrjBP2znsDHiD7K7Q2jhsdDlw+yYgaf8wO+uwhVWxh2SA9u3COgBN+cM0hO+b1e8i1t3VyxPoV4QNncS1EX5XSs6e/jebh0YUCc2JnO7XlsisKvzUFjZXbL5iwI0zmXY4I/2LyyR1Oha7A==
  • 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: 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.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Thu, 07 May 2026 10:55:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

There is no need to explicitly enable/disable local event delivery on
stgi/clgi since HVM event delivery already takes into account the state
of the GIF (and IF). This ensures the behaviour is consistent regardless
of whether vGIF is used.

Fold the functions into the callers since they are now only a single
assignment.

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

New in v2.

 xen/arch/x86/hvm/svm/nestedsvm.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index ef6fa5d23b67..64fbfe8fa71f 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -19,22 +19,6 @@
 #define NSVM_ERROR_VVMCB        1
 #define NSVM_ERROR_VMENTRY      2
 
-static void
-nestedsvm_vcpu_clgi(struct vcpu *v)
-{
-    /* clear gif flag */
-    vcpu_nestedsvm(v).ns_gif = 0;
-    local_event_delivery_disable(); /* mask events for PV drivers */
-}
-
-static void
-nestedsvm_vcpu_stgi(struct vcpu *v)
-{
-    /* enable gif flag */
-    vcpu_nestedsvm(v).ns_gif = 1;
-    local_event_delivery_enable(); /* unmask events for PV drivers */
-}
-
 int nestedsvm_vmcb_map(struct vcpu *v, uint64_t vmcbaddr)
 {
     struct nestedvcpu *nv = &vcpu_nestedhvm(v);
@@ -161,7 +145,7 @@ int cf_check nsvm_vcpu_reset(struct vcpu *v)
 
     svm->ns_iomap = NULL;
 
-    nestedsvm_vcpu_stgi(v);
+    svm->ns_gif = 1;
     return 0;
 }
 
@@ -667,7 +651,7 @@ nsvm_vcpu_vmentry(struct vcpu *v, struct cpu_user_regs 
*regs,
         return ret;
     }
 
-    nestedsvm_vcpu_stgi(v);
+    svm->ns_gif = 1;
     return 0;
 }
 
@@ -1214,7 +1198,7 @@ nestedsvm_vmexit_defer(struct vcpu *v,
     if ( vmcb->_vintr.fields.vgif_enable )
         vmcb->_vintr.fields.vgif = 0;
     else
-        nestedsvm_vcpu_clgi(v);
+        svm->ns_gif = 0;
 
     svm->ns_vmexit.exitcode = exitcode;
     svm->ns_vmexit.exitinfo1 = exitinfo1;
@@ -1502,7 +1486,7 @@ void svm_vmexit_do_stgi(struct cpu_user_regs *regs, 
struct vcpu *v)
     if ( (inst_len = svm_get_insn_len(v, INSTR_STGI)) == 0 )
         return;
 
-    nestedsvm_vcpu_stgi(v);
+    vcpu_nestedsvm(v).ns_gif = 1;
 
     __update_guest_eip(regs, inst_len);
 }
@@ -1523,7 +1507,7 @@ void svm_vmexit_do_clgi(struct cpu_user_regs *regs, 
struct vcpu *v)
     if ( (inst_len = svm_get_insn_len(v, INSTR_CLGI)) == 0 )
         return;
 
-    nestedsvm_vcpu_clgi(v);
+    vcpu_nestedsvm(v).ns_gif = 0;
 
     /* After a CLGI no interrupts should come */
     intr = vmcb_get_vintr(vmcb);
-- 
2.53.0




 


Rackspace

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