From nobody Thu Dec 18 08:07:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538423239553418.78733286906913; Mon, 1 Oct 2018 12:47:19 -0700 (PDT) Received: from localhost ([::1]:40338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g749z-0006WU-0y for importer@patchew.org; Mon, 01 Oct 2018 15:47:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g747a-0005FO-Sp for qemu-devel@nongnu.org; Mon, 01 Oct 2018 15:44:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g747X-00056M-Lx for qemu-devel@nongnu.org; Mon, 01 Oct 2018 15:44:46 -0400 Received: from mail-co1nam03on0614.outbound.protection.outlook.com ([2a01:111:f400:fe48::614]:8231 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g747W-00054U-Gf for qemu-devel@nongnu.org; Mon, 01 Oct 2018 15:44:42 -0400 Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2698.namprd12.prod.outlook.com (20.176.116.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Mon, 1 Oct 2018 19:44:34 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8%3]) with mapi id 15.20.1185.024; Mon, 1 Oct 2018 19:44:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x7BXA+uNftaMJ+NSLwmMLJdoEhJOrVldQrHWi7yBQQU=; b=LUGehk0gl2h1UZqmvSvftYOb9KYo/NTqtEJJ5tk0aiHEwGhnobYdwX5c+R2du67AB7G3wpEFpl576r3QTuhBRxQlGKbx8th43i/GwdtIpAEGgDBS+C8FQz4Tittjn9ANektw/QYrfIVtfZi7fCQW9PC3i9xrQblc4brtZXgWlwA= From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 4/9] x86_iommu/amd: make the address space naming consistent with intel-iommu Thread-Index: AQHUWb8tM4UJDrNJPU+zrJHX6G/UHA== Date: Mon, 1 Oct 2018 19:44:34 +0000 Message-ID: <1538423049-29524-5-git-send-email-brijesh.singh@amd.com> References: <1538423049-29524-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1538423049-29524-1-git-send-email-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR2201CA0033.namprd22.prod.outlook.com (2603:10b6:301:28::46) To DM6PR12MB2682.namprd12.prod.outlook.com (2603:10b6:5:4a::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR12MB2698; 20:igQAzihe/MkbIgCloUaCidgMhxSW15qAdcapnTixW6AyrIgj3LQtt0ozqturnQl+6ViftLZB1H2AW9npSegf+Y+FBj6YZj2nRkpNdx/YlUQW4UySc/1KOlU85SDOcU+1m3tzoBDNeT/Ik0axkt3VfzjlaVn0+T2oeJcJ9CoW3lNbbtuaa+lGBpcWNLbLn1ia1i/fcN5ErzAecEV8xyMmk6xSkgIBrLH0hX3efO7iw5yYS44vW2g9ftXq6mu14h6Q x-ms-office365-filtering-correlation-id: a5994939-cc27-457c-b1b9-08d627d65023 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2698; x-ms-traffictypediagnostic: DM6PR12MB2698: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(10201501046)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:DM6PR12MB2698; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2698; x-forefront-prvs: 0812095267 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(346002)(376002)(366004)(396003)(199004)(189003)(2501003)(105586002)(5250100002)(305945005)(7736002)(106356001)(486006)(68736007)(39060400002)(446003)(6116002)(11346002)(3846002)(97736004)(6486002)(2616005)(6916009)(2351001)(476003)(81156014)(81166006)(2906002)(8676002)(5660300001)(8936002)(256004)(14444005)(186003)(36756003)(26005)(66066001)(6506007)(54906003)(4326008)(86362001)(102836004)(25786009)(76176011)(386003)(5640700003)(6512007)(52116002)(14454004)(53936002)(99286004)(71190400001)(71200400001)(478600001)(2900100001)(6436002)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2698; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: c8g0qu17NBRDU5Jizr3sPIgn9ESukvyHp+aVS3jBpfURJXORKTmzt0/puQjGlKRryNUOxta94iaOkQh0ZL2bNFwgOVa7/Qmu2oYe3gWDfPfpsmQsWE40hx00QB5T8y9D4Fr2HxYNICcFsB0+Mic9VLNH/Nk3nLEs1tJBikeiGpq2agerAXSenfO6AR7+fI4yB0Iik/SbPUwBYwku7n3qkf2gIdsWlNTBbrW5aIAs6Sr6IAMkHyKc4XVlzKggMHjqWdICM5uLragpsPNKpUUlXmS+K1BMBmkCdQp4vdkKJRYnYAMnX0csRTPSS+wi7e3c3/o5z0zxKqVGD6GlM3bOwpRZHK+IDkFnQKMdCjBfs/U= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5994939-cc27-457c-b1b9-08d627d65023 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2018 19:44:34.4357 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2698 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe48::614 Subject: [Qemu-devel] [PATCH v5 4/9] x86_iommu/amd: make the address space naming consistent with intel-iommu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Lendacky, Thomas" , "Singh, Brijesh" , Eduardo Habkost , "Michael S. Tsirkin" , Peter Xu , Paolo Bonzini , "Suthikulpanit, Suravee" , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To be consistent with intel-iommu: - rename the address space to use '_' instead of '-' - update the memory region relationships Signed-off-by: Brijesh Singh Reviewed-by: Peter Xu Cc: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit --- hw/i386/amd_iommu.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 7206bb0..4bec1c6 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -55,6 +55,7 @@ struct AMDVIAddressSpace { uint8_t bus_num; /* bus number */ uint8_t devfn; /* device function */ AMDVIState *iommu_state; /* AMDVI - one per machine */ + MemoryRegion root; /* AMDVI Root memory map region */ IOMMUMemoryRegion iommu; /* Device's address translation region */ MemoryRegion iommu_ir; /* Device's interrupt remapping region */ AddressSpace as; /* device's corresponding address space */ @@ -1032,8 +1033,9 @@ static IOMMUTLBEntry amdvi_translate(IOMMUMemoryRegio= n *iommu, hwaddr addr, =20 static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int d= evfn) { + char name[128]; AMDVIState *s =3D opaque; - AMDVIAddressSpace **iommu_as; + AMDVIAddressSpace **iommu_as, *amdvi_dev_as; int bus_num =3D pci_bus_num(bus); =20 iommu_as =3D s->address_spaces[bus_num]; @@ -1046,19 +1048,37 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *b= us, void *opaque, int devfn) =20 /* set up AMD-Vi region */ if (!iommu_as[devfn]) { + snprintf(name, sizeof(name), "amd_iommu_devfn_%d", devfn); + iommu_as[devfn] =3D g_malloc0(sizeof(AMDVIAddressSpace)); iommu_as[devfn]->bus_num =3D (uint8_t)bus_num; iommu_as[devfn]->devfn =3D (uint8_t)devfn; iommu_as[devfn]->iommu_state =3D s; =20 - memory_region_init_iommu(&iommu_as[devfn]->iommu, - sizeof(iommu_as[devfn]->iommu), + amdvi_dev_as =3D iommu_as[devfn]; + + /* + * Memory region relationships looks like (Address range shows + * only lower 32 bits to make it short in length...): + * + * |-----------------+-------------------+----------| + * | Name | Address range | Priority | + * |-----------------+-------------------+----------+ + * | amdvi_root | 00000000-ffffffff | 0 | + * | amdvi_iommu | 00000000-ffffffff | 1 | + * |-----------------+-------------------+----------| + */ + memory_region_init_iommu(&amdvi_dev_as->iommu, + sizeof(amdvi_dev_as->iommu), TYPE_AMD_IOMMU_MEMORY_REGION, OBJECT(s), - "amd-iommu", UINT64_MAX); - address_space_init(&iommu_as[devfn]->as, - MEMORY_REGION(&iommu_as[devfn]->iommu), - "amd-iommu"); + "amd_iommu", UINT64_MAX); + memory_region_init(&amdvi_dev_as->root, OBJECT(s), + "amdvi_root", UINT64_MAX); + address_space_init(&amdvi_dev_as->as, &amdvi_dev_as->root, name); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, + MEMORY_REGION(&amdvi_dev_as->i= ommu), + 1); } return &iommu_as[devfn]->as; } --=20 2.7.4