From patchwork Fri Apr 1 13:05:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Wan X-Patchwork-Id: 64825 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp543108lbc; Thu, 31 Mar 2016 22:44:23 -0700 (PDT) X-Received: by 10.98.64.79 with SMTP id n76mr27961876pfa.149.1459489463297; Thu, 31 Mar 2016 22:44:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h85si18992894pfj.72.2016.03.31.22.44.23; Thu, 31 Mar 2016 22:44:23 -0700 (PDT) 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; dkim=pass header.i=@amdcloud.onmicrosoft.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 S1758270AbcDAFoP (ORCPT + 29 others); Fri, 1 Apr 2016 01:44:15 -0400 Received: from mail-by2on0059.outbound.protection.outlook.com ([207.46.100.59]:21776 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754498AbcDAFoM (ORCPT ); Fri, 1 Apr 2016 01:44:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=G+Xov3ZYmGpWTP7Bpr9FZnK9n/iBqwBqOvvg6i1ZYHg=; b=N+ORbZc54YKnwAVZNQf2Z5oaQWvpY9PohVf9Ouz4a7fOp3QmROWZx6XVLQsTamMjM03e0x+P9EGbCP9KcLjdL3TIvQ12M5M2nyTt7afBysa+3VTpyzis6XPCa+Sgr5YgJnNeSUxJCWLVrNjstmWwIMQVPSSapkBUUSV8UjILDAQ= Received: from BY2PR12CA0022.namprd12.prod.outlook.com (10.160.121.32) by SN1PR12MB0719.namprd12.prod.outlook.com (10.163.209.21) with Microsoft SMTP Server (TLS) id 15.1.447.15; Fri, 1 Apr 2016 05:28:32 +0000 Received: from CO1NAM03FT047.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by BY2PR12CA0022.outlook.office365.com (2a01:111:e400:2c84::32) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Fri, 1 Apr 2016 05:28:32 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) 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 atltwp01.amd.com (165.204.84.221) by CO1NAM03FT047.mail.protection.outlook.com (10.152.81.48) with Microsoft SMTP Server id 15.1.453.6 via Frontend Transport; Fri, 1 Apr 2016 05:28:31 +0000 X-WSS-ID: 0O4XWJH-07-GWX-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2AF7BCAE656; Fri, 1 Apr 2016 01:28:29 -0400 (EDT) Received: from SATLEXCHOV02.amd.com (10.181.40.72) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 1 Apr 2016 00:28:56 -0500 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 1 Apr 2016 00:28:29 -0500 Received: from viwan-emmc.amd.com (10.237.75.161) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.266.1; Fri, 1 Apr 2016 13:28:25 +0800 From: Wan Zongshun To: Joerg Roedel , CC: Suravee Suthikulpanit , Borislav Petkov , Ray Huang , , , Subject: [PATCH V3 2/9] iommu/amd: Modify ivhd_header structure to support type 11h and 40h Date: Fri, 1 Apr 2016 09:05:58 -0400 Message-ID: <1459515965-2865-3-git-send-email-vincent.wan@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan@amd.com> References: <1459515965-2865-1-git-send-email-vincent.wan@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(586003)(5001770100001)(76176999)(86362001)(189998001)(50986999)(2950100001)(77096005)(5008740100001)(92566002)(229853001)(101416001)(11100500001)(33646002)(47776003)(36756003)(5003940100001)(19580405001)(81166005)(19580395003)(5003600100002)(105586002)(50466002)(48376002)(106466001)(1220700001)(1096002)(2906002)(53416004)(87936001)(50226001)(4326007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0719; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; X-MS-Office365-Filtering-Correlation-Id: c8c71132-b71d-413a-9ccd-08d359ee770f X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0719; 2:YVLhPtaa5vsOcGRfGV6Ymi6oOa0Dly/eW6TfNaP7zUHJm2SiXsuXe+/mv8+0OLRnBsu/u+kAj0kADUS64izQIbcOpxIAWywgzhigbGA5D7uzoySL9ZVZ0itAJItVfNrzbKD4tMYfXZNMk9I7obj94xK3WG9GbWhEDXFUjIRO7tcws0B9lQwDucXMIqaIedX7; 3:amUEdNt7Ui5y9gw7kc719jHm9Q5Ko+oR0+t1bATBY93fVpZEByTdiEAQF3LYmCMH2456Ya1BOB7ntMUXMl/+Omn7rDQmagekhUnK2t4yZ8CQs05YL0756HJrcTTTGmU6+q5WppNA4nfjsZ1g6HHCv5wl5EEymPgVbTuOcRpsTIPCjd/N5GhmaVPfwcRVlpOck/tEfzRcJTo2xQIExLRYrAMqy15p2Zhq+gk7zO7hH/I= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0719; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0719; 25:RQDyAGONFKElMfTcJNA4qIZAQV1+dYnQXo10i/AV/ZYV1IH6eVRE9NlpZBdopcK95twOLFkO2GTCpWEXh07sBiwRbiE1qOPrVmQzdZ2FpvlOlye8A8yWnUGGDxBLc/1Tl9gIusd+rXcww49fGwX+D43ORgrPOfIoWyBKmlfRt1+EXsMWKVWAMPqAj2Iq0sBi940L0224P/j4DDkX91apn9YFE0JUh0jqZaRLiZCKkxrDlfBVQoEKx0Vu7EOG/4Aw+PLi9ezoKRkGDcTbnSCecfQV7P3Nz/jgI/6Yj3mLDvzA53FBgSNa8MudP0qnHaSE0X9FtkAiDomR3JllfHEB9Q85A5rFQRNwGR1HBEQz2KNX9sM12CeQgE9/QSEQOc2v7WRFrjHA4wyBerfW08xDqtkyId21xpvB2Y/1HOR3DIKtTn3S1yWUSqpNJK3hE7B4Acd+FZfFkql995+ok3DQDuJ6o19v2G5YTt6qWYwIJcVVwq110Ckoyl03BGJ9RurCLvyHXu1H8mfjaXwwb63tmo6ASVyICiH5iMejQl6rPWWe5EgZPL5vY4s4j/ZdQc7c4pqX5hWLgaYqs89d6btmQQgBtpoA3ObwdHzAKV3TAcpRistRBbppJzSRyLY9bjXC X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0719; 20:FpL7rOTy9WdzYDNZyRt6FBxYiMQs8Hcl8bxZE5uJLroxHGkAS2n9fx4WOYtMypimjXfQs6WVT+33VazbJZVdheGJIvCqL0O1klrYPQE//QZLqNcAnyxWpOwle5m62moJxIoaoc23BCctT36z3zewQsrWs5F0x471xebsEtHN61+MQolNqBh1g5GchdouAgLeCWSO6S0TgSefYjAoXD4jZTD8be1b5nMFtT4kiWL8CmzwY3BY9XkF3ZGG6LspPSftPbosFioijMvebMxm88c3z79luw0u2dXHc0sy57dXLk1CSWLnhHi0I/CFrlt3aSzzjrQ9phZ+5Oz8JhfkR08Mzui4D0Jl5zWJHb7pwhxL821V7nQEJtHFJ7/MkY+FmipuQJXZ7NLULy9umY5/WD3WLm4mu19VlYzkCqwzjzyX+Kh/rHQnviSbZ8+OpqVxWatGbDXGB0uGaCctaDgRi7zOYfw6OlFghOuIljSdWn2czFbHSzYAFMYYnh011TcLVGkj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13023025)(8121501046)(13017025)(13015025)(13024025)(13018025)(3002001)(10201501046); SRVR:SN1PR12MB0719; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0719; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0719; 4:t1lOV5urB/eyCB7HqtkmPV/uUHeNShmJXQ6Ir+TLwRZSS3z1BrOQM1T3r0XEMnkJMm24Un1GMcwV7mYehvy754JwwZ9nBm747K/yk7H/2XDn4vZtqtDdYftVde+RClrcApV0BCxh9PlAFMtGNcTVe7+iCAXP7/JWyF8cZVzHg+WViIXd8C94w3PGjw7rlIekF6G4V7WnG39wNAy8EGdq33mSz/zOGshBmEPFrBlhrbSft9DJIVE2/HD7GRCXMlrx7jAKys3vquGICpotXd8pC8PPXXdcOeNS+MHVw5O+ig4mQiS9L9VwaVN7eahv9R4zgOFQ8EpRGSQndrn1n0p9zlnU+pglEduR6pMAZmJciTqI+Mqh1x08P/Saf2lAkOKNSLXphe2KV4gXYZvaTzzeYMGHraQd3W3u3Zg0KngobDcZ3B+TtMbRCMxlr3Q6vhG38vmfahEt7/pSwSfa9u1g5A== X-Forefront-PRVS: 0899B47777 X-Microsoft-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L9Vj2JHhGuYrLH9cSWtr8CHwW8XBVuJKaLqBIERxkYkag?= =?us-ascii?Q?hVif+MHRPbUsm0ZXXyT09HKAZFxZ1lhJIODAJ4uPZVs+krSEo0zwf7ASgbF7?= =?us-ascii?Q?jVKJD9u/XWoLhysmKG4DN074W1rB+KDZC5QsBDcZugzXZGhsb/5upQTV4/pL?= =?us-ascii?Q?5EHsNBkulocbnDqqTD2p4+n?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0719; 5:MUObv1QaAR+OnRfl0oh+5+dboadSTD55+Zh2igxJW6DIjj3QbNf8jf7ToZNjl9jzTC3mr/6JocEULQaaNqySQ/u6xsJQLcA0zRq01NtWqrC968OT3QMAsEOMvXZXlxXjEtDkYlGvhfgxiscN5+BVww==; 24:ExcEQUBeRpMKk4skrMQKeL+KjbFesdFC47hI8N3zFstkXF9+RmqGnVyY97dIsS+4vLUx0vT+11odPy1sZ0Z5+7k64rEg2xOOZDdCbnSJY8Y=; 20:XmtYA0BiQnrzzw7Um+x2vpwVByfAItiHR/KfJ7dPRmtFVQM/pW9gWnzVYjt0w1dqu/FU2IYaaGRV5Uo6Ja6j1cAyyJcmf7pUFn8dCXFW7GPcFLBuKhh3EHNNBxMr3ylSZ2YiEqRDZZxyoLtENioeSLJWyTaLmlDZ6hhRIkrScXy5RZyHrye/zZMlZnfhNFB301Xvz8JAlMWE7MZRR3pnVBIyFYqd+xNw9V3lxaQgus9vOCWLXdEN6I4zVgOvjrVr SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2016 05:28:31.6159 (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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0719 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 | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index dff1e01..22e078b 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -398,6 +398,22 @@ static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu) release_mem_region(iommu->mmio_phys, iommu->mmio_phys_end); } +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; +} + /**************************************************************************** * * The functions below belong to the first pass of AMD IOMMU ACPI table @@ -424,7 +440,14 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h) u8 *p = (void *)h, *end = (void *)h; struct ivhd_entry *dev; - p += sizeof(*h); + 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 += ivhd_size; end += h->length; while (p < end) { @@ -789,6 +812,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; @@ -804,7 +828,14 @@ 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;