[PATCH] efi: Remove unnecessary (and buggy) .memmap initialization from the Xen EFI driver

Ingo Molnar
2016-04-29T08:31:37Z

* tip-bot for Matt Fleming <tipbot@zytor.com> wrote:

> Commit-ID: 884f4f66ffd6ffe632f3a8be4e6d10a858afdc37
> Gitweb: http://git.kernel.org/tip/884f4f66ffd6ffe632f3a8be4e6d10a858afdc37
> Author: Matt Fleming <matt@codeblueprint.co.uk>
> AuthorDate: Mon, 25 Apr 2016 21:06:39 +0100
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitDate: Thu, 28 Apr 2016 11:33:51 +0200
>
> efi: Remove global 'memmap' EFI memory map
>
> Abolish the poorly named EFI memory map, 'memmap'. It is shadowed by a
> bunch of local definitions in various files and having two ways to
> access the EFI memory map ('efi.memmap' vs. 'memmap') is rather
> confusing.
>
> Furthermore, IA64 doesn't even provide this global object, which has
> caused issues when trying to write generic EFI memmap code.
>
> Replace all occurrences with efi.memmap, and convert the remaining
> iterator code to use for_each_efi_mem_desc().
>
> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Luck, Tony <tony.luck@intel.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-efi@vger.kernel.org
> Link: http://lkml.kernel.org/r/1461614832-17633-8-git-send-email-matt@codeblueprint.co.uk
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
> arch/x86/platform/efi/efi.c | 84 +++++++++++++++++++++-----------------
> drivers/firmware/efi/arm-init.c | 20 ++++-----
> drivers/firmware/efi/arm-runtime.c | 12 +++---
> drivers/firmware/efi/efi.c | 2 +-
> drivers/firmware/efi/fake_mem.c | 40 +++++++++---------
> include/linux/efi.h | 5 +--
> 6 files changed, 85 insertions(+), 78 deletions(-)

So this commit triggered the follwing build warning on x86 64-bit allyesconfig:

In file included from ./include/uapi/linux/posix_types.h:4:0,
from include/uapi/linux/types.h:13,
from include/linux/compiler.h:203,
from include/asm-generic/bug.h:4,
from ./arch/x86/include/asm/bug.h:35,
from include/linux/bug.h:4,
from drivers/xen/efi.c:21:
include/linux/stddef.h:7:14: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
#define NULL ((void *)0)
^
drivers/xen/efi.c:319:30: note: in expansion of macro ‘NULL’
.memmap = NULL, /* Not used under Xen. */
^
CC drivers/gpu/drm/i915/intel_acpi.o
include/linux/stddef.h:7:14: note: (near initialization for ‘efi_xen.memmap.phys_map’)
#define NULL ((void *)0)
^
drivers/xen/efi.c:319:30: note: in expansion of macro ‘NULL’
.memmap = NULL, /* Not used under Xen. */
^
drivers/xen/efi.c:290:47: warning: missing braces around initializer [-Wmissing-braces]
static const struct efi efi_xen __initconst = {
^
drivers/xen/efi.c:290:47: note: (near initialization for ‘efi_xen’)

It's this initialization in drivers/xen/efi.c:

static const struct efi efi_xen __initconst = {
...
.memmap = NULL, /* Not used under Xen. */
...

which was forgotten about, as .memmap now is an embedded struct:

struct efi_memory_map memmap;

We can remove this initialization - it's an EFI core internal data structure plus
it's not used in the Xen driver anyway.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
drivers/xen/efi.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index be7e56a338e8..e9d2135445c1 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -316,7 +316,6 @@ static const struct efi efi_xen __initconst = {
.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
.reset_system = NULL, /* Functionality provided by Xen. */
.set_virtual_address_map = NULL, /* Not used under Xen. */
- .memmap = NULL, /* Not used under Xen. */
.flags = 0 /* Initialized later. */
};