Skip to contentSkip to conversation

KVM: s390: pci: Fix aisb calculation

PATCH Applied Farhan Ali 2 participants 2 messages Aug 12 – Aug 15 Stable branch

lore
Share & tools
lore

Farhan Ali

author
#0 lore raw

PATCH 1/1 KVM: s390: pci: Fix aisb calculation

From: Matthew Rosato <[email protected]>

The current implementation of aisb calculation will erroneously index via an unsigned long * as well as multiply by 8B for every 64-bits in the offset; only one or the other is required. This throws off aisb calculations once the number of devices exceeds 64, and can result in out-of-bounds access as well as failure to indicate summary bits associated with those devices in guests.

Fix this by converting to a physical address before applying the offset, as is already done in arch/s390/pci/pci_irq.c.

Fixes 3c5a1b6f0a18 ("KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding")
(cherry picked from commit 0cfe660559e857d7c00ab86c73e4510ce069086f)
[[email protected]: Resolved merge conflict]
---
 arch/s390/kvm/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/pci.c +1 -1
index 4cc554c9d328..ebeaacfdb3bb 100644
@@ -167,7 +167,7 @@ static int kvm_zpci_set_airq(struct zpci_dev *zdev)
 	fib.fmt0.noi = airq_iv_end(zdev->aibv);
 	fib.fmt0.aibv = virt_to_phys(zdev->aibv->vector);
 	fib.fmt0.aibvo = 0;
-	fib.fmt0.aisb = virt_to_phys(aift->sbv->vector + (zdev->aisb / 64) * 8);
+	fib.fmt0.aisb = virt_to_phys(aift->sbv->vector) + (zdev->aisb / 64) * 8;
 	fib.fmt0.aisbo = zdev->aisb & 63;
 	fib.gd = zdev->gisa;
 
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 6 lines

The current implementation of aisb calculation will erroneously index via an unsigned long * as well as multiply by 8B for every 64-bits in the offset; only one or the other is required. This throws off aisb calculations once the number of devices exceeds 64, and can result in out-of-bounds access as well as failure to indicate summary bits associated with those devices in guests.

Queued for 6.18, thanks.

Signature · 2 lines
Thanks,
Sasha