From patchwork Fri Aug 25 15:50:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111035 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1219977qge; Fri, 25 Aug 2017 09:00:12 -0700 (PDT) X-Received: by 10.84.224.1 with SMTP id r1mr11299859plj.442.1503676812005; Fri, 25 Aug 2017 09:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676811; cv=none; d=google.com; s=arc-20160816; b=W5cDEMK/qk/qULpssZASbhvXc4P5uQNkHUqqrv56hkvi7xvFiOTqu2/YJmbJjtvEUE ts4Jy2k0CNJ+tbVmkTbY5xRz8BHXCLAKPG6CEKEJJdul9pikgpZ108BFzt/Y1PmpTHyo 2AGp0w+3zxVgAUACVNph5D25wXeSVIeCref4eaj3I5MJ9xzx3XSm2ozk21Af42oeiDiM UmWax+29yzrbn1oev0Q1Xha7z9rYfu0B+emPRhNtlVDhdA1jK5cQQ+Q32mIbE+rMhPpv MI6PdWMvY0ucJu2nJmhYMVgiQt3OqUdxjVoTHVErCLwUe8xbclKpl/CzMC38pSmxSSxn CqKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=wARPegnfWw9GD6pWeIeL98hEp0bwn383KFu68CKcYaTKPvCGnczyv639ZPSbwNC2Lq +AguPgZbqgPTrOaY5OSQA01wGonwChlevsKgLDI5NK+jcrMqCKftT0aFm8i6JxgdyKPa NlF4xWHhyrKeFJ2A6Y7CuIh0svUjeWnW2oq6U4wp27MJ1XGFZNjRNnJcopeeZujVg+3e ToU9uAPBzJkM6AeD6IYW8z04Zu6sgLLQbmWdWUrsY8XtQ3/zusDKsT5iH5dpvAH8dfV8 iYq4NfEtd/+Alc3X8XQr88ueqVE1nx2Kqs40AIsf+DDBHS3FgVww/NQAF96k8dHKOHB7 IwiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WXG1Ydui; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si5361626ply.828.2017.08.25.09.00.11; Fri, 25 Aug 2017 09:00:11 -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=@linaro.org header.s=google header.b=WXG1Ydui; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934152AbdHYQAJ (ORCPT + 26 others); Fri, 25 Aug 2017 12:00:09 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:36675 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934089AbdHYP7g (ORCPT ); Fri, 25 Aug 2017 11:59:36 -0400 Received: by mail-wr0-f169.google.com with SMTP id p14so648106wrg.3 for ; Fri, 25 Aug 2017 08:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=WXG1YduipZbX1hPmtF24+ZGSLHVusBtrMgqhd22bIJElr+2ukjLxCUD58JlvZtxa9I b0lQxknykAnuahk9WEjCYgdMkqHMqKQbMXc+kdbQYVMh+Xv2UNg9qWbBSQ/yQ+STdUQ3 DWjamFNHCvyWKy4UbQwy9vkzMskZQW78ABGN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=OFjRPLhETzTEJK6kPBceL/ExywhoxmuUYWphy1juP+Zu+D3rAPiZaErGI3V7I13jOx yZ0JS1UwEUeAItmxWsKc8+v9t+H+ERrng9u4ZnVfgzviWklqAnDvmDhLNhNjpQLHr+zP rLTrIhtZr6VX2JBDDZx7dpoFkfXKBkZs45LwMJvzUCDsC1Y+n7q+MUdBq9zap9cEE1Bp 7Ibj7CE5x0c3eXAdXCK/CZ4zL3Rzhv4YowV8HBJbycgTJ8pk6i0Ja3drWvThp0RYChy1 eSoApt7K66H977gDNZqn8i8AiBvxnMjxkqEahmGWLeAK6q3MhwJKu2YNqbEdaNht2CEX hu5Q== X-Gm-Message-State: AHYfb5jFZVdB48/NMqP3R7KntFvSZwG3PZy32ibG5WMWTp3bMhazsSl8 jP1x6Eqwoxy9obeo X-Received: by 10.223.186.132 with SMTP id p4mr6178604wrg.181.1503676775378; Fri, 25 Aug 2017 08:59:35 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:34 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Beulich , Ard Biesheuvel , linux-kernel@vger.kernel.org, Jan Beulich , Matt Fleming Subject: [PATCH 4/5] efi: move efi_mem_type() to common code Date: Fri, 25 Aug 2017 16:50:18 +0100 Message-Id: <20170825155019.6740-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich This follows efi_mem_attributes(), as it's similarly generic. Drop __weak from that one though (and don't introduce it for efi_mem_type() in the first place) to make clear that other overrides to these functions are really not intended. Signed-off-by: Jan Beulich Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/efi.c | 19 ------------------- drivers/firmware/efi/efi.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) -- 2.11.0 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f084d8718ac4..928b6dceeca0 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -1032,25 +1032,6 @@ void __init efi_enter_virtual_mode(void) efi_dump_pagetable(); } -/* - * Convenience functions to obtain memory types and attributes - */ -u32 efi_mem_type(unsigned long phys_addr) -{ - efi_memory_desc_t *md; - - if (!efi_enabled(EFI_MEMMAP)) - return 0; - - for_each_efi_memory_desc(md) { - if ((md->phys_addr <= phys_addr) && - (phys_addr < (md->phys_addr + - (md->num_pages << EFI_PAGE_SHIFT)))) - return md->type; - } - return 0; -} - static int __init arch_parse_efi_cmdline(char *str) { if (!str) { diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 9e822906adcb..f97f272e16ee 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -792,19 +792,19 @@ char * __init efi_md_typeattr_format(char *buf, size_t size, } /* + * IA64 has a funky EFI memory map that doesn't work the same way as + * other architectures. + */ +#ifndef CONFIG_IA64 +/* * efi_mem_attributes - lookup memmap attributes for physical address * @phys_addr: the physical address to lookup * * Search in the EFI memory map for the region covering * @phys_addr. Returns the EFI memory attributes if the region * was found in the memory map, 0 otherwise. - * - * Despite being marked __weak, most architectures should *not* - * override this function. It is __weak solely for the benefit - * of ia64 which has a funky EFI memory map that doesn't work - * the same way as other architectures. */ -u64 __weak efi_mem_attributes(unsigned long phys_addr) +u64 efi_mem_attributes(unsigned long phys_addr) { efi_memory_desc_t *md; @@ -820,6 +820,31 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr) return 0; } +/* + * efi_mem_type - lookup memmap type for physical address + * @phys_addr: the physical address to lookup + * + * Search in the EFI memory map for the region covering @phys_addr. + * Returns the EFI memory type if the region was found in the memory + * map, EFI_RESERVED_TYPE (zero) otherwise. + */ +u32 efi_mem_type(unsigned long phys_addr) +{ + const efi_memory_desc_t *md; + + if (!efi_enabled(EFI_MEMMAP)) + return 0; + + for_each_efi_memory_desc(md) { + if ((md->phys_addr <= phys_addr) && + (phys_addr < (md->phys_addr + + (md->num_pages << EFI_PAGE_SHIFT)))) + return md->type; + } + return EFI_RESERVED_TYPE; +} +#endif + int efi_status_to_err(efi_status_t status) { int err;