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

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Mon Feb 27 17:51:45 AEDT 2017


Alexey Kardashevskiy <aik at ozlabs.ru> writes:

> On 27/02/17 17:00, Nikunj A Dadhania wrote:
>> Alexey Kardashevskiy <aik at ozlabs.ru> writes:
>> 
>>> 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?
>> 
>> Can you give pointer to Michael's version ?
>
> Sorry, here it is:
>
> https://github.com/mdroth/SLOF/commit/6ff6827740aba39d8db9bebcc3ae069bdf934d06

Seems fine, assign-var-min-align can be optimized (untested)

: assign-var-min-align ( size var min-align -- al-mem )
   dup 3 pick < IF                 \ ( size var min-align min-align size)
       drop 1 pick                 \ ( size var sz-al)
   THEN
   swap                            \ ( size align var )              
   dup @                           \ ( size align var cur-mem)
   rot                             \ ( size var cur-mem align )
   #aligned                        \ ( size var al-mem )        align the mem to the size
   dup 2swap -rot +                \ ( al-mem var new-mem )     add size to aligned mem
   swap !                          \ ( al-mem )                 set variable to new mem
;

Regards
Nikunj



More information about the SLOF mailing list