Skip to contentSkip to conversation

x86/physdev: Return pirq that irq was already mapped to

PATCH Superseded Jiqian Chen 2 participants 2 messages Jul 8, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/physdev: Return pirq that irq was already mapped to

Fix bug imported by 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq"). After that re-factoring, when pirq<0 and current_pirq>0, it means caller want to allocate a free pirq for irq but irq already has a mapped pirq, then it returns the negative pirq, so it fails. However, the logic before that re-factoring is different, it should return the current_pirq that irq was already mapped to and make the call success.

Fixes 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq")
---
 xen/arch/x86/irq.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/irq.c +1 -0
index 9a611c79e024..1a827ccc8498 100644
@@ -2897,6 +2897,7 @@ static int allocate_pirq(struct domain *d, int index, int pirq, int irq,
                     d->domain_id, index, pirq, current_pirq);
             if ( current_pirq < 0 )
                 return -EBUSY;
+            pirq = current_pirq;
         }
         else if ( type == MAP_PIRQ_TYPE_MULTI_MSI )
         {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Jiqian Chen

Fix bug imported by 0762e2502f1f ("x86/physdev: factor out the code to allocate and

Nit: Perhaps s/imported/introduced/ ?

Quoted 11 lines

map a pirq"). After that re-factoring, when pirq<0 and current_pirq>0, it means caller want to allocate a free pirq for irq but irq already has a mapped pirq, then it returns the negative pirq, so it fails. However, the logic before that re-factoring is different, it should return the current_pirq that irq was already mapped to and make the call success.

Fixes 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq")