Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933316AbcKMJIf (ORCPT ); Sun, 13 Nov 2016 04:08:35 -0500 Received: from terminus.zytor.com ([198.137.202.10]:58444 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932845AbcKMJIc (ORCPT ); Sun, 13 Nov 2016 04:08:32 -0500 Date: Sun, 13 Nov 2016 01:07:49 -0800 From: tip-bot for Lukas Wunner Message-ID: Cc: andreas.noever@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org, pjones@redhat.com, peterz@infradead.org, lukas@wunner.de, hpa@zytor.com, mingo@kernel.org Reply-To: mingo@kernel.org, hpa@zytor.com, lukas@wunner.de, peterz@infradead.org, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, pjones@redhat.com, matt@codeblueprint.co.uk, tglx@linutronix.de, torvalds@linux-foundation.org, andreas.noever@gmail.com In-Reply-To: <20161112213237.8804-8-matt@codeblueprint.co.uk> References: <20161112213237.8804-8-matt@codeblueprint.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi: Allow bitness-agnostic protocol calls Git-Commit-ID: 3552fdf29f01e5a889e88202dc55b67aa6766620 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 Content-Length: 3980 Lines: 98 Commit-ID: 3552fdf29f01e5a889e88202dc55b67aa6766620 Gitweb: http://git.kernel.org/tip/3552fdf29f01e5a889e88202dc55b67aa6766620 Author: Lukas Wunner AuthorDate: Sat, 12 Nov 2016 21:32:35 +0000 Committer: Ingo Molnar CommitDate: Sun, 13 Nov 2016 08:23:16 +0100 efi: Allow bitness-agnostic protocol calls We already have a macro to invoke boot services which on x86 adapts automatically to the bitness of the EFI firmware: efi_call_early(). The macro allows sharing of functions across arches and bitness variants as long as those functions only call boot services. However in practice functions in the EFI stub contain a mix of boot services calls and protocol calls. Add an efi_call_proto() macro for bitness-agnostic protocol calls to allow sharing more code across arches as well as deduplicating 32 bit and 64 bit code paths. On x86, implement it using a new efi_table_attr() macro for bitness- agnostic table lookups. Refactor efi_call_early() to make use of the same macro. (The resulting object code remains identical.) Signed-off-by: Lukas Wunner Signed-off-by: Matt Fleming Cc: Andreas Noever Cc: Ard Biesheuvel Cc: Linus Torvalds Cc: Peter Jones Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20161112213237.8804-8-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar --- arch/arm/include/asm/efi.h | 3 +++ arch/arm64/include/asm/efi.h | 3 +++ arch/x86/include/asm/efi.h | 16 +++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 766bf9b..0b06f53 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -57,6 +57,9 @@ void efi_virtmap_unload(void); #define __efi_call_early(f, ...) f(__VA_ARGS__) #define efi_is_64bit() (false) +#define efi_call_proto(protocol, f, instance, ...) \ + ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) + struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg); void free_screen_info(efi_system_table_t *sys_table, struct screen_info *si); diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index a9e54aa..771b3f0 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -51,6 +51,9 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md); #define __efi_call_early(f, ...) f(__VA_ARGS__) #define efi_is_64bit() (true) +#define efi_call_proto(protocol, f, instance, ...) \ + ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__) + #define alloc_screen_info(x...) &screen_info #define free_screen_info(x...) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 389d700..e99675b 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -210,12 +210,18 @@ static inline bool efi_is_64bit(void) return __efi_early()->is64; } +#define efi_table_attr(table, attr, instance) \ + (efi_is_64bit() ? \ + ((table##_64_t *)(unsigned long)instance)->attr : \ + ((table##_32_t *)(unsigned long)instance)->attr) + +#define efi_call_proto(protocol, f, instance, ...) \ + __efi_early()->call(efi_table_attr(protocol, f, instance), \ + instance, ##__VA_ARGS__) + #define efi_call_early(f, ...) \ - __efi_early()->call(efi_is_64bit() ? \ - ((efi_boot_services_64_t *)(unsigned long) \ - __efi_early()->boot_services)->f : \ - ((efi_boot_services_32_t *)(unsigned long) \ - __efi_early()->boot_services)->f, __VA_ARGS__) + __efi_early()->call(efi_table_attr(efi_boot_services, f, \ + __efi_early()->boot_services), __VA_ARGS__) #define __efi_call_early(f, ...) \ __efi_early()->call((unsigned long)f, __VA_ARGS__);