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

yongji xie xyjxie at linux.vnet.ibm.com
Mon Dec 14 15:29:46 AEDT 2015



在 2015/12/11 17:40, Nikunj A Dadhania 写道:
> Yongji Xie <xyjxie at linux.vnet.ibm.com> writes:
>
>> 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.
> So this would be basically hard-code (host page size 64k) page size. Is
> there a better way to communicate this to the guest ?
Yes, I know hard-code is not a good idea.
> We can pass host page size in the device tree and make this generic.
So you mean we can add a OF property like "ibm, mmio-bars-alignment"
for phb device node in QEMU and pass it to SLOF? Thanks.
>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/slof/attachments/20151214/12541b61/attachment.html>


More information about the SLOF mailing list