[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xen/arm: pci: fix check in pci_check_bar()
- To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 11 Jul 2023 18:04:12 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=48chY0xPaSgtH4igxXtcrcXiKgeKOLWf++UqDMpz7t0=; b=XMJjSyUuDFULHMJAtBJ5i3OdEQzmPPE6wSBG3SU4DdmvkDvifF3QifQ1ziIFxHIgrRFseRiNZzCC9fheYsqASuflRcCvDW5JrsDLjtBegLZ+jkKikdlChp1Xz0uB3T6PakoPXsv+JKUIX7m0/PX/OuevTxawGwo4yzuAbTOtjeE1aJY+hrGgDjqW9e6qc9CGIr1yvExO51BzlVuqn05MckKDXI74NsQfKXTGUtkYvWTc5R343BzukFpEsE8apzljG7imJDbQ4+xMcCr9zmerNCEagi73WOeWY6I+LHroP8wm2hd8e0qHIOxJWoRTqSiQgikxDIiwm9ig4HZtVfbnbQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J523z6dsO4o9ugZR/q8i9IfaecgDlnuXMocbUs+b59sykLInhyF6qsYtI6RiGAScY+ocOIsfRbSAdM03eMBYQc0MB8JTMHH4TZfOkSpR1R8bcWbJNMEnK7+rlgCXj1K/hna+PK3L5TG5o9IGIyb7F6/p4cjtEds1YQHRwkdH2G0NevPOQiKDGJrdULSfDmPSb5BF5tfzREiDYG6ee74Lurvj0zpbL2ypyDS+tQ7PqqY3B9N+881xxZROEUAR4XFz8GcsyB2SQ+Twf+oMlyvXvP3iHqg99DT4CBwbrq41I/VwrZKJa7KCOxzCQHT27y1N94CP5A7khLwu6r5e9/LCiQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>
- Delivery-date: Tue, 11 Jul 2023 16:04:35 +0000
- Ironport-data: A9a23:qufqI6DUH9eSERVW/7/iw5YqxClBgxIJ4kV8jS/XYbTApD8j3jQAz TYcUDrVOf+NNDOmKotzOoTi90hSvZTVnNFqQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4GxB5wRnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwpOxGL2VOz a0jGTUmP0qqpMG82KOec7w57igjBJGD0II3nFhFlGmcIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI9exuuzK7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqy7x2LCXwX+TtIQ6CLm7ytFRhn6q3Fc+IicKBHDkq/iTsxvrMz5YA wlOksY0loAp6EG0R8PhGR25pHKJtAQVXdZ4Gug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ok8d+X0jLrtPAK4XsuOCeePHPJKD1GTJhXm/kGH MMUDX6Oc0F5EG2XX3zhgTXRhrWCwTC1IM1FLKf8/kYyYALOIEJug8JiU6h7sXOMjFGurxeRj oLHFomqNLPmYCbxxe704wyAGssMq982sSSb093
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Jul 11, 2023 at 11:46:47AM -0400, Stewart Hildebrand wrote:
> When mapping BARs for vPCI, it's valid for a BAR start address to equal the
> BAR
> end address (i.e. s == e). However, pci_check_bar() currently returns false in
> this case, which results in Xen not mapping the BAR. In this example boot log,
> Linux has mapped the BARs, but since Xen did not map them, Linux encounters a
> data abort and panics:
>
> [ 2.593300] pci 0000:00:00.0: BAR 0: assigned [mem 0x50008000-0x50008fff]
> [ 2.593682] pci 0000:00:00.0: BAR 2: assigned [mem 0x50009000-0x50009fff]
> [ 2.594066] pci 0000:00:00.0: BAR 4: assigned [mem 0x5000a000-0x5000afff]
> ...
> [ 2.810502] virtio-pci 0000:00:00.0: enabling device (0000 -> 0002)
> (XEN) 0000:00:00.0: not mapping BAR [50008, 50008] invalid position
> (XEN) 0000:00:00.0: not mapping BAR [50009, 50009] invalid position
> (XEN) 0000:00:00.0: not mapping BAR [5000a, 5000a] invalid position
> [ 2.817502] virtio-pci 0000:00:00.0: virtio_pci: leaving for legacy driver
> [ 2.817853] virtio-pci 0000:00:00.0: enabling bus mastering
> (XEN) arch/arm/traps.c:1992:d0v0 HSR=0x00000093010045 pc=0xffff8000089507d4
> gva=0xffff80000c46d012 gpa=0x00000050008012
> [ 2.818397] Unable to handle kernel ttbr address size fault at virtual
> address ffff80000c46d012
> ...
>
> Fix this by changing the condition in pci_check_bar().
>
> Fixes: cc80e2bab0d0 ("xen/pci: replace call to is_memory_hole to
> pci_check_bar")
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
> ---
> xen/arch/arm/pci/pci-host-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/pci/pci-host-common.c
> b/xen/arch/arm/pci/pci-host-common.c
> index 7cdfc89e5211..e0ec526f9776 100644
> --- a/xen/arch/arm/pci/pci-host-common.c
> +++ b/xen/arch/arm/pci/pci-host-common.c
> @@ -406,7 +406,7 @@ bool pci_check_bar(const struct pci_dev *pdev, mfn_t
> start, mfn_t end)
> .is_valid = false
> };
>
> - if ( s >= e )
> + if ( s > e )
I think you want to adjust e to include the full page, ie:
paddr_t e = mfn_to_maddr(end + 1) - 1;
As passing start == end should be assumed to cover a full page, and s
== e won't be possible anymore. Adjusting the check to drop the equal
is still good IMO.
Thanks, Roger.
|