[SLOF] [PATCH slof] pci-properties: Enforce all MMIO BARs to be 64K page aligned

Alexey Kardashevskiy aik at ozlabs.ru
Mon Feb 27 15:54:49 AEDT 2017


From: Yongji Xie <xyjxie at linux.vnet.ibm.com>

QEMU may passthrough a pci device of which BARs are smaller than
64KB(PAGE_SIZE) to guest if the BARs are in an exclusive page.
But these passthru-BARs' mmio page may be shared with other
BARs in guest. This would cause the pci-passthrough fail and mmio
emulation happens in host.

To solve this performance issue, this patch enforces the alignment
of all MMIO BARs allocations to be at least 64K page aligned so that
the mmio page of one BAR would not be shared with other BARs in guest.

Signed-off-by: Yongji Xie <xyjxie at linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---


I am choosing between this and Michael's version or neither. Opinions?


---
 slof/fs/pci-properties.fs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/slof/fs/pci-properties.fs b/slof/fs/pci-properties.fs
index 4f13402..34d500e 100644
--- a/slof/fs/pci-properties.fs
+++ b/slof/fs/pci-properties.fs
@@ -126,6 +126,7 @@
 \ Setup a prefetchable 64bit BAR and return its size
 : assign-mem64-bar ( bar-addr -- 8 )
         dup pci-bar-size-mem64         \ fetch size
+        10000 #aligned                  \ align size to minimum 64K (page size)
         pci-next-mem64 @ 0 = IF          \ Check if we have 64-bit memory range
 	    pci-next-mem
 	ELSE
@@ -137,6 +138,7 @@
 \ Setup a prefetchable 32bit BAR and return its size
 : assign-mem32-bar ( bar-addr -- 4 )
         dup pci-bar-size-mem32          \ fetch size
+        10000 #aligned                  \ align size to minimum 64K (page size)
         pci-next-mem                    \ var to change
         assign-bar-value32              \ and set it all
 ;
@@ -144,6 +146,7 @@
 \ Setup a non-prefetchable 64bit BAR and return its size
 : assign-mmio64-bar ( bar-addr -- 8 )
         dup pci-bar-size-mem64          \ fetch size
+        10000 #aligned                  \ align size to minimum 64K (page size)
         pci-next-mem64 @ 0 = IF          \ Check if we have 64-bit memory range
 	    pci-next-mmio
 	ELSE
@@ -155,6 +158,7 @@
 \ Setup a non-prefetchable 32bit BAR and return its size
 : assign-mmio32-bar ( bar-addr -- 4 )
         dup pci-bar-size-mem32          \ fetch size
+        10000 #aligned                  \ align size to minimum 64K (page size)
         pci-next-mmio                   \ var to change
         assign-bar-value32              \ and set it all
 ;
@@ -169,6 +173,7 @@
 \ Setup an Expansion ROM bar
 : assign-rom-bar ( bar-addr -- )
         dup pci-bar-size-rom            \ fetch size
+        10000 #aligned                  \ align size to minimum 64K (page size)
         dup IF                          \ IF size > 0
                 over >r                 \ | save bar addr for enable
                 pci-next-mmio           \ | var to change
-- 
2.11.0



More information about the SLOF mailing list