From a548a014233146d98cf6015c8526b2ecec340a00 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 1 Aug 2019 21:39:01 -0700 Subject: [PATCH] pci: Fix MSI-X table and PBA offsets The offsets returned by the table_offset() and pba_offset() function were wrong as they were shifting the value by 3 bits. The MSI-X spec defines the MSI-X table and PBA offsets as being defined on 3-31 bits, but this does not mean it has to be shifted. Instead, the address is still on 32 bits and assumes the LSB bits 0-2 are set to 0. VFIO was working fine with devices were the MSI-X offset were 0x0, but the bug was found on a device where the offset was non-null. Signed-off-by: Sebastien Boeuf --- pci/src/msix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pci/src/msix.rs b/pci/src/msix.rs index f9abe5da3..2c5ec188d 100644 --- a/pci/src/msix.rs +++ b/pci/src/msix.rs @@ -359,11 +359,11 @@ impl MsixCap { } pub fn table_offset(&self) -> u32 { - self.table >> 3 + self.table & 0xffff_fff8 } pub fn pba_offset(&self) -> u32 { - self.pba >> 3 + self.pba & 0xffff_fff8 } pub fn table_bir(&self) -> u32 {