From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754711AbdHZIE2 (ORCPT ); Sat, 26 Aug 2017 04:04:28 -0400 Received: from terminus.zytor.com ([65.50.211.136]:41215 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632AbdHZIE0 (ORCPT ); Sat, 26 Aug 2017 04:04:26 -0400 Date: Sat, 26 Aug 2017 00:59:18 -0700 From: tip-bot for Jan Beulich Message-ID: Cc: matt@codeblueprint.co.uk, jbeulich@suse.com, peterz@infradead.org, ard.biesheuvel@linaro.org, JBeulich@suse.com, torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org Reply-To: JBeulich@suse.com, torvalds@linux-foundation.org, tglx@linutronix.de, jbeulich@suse.com, peterz@infradead.org, ard.biesheuvel@linaro.org, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com In-Reply-To: <20170825155019.6740-5-ard.biesheuvel@linaro.org> References: <20170825155019.6740-5-ard.biesheuvel@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi: Move efi_mem_type() to common code Git-Commit-ID: 23f0571c9fd184504f7a2f27011750e0ad99bb73 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 23f0571c9fd184504f7a2f27011750e0ad99bb73 Gitweb: http://git.kernel.org/tip/23f0571c9fd184504f7a2f27011750e0ad99bb73 Author: Jan Beulich AuthorDate: Fri, 25 Aug 2017 16:50:18 +0100 Committer: Ingo Molnar CommitDate: Sat, 26 Aug 2017 09:20:33 +0200 efi: Move efi_mem_type() to common code 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 Signed-off-by: Ard Biesheuvel Cc: Jan Beulich Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20170825155019.6740-5-ard.biesheuvel@linaro.org [ Resolved conflict with: f99afd08a45f: (efi: Update efi_mem_type() to return an error rather than 0) ] Signed-off-by: Ingo Molnar --- arch/x86/platform/efi/efi.c | 19 ------------------- drivers/firmware/efi/efi.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 6217b23..928b6dc 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 - */ -int efi_mem_type(unsigned long phys_addr) -{ - efi_memory_desc_t *md; - - if (!efi_enabled(EFI_MEMMAP)) - return -ENOTSUPP; - - 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 -EINVAL; -} - 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 c8a27a2..f70febf 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -811,19 +811,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; @@ -839,6 +839,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. + */ +int efi_mem_type(unsigned long phys_addr) +{ + const efi_memory_desc_t *md; + + if (!efi_enabled(EFI_MEMMAP)) + return -ENOTSUPP; + + 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 -EINVAL; +} +#endif + int efi_status_to_err(efi_status_t status) { int err;