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

Yongji Xie xyjxie at linux.vnet.ibm.com
Fri Dec 11 20:12:53 AEDT 2015


QEMU may passthrough a pci device of which BARs are smaller than
64KB(PAGE_SIZE) to guest if all PCI MMIO BARs are page aligned in
host. But these passthru-BARs' mmio page would be shared with other
BARs in guest if guest doesn't support all PCI MMIO BARs to be page
aligned. 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>
---
 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 da1d4fc..aebc7a7 100644
--- a/slof/fs/pci-properties.fs
+++ b/slof/fs/pci-properties.fs
@@ -127,6 +127,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-mem                    \ var to change
         assign-bar-value64              \ and set it all
 ;
@@ -134,6 +135,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
 ;
@@ -141,6 +143,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-mmio                   \ var to change
         assign-bar-value64              \ and set it all
 ;
@@ -148,6 +151,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
 ;
@@ -162,6 +166,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
-- 
1.7.9.5



More information about the SLOF mailing list