From patchwork Tue Apr 18 21:18:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9686441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AB94602C2 for ; Tue, 18 Apr 2017 21:26:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AE9D2094F for ; Tue, 18 Apr 2017 21:26:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D8FF269DA; Tue, 18 Apr 2017 21:26:30 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDFC72094F for ; Tue, 18 Apr 2017 21:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932839AbdDRV0C (ORCPT ); Tue, 18 Apr 2017 17:26:02 -0400 Received: from mail-sn1nam01on0067.outbound.protection.outlook.com ([104.47.32.67]:52000 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753509AbdDRVTA (ORCPT ); Tue, 18 Apr 2017 17:19:00 -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; bh=mVVlcDIQonIupQP0S4kWI7+TqeSWq6Mtld6YaKB8xX8=; b=fLgDR9wIfA3L37lIykJNkhlf1nl6PaZa8XJGr9WxBq2LGHL9Cce+jModcBnpqZR1I4IWa9Fj2XN/S0FtHsyIEvap/TkgJEGpkL1Vrrjpr7iB9x+xQ0JqcfhdKCpWrL1uKLy0a5YuQAlqLk+8IvMseAsIel+gpTBuwTfMZ8mRHgM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:18:51 +0000 From: Tom Lendacky Subject: [PATCH v5 14/32] efi: Add an EFI table address match function To: , , , , , , , , , CC: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Tue, 18 Apr 2017 16:18:48 -0500 Message-ID: <20170418211848.10190.65062.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR12CA0045.namprd12.prod.outlook.com (10.175.82.159) To BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b97c80cc-d829-4020-814f-08d486a084f7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BN6PR12MB1138; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1138; 3:2zEUQWQ/JBOVf0ATul4+fjOqGjAko1bl+8tPKgSrQFJJqTVSKUdgJ89dVd36M+Lf19T1JHEyFdj51MIuOOtmHCE7Lr0qcug5054pOJl9Ab0oA/OAfiCNtS57NJltKTXJq7rgu8PVQMiB03inEq3O1QVzmw/w5xXRYXBM3Z+FLtdK3Bvowrv1WSrY8Cpn2alc9/PCTcmIEZwUp92+B9GSUTLsrNw/G0wVYfVoiPrduXV+LLcnWJ1SUY3NYMybktenPHgnA0c3gd0k7zB9NgVJFvtJ6ccLKi7V9RGuBqu0PBTRgGJoBYidh1qoghZvWNe5i6HahkRBoovG/BFA3LH9+chX4M4RyqkaiynVqyykyC8=; 25:0AvpXbB8rTegiHo/sPLe1STVq8AUCj38Wem4n3PP2YdO7/f8sUx5BfChaxm/iJkaO8DbBUY3VyYMBQRrTPJ5xaZrMGObjQL+070MPCeHoNYoZsQFgU/DQqPy9MuoWrUwZCvIohoEwtb8VJAaPJlovvdLF0hagPWO3bOChBlQpHy2kNL6mt68AclHwd96g3CGAtwE2O3pOJzeenJhmNKuk5SaIpzI9ggzGB4EHCJeOI7vmB8eSx7U0abR3QtQ3Zm3bMvNnwRJAi+/y2ldoUtYleeugyiDXH5TbEBbvxZ4k8pKdDCfOaoThFdzcxNscxU/bSMihtjH2KEJnOcTlfptqp1vwA+LIt22mHimpAtnPyvQgKG0aR7GOJJV1m6N3H9NoXXfW0+x/i6Am7LPd1UGfEgnRDoRhGPFSqGwH8C+7fXwQUMH/e8Mw5Axz1Hp2XYkYCgMSQcDPTvXDxQdzfrDrA== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1138; 31:xAvgiFfqdF6yrLViKZpjVcJfPHN97jiBGxyt9EYRYdgizJaU5dl3Zvqj+OvEYqIuULGYmKah78axZ5PuhD2N5qUJE5D3OErR9+3j082bEpMzbc6L9ZqH8cho59Ss17WH25juZi5EYrDlX4Hv+jgKcRRGbUI7g0Q1HGTRd9tFcoyYbbjysvdP32D7cBXQf1kQatWj3fMw/GVTSWOF8RrfgNnpnEhTqHCkfA920kRiGPxBvCcm4FYp7C4BoZi+NJg2; 20:PnwUu23cBXIGRxbLp10f6quvfkQ3fui+R1/xJaPctUH8N0dMYJTJeU4OHk6574uNhY7TeiinIOlZ2fkEgCA5KOAxpU/4jc9vHTdOTrnz+H16XGCPJCqcDGXuUhHiqfTGeIF6tHp/5ewlPWxeddTq7p0PiQiKR+uj929+92ZAYDN+DmWIya32fEbFpKuzcMVfAPq0o88fSBXExlHQy1WnvS9wxHRcgbvh//MlwlUJwGcghDFS44C+KNMGJaL9EUYKbGxxaZce2sjBzAvg7hX2yRSCeHEJ9pEPRKo/3xzFLToXyTqy0VZAm6pauylI7TZfIevD53fyj4xjFuMKZzBpUEZ1Bq96eZQCwX+8Ph3fmMculVI3XnN1KWMMImOMNEIXghGn+KSna85LhNtsxrhGPMb+YKRZTeS5LUHmXckjfIJcbwx9MbYsYEcYjM6V3Kx+HTis8uEgS+PMZOCSTgmHGBsUtExyoFumoindzJQECKPbe2dTV/d3krSO8iz5n53z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:BN6PR12MB1138; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1138; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1138; 4:fkZ/D1tWo0qyx71itc0m+/jammxmtAGbwRszR1/gGhpiuMEfc/fNzFnjTJ1bzszgOAWDnT2v2lzbBKSqPhpCK3k4WIPcPWgJrWXrupZuKs8PQgrdfnk8mWN2oFw9GNat/vIATDvTRRfI8xqE/2B5+P/gRDyT+tRaL5MmWNvUNU47/oqybgfWgomTPSg53CSZbbUxAKbKLyEFqaAvveCCFIZZnujat43hNZ1TjKT9TNfTivgjniiuhfvhSwaiWkBExW/SMvGXluh3kyF1ZSVpCNyc+pMyvpnxqazvvHtM6bhwMynokOAasE20Egh9AKKnqpeT0ZeSO7uMK3Pu0cjjXJREBfrSXrRiwG0mZNh64plwbwIbPlsP0enz5B12G5rB+eucaw7ksZpXfO5W1dM1J4vIW/t+Q2vP7gbUxb909YTaC2BxYsrAYUzp28gGZaTiKcGdGjTGQk+Mli8ig13TmSZrCE8JootWHkajyl9IPypSzKOUnUVNGlmmnyw03yXv5KYQYd9jlm5KEmacDtvGO+vDnaVnY7XzTXK7M9MYEXxPnrEChuyfyi0AUjqbaKgy1ixm4AtumMcRsQ1eOh0ATZrMwt3RqSAxsXiNZf9CLAxFPYqbKkj8p9H9O0uX5RDsstvsdoA9XIMM2ypxs9aet540gdqB3kCHSmrg565i7e81acvLjhqUYZVdSE+a2V+QhFsQ0WI3TkhmzTs/35VBBWcU1u0oHqHws/sb718diNU6On7Dkg+wG53qjy1p9/RdUvV+EPIrAADq9cpUNeba6g== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39860400002)(39400400002)(39850400002)(39840400002)(39450400003)(39410400002)(103116003)(305945005)(33646002)(23676002)(47776003)(7736002)(6666003)(53936002)(2950100002)(2906002)(83506001)(4326008)(230700001)(9686003)(50466002)(25786009)(189998001)(86362001)(76176999)(2201001)(81166006)(54906002)(1076002)(50986999)(54356999)(8676002)(97746001)(42186005)(7406005)(38730400002)(53416004)(66066001)(5660300001)(55016002)(6506006)(4001350100001)(7416002)(6116002)(3846002)(71626007)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1138; H:tlendack-t1.amdo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gtR0OIRtZo4OGitiy75G+9maUIOlf8cXZsLrQlbygfD9BIObAprGaLeTfxY43himRgmVTA==; 20:LAz4Yn1IslPFv0Nrv81znkH0pSjBei4/xzx1DOPZOh4xYbtZc2augu/UDIXLw2We8lFrLlh/tXt+WNnf+2a4TxfoJJXy462FeV93Jj2OSj2gJMR4ptRqJFsrgHxuhB20VrwpoUtnUySAf6cSdywPetW5qIe8T6Ufc2B8dWk5m1X5O9aecf7BKYWqDU3eo0UnOgfRJzWXktijcjy/2dS0Yjw3mvT6daUKfguuM81kyYTirGZO9+whVXpDWrx+Owl5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:18:51.3684 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1138 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a function that will determine if a supplied physical address matches the address of an EFI table. Signed-off-by: Tom Lendacky --- drivers/firmware/efi/efi.c | 33 +++++++++++++++++++++++++++++++++ include/linux/efi.h | 7 +++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index b372aad..8f606a3 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -55,6 +55,25 @@ struct efi __read_mostly efi = { }; EXPORT_SYMBOL(efi); +static unsigned long *efi_tables[] = { + &efi.mps, + &efi.acpi, + &efi.acpi20, + &efi.smbios, + &efi.smbios3, + &efi.sal_systab, + &efi.boot_info, + &efi.hcdp, + &efi.uga, + &efi.uv_systab, + &efi.fw_vendor, + &efi.runtime, + &efi.config_table, + &efi.esrt, + &efi.properties_table, + &efi.mem_attr_table, +}; + static bool disable_runtime; static int __init setup_noefi(char *arg) { @@ -854,6 +873,20 @@ int efi_status_to_err(efi_status_t status) return err; } +bool efi_table_address_match(unsigned long phys_addr) +{ + unsigned int i; + + if (phys_addr == EFI_INVALID_TABLE_ADDR) + return false; + + for (i = 0; i < ARRAY_SIZE(efi_tables); i++) + if (*(efi_tables[i]) == phys_addr) + return true; + + return false; +} + #ifdef CONFIG_KEXEC static int update_efi_random_seed(struct notifier_block *nb, unsigned long code, void *unused) diff --git a/include/linux/efi.h b/include/linux/efi.h index ec36f42..cd768a1 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1079,6 +1079,8 @@ static inline bool efi_enabled(int feature) return test_bit(feature, &efi.flags) != 0; } extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); + +extern bool efi_table_address_match(unsigned long phys_addr); #else static inline bool efi_enabled(int feature) { @@ -1092,6 +1094,11 @@ static inline bool efi_enabled(int feature) { return false; } + +static inline bool efi_table_address_match(unsigned long phys_addr) +{ + return false; +} #endif extern int efi_status_to_err(efi_status_t status);