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

[PATCH 5/6] vmx/apicv: Replace the PI_CSW_{FROM,TO} flags with a boolean



Now that vmx_pi_hooks_deassign() no longer keeps the 'switch_to' hook
around on its own, both context switch hooks are always enabled and
disabled together, so there's no point in tracking them separately.

A separate indicator is still needed rather than keying off
pi_ops.vcpu_block: vmx_pi_hooks_assign() relies on the context switch
hooks being active before NDST is set up and vcpu_block is installed.

No functional change.

Assisted-by: Claude Opus 5.5
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
Does AVIC needs the previous split flags (FROM/TO) ?
---
 xen/arch/x86/hvm/vmx/vmx.c            | 12 ++++--------
 xen/arch/x86/include/asm/hvm/domain.h |  3 ++-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 6db2529730..9ae77fe496 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -74,10 +74,6 @@ static int cf_check vmx_msr_write_intercept(
     unsigned int msr, uint64_t msr_content);
 static void cf_check vmx_invlpg(struct vcpu *v, unsigned long linear);
 
-/* Values for domain's ->arch.hvm_domain.pi_ops.flags. */
-#define PI_CSW_FROM (1u << 0)
-#define PI_CSW_TO   (1u << 1)
-
 struct vmx_pi_blocking_vcpu {
     struct list_head     list;
     spinlock_t           lock;
@@ -357,7 +353,7 @@ void vmx_pi_hooks_assign(struct domain *d)
      * This can make sure the PI (especially the NDST feild) is
      * in proper state when we call vmx_vcpu_block().
      */
-    d->arch.hvm.pi_ops.flags = PI_CSW_FROM | PI_CSW_TO;
+    d->arch.hvm.pi_ops.ctxt_switch = true;
 
     for_each_vcpu ( d, v )
     {
@@ -395,7 +391,7 @@ void vmx_pi_hooks_deassign(struct domain *d)
     domain_pause(d);
 
     d->arch.hvm.pi_ops.vcpu_block = NULL;
-    d->arch.hvm.pi_ops.flags = 0;
+    d->arch.hvm.pi_ops.ctxt_switch = false;
 
     for_each_vcpu ( d, v )
     {
@@ -1198,7 +1194,7 @@ static void cf_check vmx_ctxt_switch_from(struct vcpu *v)
     vmx_restore_host_msrs();
     vmx_save_dr(v);
 
-    if ( v->domain->arch.hvm.pi_ops.flags & PI_CSW_FROM )
+    if ( v->domain->arch.hvm.pi_ops.ctxt_switch )
         vmx_pi_switch_from(v);
 }
 
@@ -1207,7 +1203,7 @@ static void cf_check vmx_ctxt_switch_to(struct vcpu *v)
     vmx_restore_guest_msrs(v);
     vmx_restore_dr(v);
 
-    if ( v->domain->arch.hvm.pi_ops.flags & PI_CSW_TO )
+    if ( v->domain->arch.hvm.pi_ops.ctxt_switch )
         vmx_pi_switch_to(v);
 }
 
diff --git a/xen/arch/x86/include/asm/hvm/domain.h 
b/xen/arch/x86/include/asm/hvm/domain.h
index dd7fa96aad..e731096cc4 100644
--- a/xen/arch/x86/include/asm/hvm/domain.h
+++ b/xen/arch/x86/include/asm/hvm/domain.h
@@ -41,7 +41,8 @@ struct mem_sharing_domain
  *     and actually has a physical device assigned .
  */
 struct hvm_pi_ops {
-    unsigned int flags;
+    /* Run the PI hooks upon context switch. */
+    bool ctxt_switch;
 
     /*
      * Hook into arch_vcpu_block(), which is called
-- 
2.56.0



--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

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