<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div class="moz-cite-prefix">在 2015/12/11 17:40, Nikunj A Dadhania
      写道:<br>
    </div>
    <blockquote cite="mid:87twnpb9wu.fsf@abhimanyu.in.ibm.com"
      type="cite">
      <pre wrap="">Yongji Xie <a class="moz-txt-link-rfc2396E" href="mailto:xyjxie@linux.vnet.ibm.com"><xyjxie@linux.vnet.ibm.com></a> writes:

</pre>
      <blockquote type="cite">
        <pre wrap="">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.
</pre>
      </blockquote>
      <pre wrap="">
So this would be basically hard-code (host page size 64k) page size. Is
there a better way to communicate this to the guest ?
</pre>
    </blockquote>
    Yes, I know hard-code is not a good idea.<br>
    <blockquote cite="mid:87twnpb9wu.fsf@abhimanyu.in.ibm.com"
      type="cite">
      <pre wrap="">
We can pass host page size in the device tree and make this generic.
</pre>
    </blockquote>
    So you mean we can add a OF property like "ibm, mmio-bars-alignment"<br>
    for phb device node in QEMU and pass it to SLOF? Thanks.<br>
    <span style="color: rgb(41, 41, 41); font-family: monospace,
      'Courier New', Courier, monospace; font-size: small; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: auto; text-align: start;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;"></span>
    <blockquote cite="mid:87twnpb9wu.fsf@abhimanyu.in.ibm.com"
      type="cite">
      <pre wrap="">
</pre>
      <blockquote type="cite">
        <pre wrap="">
Signed-off-by: Yongji Xie <a class="moz-txt-link-rfc2396E" href="mailto:xyjxie@linux.vnet.ibm.com"><xyjxie@linux.vnet.ibm.com></a>
---
 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
</pre>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>