[for-4.13,v4,1/3] vmx: add ASSERT to prevent syncing PIR to IRR...
diff mbox series

Message ID 20191113155940.81837-2-roger.pau@citrix.com
State New
Headers show
Series
  • x86/passthrough: fix interrupt migration when using posting
Related show

Commit Message

Roger Pau Monne Nov. 13, 2019, 3:59 p.m. UTC
... if the vCPU is different than the one currently running or if it's
running on a different pCPU.

No functional change intended.

Suggested by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Juergen Gross <jgross@suse.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Jan Beulich Nov. 14, 2019, 12:25 p.m. UTC | #1
On 13.11.2019 16:59, Roger Pau Monne wrote:
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -2054,6 +2054,17 @@ static void vmx_sync_pir_to_irr(struct vcpu *v)
>      unsigned int group, i;
>      DECLARE_BITMAP(pending_intr, NR_VECTORS);
>  
> +    if ( v != current && v->is_running )

Iirc it was suggested to use vcpu_runnable() here. Is there a reason
you used the less reliable (more prone to races) ->is_running?

Jan
Roger Pau Monne Nov. 14, 2019, 1:15 p.m. UTC | #2
On Thu, Nov 14, 2019 at 01:25:54PM +0100, Jan Beulich wrote:
> On 13.11.2019 16:59, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/hvm/vmx/vmx.c
> > +++ b/xen/arch/x86/hvm/vmx/vmx.c
> > @@ -2054,6 +2054,17 @@ static void vmx_sync_pir_to_irr(struct vcpu *v)
> >      unsigned int group, i;
> >      DECLARE_BITMAP(pending_intr, NR_VECTORS);
> >  
> > +    if ( v != current && v->is_running )
> 
> Iirc it was suggested to use vcpu_runnable() here. Is there a reason
> you used the less reliable (more prone to races) ->is_running?

My mistake, I don't think there's any reason to prefer is_running over
vcpu_runable in this case. I can resend with this fixed, but I will
wait for comments on the other patches.

Thanks, Roger.

Patch
diff mbox series

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index a55ff37733..e5e674c373 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2054,6 +2054,17 @@  static void vmx_sync_pir_to_irr(struct vcpu *v)
     unsigned int group, i;
     DECLARE_BITMAP(pending_intr, NR_VECTORS);
 
+    if ( v != current && v->is_running )
+    {
+        /*
+         * Syncing PIR to IRR must not be done behind the back of the CPU,
+         * since the IRR is controlled by the hardware when the vCPU is
+         * executing.
+         */
+        ASSERT_UNREACHABLE();
+        return;
+    }
+
     if ( !pi_test_and_clear_on(&v->arch.hvm.vmx.pi_desc) )
         return;