From nobody Sat Oct 4 23:50:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1758700793; cv=pass; d=zohomail.com; s=zohoarc; b=Wj5v9cffz9+40bRbw/KxgATck2m9AR6SfWzSYvv78ofoU20xBHRSIwZoiYHxGAiiHX0+ad9RbRNjiZxJFhX0Cm8rm07BXKSicTF8mFbxqV1uwyF0Jt4QZu4PMvsrICiitSFJwMgYk2us3YkeTdwMcT/WprbZLRB0GGdHWAjxTgA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758700793; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jXNUfWRmkjORiC7yyrgzg//uXWPFCbV0Om1VThH2SYk=; b=AmUgixUrAU9Ckrs2EtV1V+GMIi1tig+ZS/pf+SRaSnmUUgF2W+CSwJWPOzp5UIebyQ3ljN+czRjYkhoRGLwEyO/kZwKxoneBeyVHM5JwdcCbueR/xoTJ4RCZ6lYreD/5IrSSFbrGjGvrN2NtF7KLXnuEi3qmG+3Ntcg4l6kfbu0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758700793414886.2282250599465; Wed, 24 Sep 2025 00:59:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1129037.1469215 (Exim 4.92) (envelope-from ) id 1v1KPU-0000k5-Q3; Wed, 24 Sep 2025 07:59:32 +0000 Received: by outflank-mailman (output) from mailman id 1129037.1469215; Wed, 24 Sep 2025 07:59:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1KPU-0000gd-Ig; Wed, 24 Sep 2025 07:59:32 +0000 Received: by outflank-mailman (input) for mailman id 1129037; Wed, 24 Sep 2025 07:59:31 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1KPT-0007np-E1 for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 07:59:31 +0000 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [2a01:111:f403:c201::3]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65ea5722-991c-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 09:59:29 +0200 (CEST) Received: from PAVPR03MB10102.eurprd03.prod.outlook.com (2603:10a6:102:30d::12) by AS8PR03MB8118.eurprd03.prod.outlook.com (2603:10a6:20b:445::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.9; Wed, 24 Sep 2025 07:59:22 +0000 Received: from PAVPR03MB10102.eurprd03.prod.outlook.com ([fe80::b8c6:f37a:987a:beb]) by PAVPR03MB10102.eurprd03.prod.outlook.com ([fe80::b8c6:f37a:987a:beb%7]) with mapi id 15.20.9137.018; Wed, 24 Sep 2025 07:59:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 65ea5722-991c-11f0-9809-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fE/Y5HaNfdLRN3m42138AiaC5jBKVwBxgjcrxIxLonSGvCn9/ujonyhy9gurupGuFwD/gUcNaBBZ45y8sJzwceyFAyEcfffafVlpK2ak6ef/w+byLmhnR4KGS04FsOOVPOt4HnKbvk06U878FMn9ZTNdhCY4rHSN/lt32jn4VUgUq9v8Z4djCM9GgR9yZxmqQopbGC2wB2tkLDmW5rdPHzROXo25bLdfiNCosO1kF9Cux68ppQTXIwN3Q4ywjLLWw0SDAyeAdpYk2jRwxaRp8nylbj4sfLbC7Uk6xD485ScBvGPtSnx58QTfPQ9uCaAfkO7KIzcOaxorPAxgpgl6ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jXNUfWRmkjORiC7yyrgzg//uXWPFCbV0Om1VThH2SYk=; b=ItX+9E4+w+7t0pHFqrQ4FYGoBSkgGj/wA4WFRKDolTylceDjiZTLX6Y1Xtj1sqV4wRdYsueHGQNKohihBju69uYXbcJ/QJg8OXuyys+vqnF4uONljx7LaxAq8tjQS/1JP5io0r4IbI1bMQO6arhdn6RMG81bWAh6oZn67sHH+L7GTy2T85JrfPsylk1ThvkRL6h9h3CX2iYOSVL2kFGcF9NotIn/P0uylBOdneFkga/o3aaHObbjzfHDfDC0YaTOx19qgNsEkabjZodmUVbwiIdvl8jhzSFZmyvIEwVpBnzNzKv1vqDCZVhw+5L47sPdXi2hR/5VYxkaFf/3ObmECQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jXNUfWRmkjORiC7yyrgzg//uXWPFCbV0Om1VThH2SYk=; b=N5RaAnOuss5j/0K09zkWs+LTL0Gk1sF1+OoRxtLq16NazsDl8b9eq+Fcs339TMyJYaYKfycyiIcL5yQ6gUGP03QOj+HhxuaAwXcnV1NMLo6XKyRyjA+uadO1+NCnvjIrL+K+8WJ8+9HmfnFAXtb9rZMGwaxnb20CLOpzEtHyZIda15dGc4tROijpSmvtqHJ9Nr+7Q6QlCiekXv2Jy8CZDxIOYNpbL+JuA9wJ8vxa8pTJKVtZKpOHavRuqQDqmCICCUF/D5iJT1AkcUMYuUBe/OrxFIIbp7TIODbjZo7eJBPnYqERHzuVEczMMI92CjWmOYUUldpk43HPlhfT9tMYcA== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Luca Fancellu , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk , Stewart Hildebrand , Mykyta Poturai Subject: [PATCH v1 3/8] xen/pci: update DT for hwdom when it uses vpci Thread-Topic: [PATCH v1 3/8] xen/pci: update DT for hwdom when it uses vpci Thread-Index: AQHcLSki3XdXcYrDmUyuu7Fte47UGQ== Date: Wed, 24 Sep 2025 07:59:21 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR03MB10102:EE_|AS8PR03MB8118:EE_ x-ms-office365-filtering-correlation-id: 3f5f2b92-c18f-4538-e5f4-08ddfb40457b x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?qjHsEZSfTN/Yue0EZAHmJjDJpuDD2dvx3uYSCPc9L8lFK1VlEGkDotlSVV?= =?iso-8859-1?Q?nON1xaJlFVdzT8wmwR/ts+XYQgTYRruErVBY2wQIH/TAtBiPYTz1xSPU1N?= =?iso-8859-1?Q?+ywlpFB903tdNa4KuRwBubIh2aWWUsBvQMCRK1pyCTyBgfoPhtmhvte8YZ?= =?iso-8859-1?Q?UA5k6JvO/eGNU+N0gOAjM8Kpp9xnWoKBNXfTaBqEIE8zL12v1FTIyeDLaD?= =?iso-8859-1?Q?A3I0DZtFB3hpPMRLRwLP3y6qoNzYL6/24q0SLV57eZtw+nevJZIWNT0m+4?= =?iso-8859-1?Q?1ezeJ7+czIdmtcpavUQgLjAN7lKP/1vmhoZF8lz0IgOHaoj1IiDOL6KLKV?= =?iso-8859-1?Q?C0VG2hJj5wSsWPgEyX0whrIESrqvDAsDqbZPLCRkqKbLGSGzimeKzIM+rR?= =?iso-8859-1?Q?NQ5tJ9nk/urf3IR0VuGYf3KYcB3xtrwpZdytahwduMApKDl72oNwfnWQ6e?= =?iso-8859-1?Q?cLikheraQBxrpR1HQOfM1TaENolKXW9t4yh3yGd1A+dOS4O0fRE9caCK3Q?= =?iso-8859-1?Q?duXd1ZXT6g0qihri/z/YX3wqv0aTBbEY7oy4vVLwgHqt4QZvJ0jxNIyIba?= =?iso-8859-1?Q?gigicZcB0V4qVvXK7hUwT9uwaywPYeBuHmsUUsNl07/ItvvW86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+7PStL//gpN9hjWezRlxEh2IrHAlV1vMLMnAbz2v9KexXrG0KS?= =?iso-8859-1?Q?ChAEU7k=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB10102.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?3ND8saamag5hUylyhfZ2GcxCaHC0Ni86l/VWm+s+8JOpxWHV+/3IrIcxsg?= =?iso-8859-1?Q?zldrhjb/XhnmPTL1ILwdlYPVgdaofIP1nfc1I6Qzc6N8k/7lno/8cwSNpc?= =?iso-8859-1?Q?AezxBFWbx9mgLBil8yDCeblhRfJ92Vi10IxSQucR/8tLku/etBldp8UTrN?= =?iso-8859-1?Q?v8evmQOEGGRbVxl7Yiu02T1NLAx5hXzrjopaDLhYsIF+mqQb9p8k30uB2H?= =?iso-8859-1?Q?ladPiRCGDVhEKUXLNyzkeVADKiizynJblJBUDZmK8Ri91ySdr0hoVI7UeF?= =?iso-8859-1?Q?OZ1LfLS3nmA2lDg8hEdfbiKMsHiCqAXYilxmGLmKS00FoSUpS9dCbdNmEi?= =?iso-8859-1?Q?Nn/pVjeq+PJXhJDePTuIyxNHUBDzfPpbOvjYjTmhkzFY+6J1Wyh11w3s3I?= =?iso-8859-1?Q?suyXGf4/36I/zQ1+m7Dd2He7aF7vLOf4/MHYJLo501SqIJRrGAeo5PbhFG?= =?iso-8859-1?Q?T6oVL5xBZwRil6Rm2CCTQPitRw+QZYck7OgCG9hChTBVh6l8rREuoCfhn1?= =?iso-8859-1?Q?0SH4ZPNZ/jxI4+r67Nwe/zGe9cR/bI6MvFS+G8Lu6UBxJtn71b3wPcT9b8?= =?iso-8859-1?Q?LMegUPwhBLVHiypOH8Zdf/BOnGwtD7wBqj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9EigXwMmrk1l149c0SMRJzuTrUD93LY9yFiz4lGKmc52e1p++TyUnl?= =?iso-8859-1?Q?ewogeoYKQqMQvWZ+OPtF1GjXYN8DPaW+ktHoJQ4wo7kA5uKaTCrFpQLdtI?= =?iso-8859-1?Q?p4x8D9uX0oeYdkUCCm96wiGIuo+OIPnfExHC7nvB4+G6PiQjBRLHsKhw?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB10102.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f5f2b92-c18f-4538-e5f4-08ddfb40457b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2025 07:59:21.8547 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: y9JKalcRrg83AiMNX7Asej4LWvN+lDj14qUhBUCcMfB9NwQ7Lzs0CRodAnMzjzJOD8WIBm3NdKgDi0cfIrlRfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB8118 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1758700794803116600 Content-Type: text/plain; charset="utf-8" From: Luca Fancellu When pci-scan is enabled and Xen supports vpci for guests, Xen will scan the pci bus to find devices and emulate the pci bus, so the hw domain must see the emulated bus instead of the real one. A new helper function, hwdom_uses_vpci, is implemented and returns true when pci-scan is enabled and Xen is built with CONFIG_HAS_VPCI_GUEST_SUPPORT=3Dy. When hwdom_uses_vpci() is true, a vpci node is created for the hwdom device tree. Depending on whether the guest is using vPCI or not, and whether the domain is using host layout or not, generate the appropriate device tree nodes for the guest and handle the right MMIO regions traps. Signed-off-by: Luca Fancellu Signed-off-by: Stewart Hildebrand Signed-off-by: Mykyta Poturai --- docs/misc/xen-command-line.pandoc | 4 +- xen/arch/arm/domain_build.c | 151 +++++++++++++++++++++++- xen/arch/arm/include/asm/domain_build.h | 1 + xen/arch/arm/include/asm/pci.h | 15 +++ xen/arch/x86/include/asm/pci.h | 6 + 5 files changed, 175 insertions(+), 2 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 4a66c5a8f9..ac8e7bfb7a 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2077,7 +2077,9 @@ Flag to enable or disable support for PCI passthrough =20 > Default: `false` =20 -Flag to enable or disable Xen PCI scan at boot. +Flag to enable or disable Xen PCI scan at boot. When the flag is enabled, = the +hardware domain cannot have access to the real PCI bus, it will see the bus +emulated by Xen. =20 ### pcid (x86) > `=3D | xpti=3D` diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4bbffdf535..f49e0e6486 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -41,6 +41,7 @@ #include #include #include +#include =20 static unsigned int __initdata opt_dom0_max_vcpus; integer_param("dom0_max_vcpus", opt_dom0_max_vcpus); @@ -1557,6 +1558,142 @@ int __init make_chosen_node(const struct kernel_inf= o *kinfo) return res; } =20 +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT +struct vpci_param { + uint64_t vpci_ecam_base; + uint64_t vpci_ecam_size; + uint64_t vpci_mem_base; + uint64_t vpci_mem_size; + uint64_t vpci_mem_prefetch_base; + uint64_t vpci_mem_prefetch_size; +}; + +static int __init handle_vpci_range(const struct dt_device_node *dev, + uint32_t flags, uint64_t addr, uint64_= t len, + void *data) +{ + struct vpci_param *vpci =3D (struct vpci_param *)data; + + if ( !(flags & IORESOURCE_MEM) ) + return 0; + + if ( !(flags & IORESOURCE_PREFETCH) && addr < GB(4) ) + { + vpci->vpci_mem_base =3D addr; + vpci->vpci_mem_size =3D len; + } + else if ( flags & IORESOURCE_PREFETCH ) + { + vpci->vpci_mem_prefetch_base =3D addr; + vpci->vpci_mem_prefetch_size =3D len; + } + return 0; +} + +int __init make_vpci_node(struct domain *d, void *fdt) +{ + /* reg is sized to be used for all the needed properties below */ + __be32 reg[((GUEST_ROOT_ADDRESS_CELLS * 2) + GUEST_ROOT_SIZE_CELLS + 1) + * 2]; + __be32 *cells; + char buf[22]; /* pcie@ + max 16 char address + '\0' */ + int res; + struct vpci_param vpci =3D { + .vpci_ecam_base =3D GUEST_VPCI_ECAM_BASE, + .vpci_ecam_size =3D GUEST_VPCI_ECAM_SIZE, + .vpci_mem_base =3D GUEST_VPCI_MEM_ADDR, + .vpci_mem_size =3D GUEST_VPCI_MEM_SIZE, + .vpci_mem_prefetch_base =3D GUEST_VPCI_PREFETCH_MEM_ADDR, + .vpci_mem_prefetch_size =3D GUEST_VPCI_PREFETCH_MEM_SIZE + }; + + if ( domain_use_host_layout(d) ) + { + struct pci_host_bridge *bridge; + + bridge =3D pci_find_host_bridge(0, 0); + + vpci.vpci_ecam_base =3D bridge->cfg->phys_addr; + vpci.vpci_ecam_size =3D bridge->cfg->size; + + res =3D dt_for_each_range(bridge->dt_node, handle_vpci_range, &vpc= i); + if ( res < 0 ) + return -EINVAL; + } + + snprintf(buf, sizeof(buf), "pcie@%"PRIx64, vpci.vpci_ecam_base); + dt_dprintk("Create vpci node\n"); + res =3D fdt_begin_node(fdt, buf); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "pci-host-ecam-generic"= ); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "device_type", "pci"); + if ( res ) + return res; + + /* Create reg property */ + cells =3D ®[0]; + dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_C= ELLS, + vpci.vpci_ecam_base, vpci.vpci_ecam_size); + + res =3D fdt_property(fdt, "reg", reg, + (GUEST_ROOT_ADDRESS_CELLS + + GUEST_ROOT_SIZE_CELLS) * sizeof(*reg)); + if ( res ) + return res; + + /* Create bus-range property */ + cells =3D ®[0]; + dt_set_cell(&cells, 1, 0); + dt_set_cell(&cells, 1, 255); + res =3D fdt_property(fdt, "bus-range", reg, 2 * sizeof(*reg)); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#address-cells", 3); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#size-cells", 2); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "status", "okay"); + if ( res ) + return res; + + /* + * Create ranges property as: + * <(PCI bitfield) (PCI address) (CPU address) (Size)> + */ + cells =3D ®[0]; + dt_set_cell(&cells, 1, GUEST_VPCI_ADDR_TYPE_MEM); + dt_set_cell(&cells, GUEST_ROOT_ADDRESS_CELLS, vpci.vpci_mem_base); + dt_set_cell(&cells, GUEST_ROOT_ADDRESS_CELLS, vpci.vpci_mem_base); + dt_set_cell(&cells, GUEST_ROOT_SIZE_CELLS, vpci.vpci_mem_size); + dt_set_cell(&cells, 1, GUEST_VPCI_ADDR_TYPE_PREFETCH_MEM); + dt_set_cell(&cells, GUEST_ROOT_ADDRESS_CELLS, vpci.vpci_mem_prefetch_b= ase); + dt_set_cell(&cells, GUEST_ROOT_ADDRESS_CELLS, vpci.vpci_mem_prefetch_b= ase); + dt_set_cell(&cells, GUEST_ROOT_SIZE_CELLS, vpci.vpci_mem_prefetch_size= ); + res =3D fdt_property(fdt, "ranges", reg, sizeof(reg)); + if ( res ) + return res; + + res =3D fdt_end_node(fdt); + + return res; +} +#else +static inline int __init make_vpci_node(struct domain *d, void *fdt) +{ + return 0; +} +#endif + static int __init handle_node(struct domain *d, struct kernel_info *kinfo, struct dt_device_node *node, p2m_type_t p2mt) @@ -1615,7 +1752,12 @@ static int __init handle_node(struct domain *d, stru= ct kernel_info *kinfo, dt_dprintk(" Skip it (blacklisted)\n"); return 0; } - + /* If Xen is scanning the PCI devices, don't expose real bus to hwdom = */ + if ( hwdom_uses_vpci() && dt_device_type_is_equal(node, "pci") ) + { + dt_dprintk(" Skip it (pci-scan is enabled)\n"); + return 0; + } /* * Replace these nodes with our own. Note that the original may be * used_by DOMID_XEN so this check comes first. @@ -1766,6 +1908,13 @@ static int __init handle_node(struct domain *d, stru= ct kernel_info *kinfo, if ( res ) return res; } + + if ( hwdom_uses_vpci() ) + { + res =3D make_vpci_node(d, kinfo->fdt); + if ( res ) + return res; + } } =20 res =3D fdt_end_node(kinfo->fdt); diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include= /asm/domain_build.h index c6fec3168c..bb36e0150b 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -6,6 +6,7 @@ =20 typedef __be32 gic_interrupt_t[3]; int make_psci_node(void *fdt); +int make_vpci_node(struct domain *d, void *fdt); void evtchn_allocate(struct domain *d); =20 /* diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h index 7289f7688b..4fc46da315 100644 --- a/xen/arch/arm/include/asm/pci.h +++ b/xen/arch/arm/include/asm/pci.h @@ -176,4 +176,19 @@ static inline int pci_get_new_domain_nr(void) } =20 #endif /*!CONFIG_HAS_PCI*/ + +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT +static inline bool hwdom_uses_vpci(void) +{ + return pci_scan_enabled; +} + +#else /*!CONFIG_HAS_VPCI_GUEST_SUPPORT*/ + +static inline bool hwdom_uses_vpci(void) +{ + return false; +} +#endif /*!CONFIG_HAS_VPCI_GUEST_SUPPORT*/ + #endif /* __ARM_PCI_H__ */ diff --git a/xen/arch/x86/include/asm/pci.h b/xen/arch/x86/include/asm/pci.h index 0b98081aea..08e8959d0d 100644 --- a/xen/arch/x86/include/asm/pci.h +++ b/xen/arch/x86/include/asm/pci.h @@ -76,4 +76,10 @@ int pci_sanitize_bar_memory(struct rangeset *r); =20 void pci_setup(void); =20 +/* Unlike ARM, HW domain does not ever use vpci for x86 */ +static inline bool hwdom_uses_vpci(void) +{ + return false; +} + #endif /* __X86_PCI_H__ */ --=20 2.34.1