From patchwork Tue Jan 5 10:07:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Wan X-Patchwork-Id: 59167 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5714871lbb; Mon, 4 Jan 2016 18:44:08 -0800 (PST) X-Received: by 10.98.0.133 with SMTP id 127mr74465297pfa.76.1451961848398; Mon, 04 Jan 2016 18:44:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q79si80537974pfi.220.2016.01.04.18.44.08; Mon, 04 Jan 2016 18:44:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754048AbcAECoF (ORCPT + 29 others); Mon, 4 Jan 2016 21:44:05 -0500 Received: from mail-bn1bon0091.outbound.protection.outlook.com ([157.56.111.91]:65194 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753842AbcAECoC (ORCPT ); Mon, 4 Jan 2016 21:44:02 -0500 Received: from SN1PR12CA0008.namprd12.prod.outlook.com (10.162.96.146) by DM3PR12MB0857.namprd12.prod.outlook.com (10.164.7.139) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 5 Jan 2016 02:28:52 +0000 Received: from DM3NAM03FT050.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::205) by SN1PR12CA0008.outlook.office365.com (2a01:111:e400:5174::18) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Tue, 5 Jan 2016 02:28:52 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by DM3NAM03FT050.mail.protection.outlook.com (10.152.82.252) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Tue, 5 Jan 2016 02:28:50 +0000 X-WSS-ID: 0O0GK7X-08-CYJ-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2A2A4D22A15; Mon, 4 Jan 2016 21:28:45 -0500 (EST) Received: from SATLEXDAG04.amd.com (10.181.40.9) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 4 Jan 2016 20:29:40 -0600 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 4 Jan 2016 21:28:47 -0500 Received: from viwan-emmc.amd.com (10.237.75.243) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.266.1; Tue, 5 Jan 2016 10:28:42 +0800 From: Wan Zongshun To: Joerg Roedel , CC: Suravee Suthikulpanit , Borislav Petkov , Ray Huang , , Subject: [PATCH 1/6] iommu/amd: Modify ivhd_header structure to support type 11h and 40h Date: Tue, 5 Jan 2016 05:07:19 -0500 Message-ID: <1451988444-4694-2-git-send-email-vincent.wan@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451988444-4694-1-git-send-email-vincent.wan@amd.com> References: <1451988444-4694-1-git-send-email-vincent.wan@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(189002)(199003)(19580395003)(586003)(36756003)(5003600100002)(11100500001)(5008740100001)(47776003)(5003940100001)(19580405001)(86362001)(48376002)(50466002)(97736004)(76176999)(1096002)(101416001)(5001770100001)(1220700001)(92566002)(50986999)(53416004)(33646002)(87936001)(105586002)(4326007)(50226001)(106466001)(189998001)(77096005)(2950100001)(229853001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0857; H:atltwp02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0857; 2:xRVCRtX3y84EC6yjOHO5WoonU4lHpIQJ+ynn4o0aiU6tZ3RUAaN5UrDaYoI/4GUBCgtwlqir7yqp6eu8WSyQot9FtNKhk9Z4K5Qk60saZrvaQ4FuNF9mocVo5ugbyru29Oyx7I4Oy15EzNIkwZUSVQ==; 3:dzUI6EUJ6yakGPVdRFrJbOzosQ0Dd5XpZAjbOcWhJCoR4QTlbgrKz4Mb12sek9tEV0/Ntp0/KXQ2/uUEa9V3MHgfLfqe7LLX6V+RfNBGbv/C8gL/sDM29UPkAYOk4QRt/1poquSDEpqIQIl/NS8jFY+B1/RrRcX7e54fTnDW2PwX13gYVzlXtItFgGC96v922T+ztvzagInIfpdsbp6uY9ALEpGIlWYrS9xovAexJVo=; 25:BBjp4West6aLrhPBxvYIWMOHxiqYJsE71ocU3h1x0ljJP2wLq2XxVQ8NskTgXT6b8jF/ZFFTsJ+IJNKKexs2MN+mV4GIAtzyOI5073zIZJLacC4VG3apNM5VZylAnndx9nxKhanfDY3YQvVLmTbs4y3/9g8G9T4uYI8H24YYB0QkVG6kxc+hRyh+iIYh+XesovBBtX0rcwtfoOWHp16SCAjkwFbVf2bFNYLEZKgmecpnPhBx1axYVVjyNtYFHR89 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM3PR12MB0857; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0857; 20:3Cl5xTR6UdTi7mzThSdi8DMthTuz4TzjHJjhiBTxIm8i+Yr7ZCXoVFgqgK7jsLo+Pl81cXF5Yuyk7jC0PygEADkEv4vzshAroCL1A/ccZqllLvQ7RoZH+KsjJ3+GFNcnZ1WsqmLTuTq1LKuI/Snuk+8SH9irvAeU/jFXKodUPcg2PBmO+cs8VItaClxZx4U/neBNwhO3BU0D7M8ZmZgNHY7CIslwbwJ7SXPMmGxZxRKJzN0EQ0NxDeFv4y9l9mcWeifuzt1G1hANTiADqeNoHAbTNmzFv//+EOyeXOHf2KWMbdrzI71ExX7SRb1aMrU0BvRC9896wwxI0a89ogkBgK531OPNaFKxHToM80TC6xjD9grVXFLniHXP9TTdfSzJ6Fux9nLcubq9of8AnXydIAH/5IrgmIRMM4UYeY7zM/5SJamy6VN6R5D+0Osvb1FRS4J+TwXgFe02BZm0QkwVh7PTBgPGuRLt5JYyeVaX0JW1Ttm7lmP8C7N3B+FLMs70; 4:nAaLMm+nzQCePbCMw6aGfqYUngjQs48Dc87aNL+i0mOWBcAXwdVsTTv7EbPDxZFmZIcjmlbeqL3bwj3I6zLEhT9YuzRcz2DwT1rUF0pM8BuRC+w/WSfd/OqoTrgLnGYPtqr6rRGzoSGaTYnhD1KUJoqCdKV2iMLt93m7fd6I0snZrZqfN2lO4/BZdFzMr0bQV1QGp+OPVD+8eORthIFdt6XFyaKpqAvcreEtIdhAs37vBTjBqx3IRgD6AYZ2WzR+4uR4BU/uXKAE5jbr5Dr01ZLrIuKDUIYNNK/Hfg7+MFVs1aTY82H15T9qBWJu2b3CdyZ/NjGyMET8RaFShWukfmuVVq8jT07VGz03OWe996ro+29r8cfZYzAS86wr2qJJ+lIlvvzZA2wJEsZPAI2hZiDWu9mqz32zV/61meQj7aQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:DM3PR12MB0857; BCL:0; PCL:0; RULEID:; SRVR:DM3PR12MB0857; X-Forefront-PRVS: 0812095267 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM3PR12MB0857; 23:ECQHp9Auc7BNKvQB6uBs72fmyiqH0Zmj4ziOz4fDB?= =?us-ascii?Q?PxM4adS08gqjp6sDUHoE45T72yfcOGr3nzQkm41w/qNmRdjR/3QTKXox6Tqc?= =?us-ascii?Q?lB6JvU6xeVe03KpglKeEU5YRBXNgNu8mFQ+QeKgl7Pl06eL4c81kyRYHTV/T?= =?us-ascii?Q?TgsxeWsKxDsyCRiTg0aWjUQFxu6G6mR3/du8pbQgyPcsd7JmpM6rFlEV1rsh?= =?us-ascii?Q?XmWkR1ehOPvveg0nilPAU+3qnS6sr4N0CGT8TFhHBRhfyHyydGVYjRgIuTU3?= =?us-ascii?Q?6HdUaGOopc8XDZdgYVVeXm96a+H/9aEwmSUCbVO0XSX7XUvyjNyumADamgMM?= =?us-ascii?Q?eSIdAK9d4ramVj53WLFgNPVok3EkemdV0xZOqCq3EDFkvEa1mfGU5WatBD6S?= =?us-ascii?Q?7cBdRyu0kKVVKVWhDj1uJrtkqX0xC26SaCsGsSmx8K7a9rSOfNLuyqD2DikE?= =?us-ascii?Q?ieasWQ2ZRqwe3gqDOLsr2O+O6r26/L2L7Y1FX1ab2Dg723a5cEEft2cP7DUg?= =?us-ascii?Q?xREOJ32gtd3oj7VH5dzPOCKIA3A5iItb9AlosXAMKdNSJi7IQa+CacXTQhI7?= =?us-ascii?Q?ic20GCf87jGkONOIyTLgnrhJAV1CeU5bbpv2ZSmRQo1VF6tT/tFJOifme2Pc?= =?us-ascii?Q?pYtwLXesnVL5tNoA3qt67Y0qxzKPksgRcye7p5F05f7Nq2Hd3HrxDMwG7TjK?= =?us-ascii?Q?ERyvK6VC/6QFSUTcxsKvscxdmc2Bioe9JjxnYY7prJ2jF7i4msjXr8lP0az9?= =?us-ascii?Q?eWkUrBwEIqFy/IUXUSy6vvE6fEk85Mc1ZBXbtkRljr2/ZmgGAC9pv6Op5Hq9?= =?us-ascii?Q?0/6iCJ6rDoOEAb8kBmbT7MUXLUkaaRN1VLVUIpoYsfSfNBM+RQnyvdoYr4im?= =?us-ascii?Q?MPpYH6IJ8EmTJSHv5aW4Cmx4Agry+nh1WtjdIWa7PY7Ivj4vmtRs1i4IOlCh?= =?us-ascii?Q?WkFok1GDeuOztuTcj9BLOkgSp7ldCisq536UJMfMxtZimLlTl2rXo3c/wK0m?= =?us-ascii?Q?wE=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0857; 5:GmkMywqEn9HA/AfGiUZEuDg4Pi71jRE+QEKKkpTtQPBbaSRp0q5rNleL+SHl+apRX3LkPmxx7+O+mmudJBmWjlkGSQKX6HyOu+xgZxit67U0ppb/1jc4eVKqjzEEU6dGm5ZNH2xYLa76xwgNrOkPtg==; 24:DNHRCy4i4AxGhTDpmBEf2lxRa9+YryPlPC+d3+pBN2B8stVZgnz1SuK+Vsnv5jq4QPux6UUuwzUxg7o0c5JN8Cet9BZ9XpKBBQ9a2Htwcz4=; 20:4inW9rgY6NL/sQumb3hJpl9bfXjUi6Z36jVCoetYxY3QwIkRFDB0MfHlfXs6vCSkbdl5DR9TiW9bp7fKL2LZ12gqigZVyPtpjd/3j/5M2oayDgidGugzdc2CbL1NojTsGCmMmtc75IxCTinCE7BuVa1wfqVQOXWtc0/q17RFvJ5ATfjiWwnzrR0RHMteIhSTzYJQ1WT4Tn1aT6+xub6n93W7J5FnIdX3sOgGJFncDiy+A1+hbqR7t3IliN0Xcoe+ SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2016 02:28:50.5486 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB0857 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit This patch modifies the existing struct ivhd_header, which currently only support IVHD type 0x10, to add new fields from IVHD type 11h and 40h. It also modifies the pointer calculation to allow support for IVHD type 11h and 40h Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 013bdff..2ff7000 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -88,7 +88,7 @@ /* * structure describing one IOMMU in the ACPI table. Typically followed by one - * or more ivhd_entrys. + * or more ivhd_entrys. This struct supports both IVHD type 10h, 11h and 40h. */ struct ivhd_header { u8 type; @@ -99,7 +99,11 @@ struct ivhd_header { u64 mmio_phys; u16 pci_seg; u16 info; - u32 efr; + u32 efr_attr; + + /* Following only valid on IVHD type 11h and 40h */ + u64 efr_reg_img; /* Exact copy of MMIO_EXT_FEATURES */ + u64 res; } __attribute__((packed)); /* @@ -399,6 +403,22 @@ static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu) * ****************************************************************************/ +static inline u32 get_ivhd_header_size(struct ivhd_header *h) +{ + u32 size = 0; + + switch (h->type) { + case 0x10: + size = 24; + break; + case 0x11: + case 0x40: + size = 40; + break; + } + return size; +} + /* * This function calculates the length of a given IVHD entry */ @@ -415,8 +435,14 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h) { u8 *p = (void *)h, *end = (void *)h; struct ivhd_entry *dev; + u32 ivhd_size = get_ivhd_header_size(h); + + if (!ivhd_size) { + pr_err("AMD-Vi: Unsupported IVHD type %#x\n", h->type); + return -EINVAL; + } - p += sizeof(*h); + p += ivhd_size; end += h->length; while (p < end) { @@ -781,6 +807,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu, u32 dev_i, ext_flags = 0; bool alias = false; struct ivhd_entry *e; + u32 ivhd_size; int ret; @@ -796,7 +823,13 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu, /* * Done. Now parse the device entries */ - p += sizeof(struct ivhd_header); + ivhd_size = get_ivhd_header_size(h); + if (!ivhd_size) { + pr_err("AMD-Vi: Unsupported IVHD type %#x\n", h->type); + return -EINVAL; + } + + p += ivhd_size; end += h->length; @@ -1047,9 +1080,9 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) iommu->mmio_phys = h->mmio_phys; /* Check if IVHD EFR contains proper max banks/counters */ - if ((h->efr != 0) && - ((h->efr & (0xF << 13)) != 0) && - ((h->efr & (0x3F << 17)) != 0)) { + if ((h->efr_attr != 0) && + ((h->efr_attr & (0xF << 13)) != 0) && + ((h->efr_attr & (0x3F << 17)) != 0)) { iommu->mmio_phys_end = MMIO_REG_END_OFFSET; } else { iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;