Skip to contentSkip to conversation

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

PATCH In review Jiqian Chen 3 participants 4 messages Jul 8, 2024

lore
Share & tools
lore
#0 lore raw

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

Fix bug introduced 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 017a94e31155..47477d88171b 100644
@@ -2898,6 +2898,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
#1 lore raw
Quoted 7 lines · Jiqian Chen

Fix bug introduced 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.

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

As a minor note, we treat Fixes: as a tag like all the others, so tend not to have a blank line between it an the SoB.

Can be fixed on commit - no need to resend.

~Andrew

#2 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Jiqian Chen

Fix bug introduced 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")
Quoted 7 lines
Quoted 4 lines

As a minor note, we treat Fixes: as a tag like all the others, so tend not to have a blank line between it an the SoB.

Learned it, thank you!

Quoted 4 lines

Can be fixed on commit - no need to resend.

~Andrew

Signature · 2 lines
Best regards,
Jiqian Chen.
#3 lore raw
In reply to Andrew Cooper
Quoted 21 lines · Andrew Cooper
Quoted 12 lines · Jiqian Chen

Fix bug introduced 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.

Quoted 7 lines
Fixes 0762e2502f1f ("x86/physdev: factor out the code to allocate

and map a pirq")

Quoted 5 lines

As a minor note, we treat Fixes: as a tag like all the others, so tend
not to have a blank line between it an the SoB.

Can be fixed on commit - no need to resend.

~ Oleksii