From patchwork Mon Feb 27 04:54:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 732681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vWqNF66q1z9sDG for ; Mon, 27 Feb 2017 16:03:09 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vWqND0VSbzDqGr for ; Mon, 27 Feb 2017 16:03:08 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org X-Greylist: delayed 453 seconds by postgrey-1.36 at bilbo; Mon, 27 Feb 2017 16:03:04 AEDT Received: from ozlabs.ru (ozlabs.ru [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 3vWqN866wpzDqC0 for ; Mon, 27 Feb 2017 16:03:04 +1100 (AEDT) Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 84B533A60009; Sun, 26 Feb 2017 23:54:46 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Mon, 27 Feb 2017 15:54:49 +1100 Message-Id: <20170227045449.43117-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 Subject: [SLOF] [PATCH slof] pci-properties: Enforce all MMIO BARs to be 64K page aligned X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yongji Xie , Michael Roth MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" From: Yongji Xie 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 Signed-off-by: Nikunj A Dadhania --- 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