From nobody Mon Nov 25 03:01:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1719363635; cv=pass; d=zohomail.com; s=zohoarc; b=Aplc9BkBTc0RHo3UQf0+lGJd65OUfAUTPUHXZGIjxuwusXzH6FYNJPB0DISVmvhkVY4JvKowBrWxdCwevh2g4SuUOZPB70nTmGHA5zWscoMagEmeBsg177tqeAhcxO7cwljj7dMWIzn7ZaAqIJx3jfJArDUiUv0FTLEaIqUCIT8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719363635; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6wOvi1OGUotDm+vB1MY5ShyuvtP9VXlclIHrs5TuR3U=; b=ibTlx9tMv8IMAyY93Afk5JkOwSX68EwVXpc641IUnapWj9lrkr6O3OdwnMno8mFZ2hnc4zVvafqv0qIyB8oJvIVPwP/qworZrcHRINOBqcafWXuaNTZcEnWH2eeG93aPO1nwvgsC5zYECW9bhvp+eUaDEn1JaqAl8FoyHm2s2Zg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719363635320657.513159259653; Tue, 25 Jun 2024 18:00:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMGrc-0008LR-3E; Tue, 25 Jun 2024 20:50:22 -0400 Received: from [2001:470:142:3::10] (helo=eggs.gnu.org) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMGrG-0008AT-R4 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 20:50:12 -0400 Received: from mail-mw2nam10on20607.outbound.protection.outlook.com ([2a01:111:f403:2412::607] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMGqO-00004w-Hy for qemu-devel@nongnu.org; Tue, 25 Jun 2024 20:49:43 -0400 Received: from CH2PR20CA0005.namprd20.prod.outlook.com (2603:10b6:610:58::15) by SN7PR12MB8002.namprd12.prod.outlook.com (2603:10b6:806:34b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.29; Wed, 26 Jun 2024 00:29:43 +0000 Received: from CH1PEPF0000AD80.namprd04.prod.outlook.com (2603:10b6:610:58:cafe::c2) by CH2PR20CA0005.outlook.office365.com (2603:10b6:610:58::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Wed, 26 Jun 2024 00:29:42 +0000 Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000AD80.mail.protection.outlook.com (10.167.244.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 00:29:42 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 25 Jun 2024 17:29:31 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 25 Jun 2024 17:29:31 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 25 Jun 2024 17:29:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hLwwTNf31EI5BVzUMV6hyEnbwzR9TD//RC/qYs0MumfAfdj2poecoV0JNB3lpMiQxytm9MEuG1KYzpJ5KMpDab3l822mnhUSw48Q9dGpUF/0B2hoXwFqyciFt0FRU4zE5sCZkWGLkt4T1BWnHQkicgv9yUDnt0kqwyKYnWuzxbgrnBqgYmgMThWHdXF/28tGPAQi2B/l7OJVklfOmxkMhOryunVX9EMQ7Fj19ZbN6IJ2kihObU5H1VbrXVCU6sUb7Xoy2I62foU0V/bRpw2jO1T6BudTRX4KOeX9y71CoXfw5/emfFB5jDmUZT1Z1QNtD/6rv1Ga1nB2CW3CN0WCEQ== 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=6wOvi1OGUotDm+vB1MY5ShyuvtP9VXlclIHrs5TuR3U=; b=Ql20/zTc1ZU4QbA51pNoL/t8dLyNrsrJE8m1di5nZo95yCP5JiwXOt7PfwXIHh/CndAvdaGxc3LsP61T6/DNr+PnpNOp8KiGESblb78ZIecvt3vD+74zSpD5hmH+C+1R58oREf1r2tEmlV/U9yBnjEKMykO7emguOQbcDb/sbMKodR7m6PHQooTNcynEmHv+zui7BTa2DMx/r/ZJn6bxlPXwgG2w1VDDCZlakqh29UWEJ6OEoCu7Aq4RE59bUSIo0r9BvjeCpfQ3fOQAdkD+Xso4Qq9YQ8+MCze02OvKDRVAlJ/J/nEpzdg/rmNNA+WG7NmKo0fK4uAKg+lfQ97jlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=linaro.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6wOvi1OGUotDm+vB1MY5ShyuvtP9VXlclIHrs5TuR3U=; b=Tkb+d1FSUGocRUqUNEou00p1TATj+dOT5/F11h5RcbQPrKsphmJcIHUSek2HziLcp+nYn+MvMnU2K5HBUnulVjKg2gL8tn59/+QesG21fFfiBlrZDE1+ZQDEAiolOiT1IFVsm9lQaWOm8wv2QrvWMXXCXkF0DKZmfd87bcXKA9qkUL/Aq5on++yRE/4d391kRkTcUZVv8EK9JyRIS7BBw+uCUocoVR2KnCwE5NRcvx+lDWuPWZGOCzUufpvkFqdcSZyldEEyZdNWjOiytP1NecuJVPnpdekJH/iWRX/s08GGauB9w6ZDMBdScio6x19Aj0EL33wMb0Es7bXjR5OlHw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Nicolin Chen To: , , , , , , CC: , , , , Subject: [PATCH RFCv1 08/10] hw/arm/virt-acpi-build: Handle reserved bus number of pxb buses Date: Tue, 25 Jun 2024 17:28:35 -0700 Message-ID: <2f5791d4148859a71bc1eae041cf6c7d478b2cb2.1719361174.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD80:EE_|SN7PR12MB8002:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b133c44-5cb1-47ef-2b50-08dc957712a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|36860700011|376012|7416012|1800799022|82310400024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ITGw7nyVO0foD6UuBse2ibnHs5SVTLMJL07fOvmyTpjdpRehWdNDWKlVgn64?= =?us-ascii?Q?jDimucQvfYtGSwqYBoxODKnjbxoes3apj/qALPyKUtiV9pSSY4yAN2X0YbKA?= =?us-ascii?Q?I8aAzc1HliRX1IChgy6bNuW5sQ2LQIJuB5Ogv3LaB1dSGA5KqDo5luV/Wtvt?= =?us-ascii?Q?MjDQlaZx35uwiEk6Pi3e96O+s3WLPSU1j8viiAAMh+zC0kGg9LQb/cf+45EU?= =?us-ascii?Q?fHOVCHmdXLL4gwsN287i+mHMgm1AJTQ7A4wZ0FBPcCojYU1VA/scZ4aL+V4C?= =?us-ascii?Q?OgN1WP3fCfRnrraNSiqkbWfXcKc7TLgS5FbMiREIIU2rrWNYMBGBXIjHYB/Y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j+uyk6UJZ04lEEObdrGSxqM?= =?us-ascii?Q?sBIJZJRlsRqUxb0QJ3FcOTNwYuf3DtFFvZEMa4lIVMWOhVEkOHpqSzND9pOE?= =?us-ascii?Q?xndyg38XiE4ywZ0YGGP0rOMVjMqFEmxPmDP6TY5/3a7tydp0xWgHy9RaLKtG?= =?us-ascii?Q?MOqh77/T0Jl3dzbFF+WINeun9nwBkW+BczMwXyBDqk5wAtqJrA=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230038)(36860700011)(376012)(7416012)(1800799022)(82310400024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 00:29:42.4641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b133c44-5cb1-47ef-2b50-08dc957712a7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD80.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8002 Received-SPF: softfail client-ip=2a01:111:f403:2412::607; envelope-from=nicolinc@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1719363636731100003 Content-Type: text/plain; charset="utf-8" Each pxb bus created for a nested SMMU has a reserved bus number, allowing a hotplug device to attach to the bus in a later stage. Read it out to apply to the id_count calculation. Signed-off-by: Nicolin Chen --- hw/arm/virt-acpi-build.c | 28 ++++++++++++++++++++++++---- include/hw/arm/virt.h | 13 +++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d5e72800f6..91f53f90ca 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -236,6 +236,12 @@ build_iort_id_mapping(GArray *table_data, uint32_t inp= ut_base, build_append_int_noprefix(table_data, flags, 4); /* Flags */ } =20 +struct AcpiIortIdMappingVM { + VirtMachineState *vms; + GArray *smmu_idmaps; +}; +typedef struct AcpiIortIdMappingVM AcpiIortIdMappingVM; + struct AcpiIortIdMapping { uint32_t input_base; uint32_t id_count; @@ -246,21 +252,34 @@ typedef struct AcpiIortIdMapping AcpiIortIdMapping; static int iort_host_bridges(Object *obj, void *opaque) { - GArray *idmap_blob =3D opaque; + AcpiIortIdMappingVM *idmap_vm =3D opaque; + VirtMachineState *vms =3D idmap_vm->vms; =20 if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; =20 if (bus && !pci_bus_bypass_iommu(bus)) { + VirtNestedSmmu *nested_smmu =3D find_nested_smmu_by_pci_bus(vm= s, bus); int min_bus, max_bus; =20 - pci_bus_range(bus, &min_bus, &max_bus); + if (vms->iommu =3D=3D VIRT_IOMMU_NESTED_SMMUV3) { + /* PCI host bridge hehind a nested SMMU has reserved buses= */ + if (nested_smmu) { + min_bus =3D pci_bus_num(nested_smmu->pci_bus); + max_bus =3D min_bus + nested_smmu->reserved_bus_nums -= 1; + } else { + /* Not connected to a nested SMMU */ + return 0; + } + } else { + pci_bus_range(bus, &min_bus, &max_bus); + } =20 AcpiIortIdMapping idmap =3D { .input_base =3D min_bus << 8, .id_count =3D (max_bus - min_bus + 1) << 8, }; - g_array_append_val(idmap_blob, idmap); + g_array_append_val(idmap_vm->smmu_idmaps, idmap); } } =20 @@ -331,6 +350,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) uint32_t id =3D 0; GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); + AcpiIortIdMappingVM idmap_vm =3D { .vms =3D vms, .smmu_idmaps =3D smmu= _idmaps, }; =20 AcpiTable table =3D { .sig =3D "IORT", .rev =3D 5, .oem_id =3D vms->oe= m_id, .oem_table_id =3D vms->oem_table_id }; @@ -341,7 +361,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) AcpiIortIdMapping next_range =3D {0}; =20 object_child_foreach_recursive(object_get_root(), - iort_host_bridges, smmu_idmaps); + iort_host_bridges, &idmap_vm); =20 nb_nodes =3D 3; /* RC, ITS, SMMUv3 */ =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index dfbc4bba3c..7ac392eb88 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -259,4 +259,17 @@ find_nested_smmu_by_sysfs(VirtMachineState *vms, char = *node) return NULL; } =20 +static inline VirtNestedSmmu * +find_nested_smmu_by_pci_bus(VirtMachineState *vms, PCIBus *pci_bus) +{ + VirtNestedSmmu *nested_smmu; + + QLIST_FOREACH(nested_smmu, &vms->nested_smmu_list, next) { + if (nested_smmu->pci_bus =3D=3D pci_bus) { + return nested_smmu; + } + } + return NULL; +} + #endif /* QEMU_ARM_VIRT_H */ --=20 2.43.0