From patchwork Thu Sep 27 16:45:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10618217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D047E913 for ; Thu, 27 Sep 2018 16:51:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2772BBF5 for ; Thu, 27 Sep 2018 16:51:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2BF52BBFA; Thu, 27 Sep 2018 16:51:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2ACB42BBF5 for ; Thu, 27 Sep 2018 16:51:28 +0000 (UTC) Received: from localhost ([::1]:38063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ZVf-0004F7-AE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 12:51:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ZQc-0007tW-RE for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5ZQb-0002QA-B2 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:14 -0400 Received: from mail-co1nam03on0071.outbound.protection.outlook.com ([104.47.40.71]:58376 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 1g5ZQa-0002E8-VZ for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:13 -0400 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=0Av0SWaeHOIPKQ9kYwWcnjzVp2mHNaHLyDFQC6H+kOo=; b=yaw4J4R0lw/dAeefrUyTfeU/zkvZN6WdlSbuve96e9+UFQWFPYDkRXDMCphLLM9RvSQ8OQ4j/src5IGVwOY5kJwSWmY4JjSSRR7faAm+rt7FQ94LBHXDtpo8QXR/kI4iYFCQxSHQD84yZOgG3Thlx0rW4epPtO8AzgCNX0FtbZw= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2748.namprd12.prod.outlook.com (20.176.118.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Thu, 27 Sep 2018 16:45:56 +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.1164.024; Thu, 27 Sep 2018 16:45:56 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v4 4/9] x86_iommu/amd: make the address space naming consistent with intel-iommu Thread-Index: AQHUVoGPhBYyiaEhDUGclZMDZikn9Q== Date: Thu, 27 Sep 2018 16:45:56 +0000 Message-ID: <1538066739-13095-5-git-send-email-brijesh.singh@amd.com> References: <1538066739-13095-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1538066739-13095-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: CY4PR1201CA0007.namprd12.prod.outlook.com (2603:10b6:910:16::17) 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; DM6PR12MB2748; 20:No2MmQc6KNiK8vb98QKxqzG38paWAff31w4DHlyfpKLHpsPgoLQx/+XwoInH+ybAXIwYUoENDCat4EQgJsAvlLDThwWtv0Mig6zila/OgdSAB5mcpVOFWOoSnJnTsrNsfHep3jeR3RF/Xi7EJPSsvm6IzpoNgi4msmPnDC9bSO/2r3Gr7BgVcEqk2MGIg30j8CeyKiBUfglastD3LB6JtPI8I22RQkDMxGp8d+6KC07HcfsfIOxZ/odX8UXiSaBM x-ms-office365-filtering-correlation-id: 19d1a8b6-a382-4195-884b-08d62498b231 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:DM6PR12MB2748; x-ms-traffictypediagnostic: DM6PR12MB2748: 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)(8121501046)(5005006)(823301075)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:DM6PR12MB2748; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2748; x-forefront-prvs: 0808323E97 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(39860400002)(136003)(396003)(376002)(199004)(189003)(8676002)(6916009)(2351001)(54906003)(86362001)(105586002)(14454004)(7736002)(106356001)(99286004)(34290500001)(36756003)(2906002)(305945005)(68736007)(81156014)(478600001)(5660300001)(5640700003)(6116002)(3846002)(26005)(81166006)(39060400002)(2616005)(14444005)(446003)(76176011)(2900100001)(6486002)(6506007)(5250100002)(8936002)(316002)(476003)(11346002)(256004)(71200400001)(52116002)(71190400001)(53936002)(2501003)(66066001)(6436002)(486006)(97736004)(102836004)(25786009)(4326008)(6512007)(186003)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2748; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: DZYgeE66L8ffT5Q6zPkBRZmACWiiQF53j6jes00C7x7gd1TDppkFmRXhN6vk3AW8T0f+3DO6VmkmengnPZOmsP29VKDpKWAp+9rgSbQumMlsyV737lkdfpmkqVxcgBIziAY7VV5Fwosu8sOcMFxMtIC47Z+QFtOPzt6ja7vV2kcWeukN1QDsCb/krJ6Q1n/QrTIks9pObhtIEqqmvUjt1a/IaL9ZVlOoshCn/BHaaREAmiRumhKSuvqROkSVAbDeYYQ2rkz9jMZC9Az8aLsVlLinNPV+JRCBlK9QVWkkaboJ3pOOaEgLe9leQhGFzKyIXw/Yg6TAvP4JyZvf6CO5gJSZCEsenLDElwOvn5PXpFo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d1a8b6-a382-4195-884b-08d62498b231 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2018 16:45:56.6726 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2748 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.71 Subject: [Qemu-devel] [PATCH v4 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To be consistent with intel-iommu: - rename the address space to use '_' instead of '-' - update the memory region relationships Signed-off-by: Brijesh Singh 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 Reviewed-by: Peter Xu --- 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(IOMMUMemoryRegion *iommu, hwaddr addr, static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { + char name[128]; AMDVIState *s = opaque; - AMDVIAddressSpace **iommu_as; + AMDVIAddressSpace **iommu_as, *amdvi_dev_as; int bus_num = pci_bus_num(bus); iommu_as = s->address_spaces[bus_num]; @@ -1046,19 +1048,37 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) /* set up AMD-Vi region */ if (!iommu_as[devfn]) { + snprintf(name, sizeof(name), "amd_iommu_devfn_%d", devfn); + iommu_as[devfn] = g_malloc0(sizeof(AMDVIAddressSpace)); iommu_as[devfn]->bus_num = (uint8_t)bus_num; iommu_as[devfn]->devfn = (uint8_t)devfn; iommu_as[devfn]->iommu_state = s; - memory_region_init_iommu(&iommu_as[devfn]->iommu, - sizeof(iommu_as[devfn]->iommu), + amdvi_dev_as = 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->iommu), + 1); } return &iommu_as[devfn]->as; }