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

From: Ingo Molnar
Date: Fri Apr 29 2016 - 04:31:42 EST



* tip-bot for Matt Fleming <tipbot@xxxxxxxxx> wrote:

> Commit-ID: 884f4f66ffd6ffe632f3a8be4e6d10a858afdc37
> Gitweb: http://git.kernel.org/tip/884f4f66ffd6ffe632f3a8be4e6d10a858afdc37
> Author: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx>
> AuthorDate: Mon, 25 Apr 2016 21:06:39 +0100
> Committer: Ingo Molnar <mingo@xxxxxxxxxx>
> 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@xxxxxxxxxxxxxxxxxxx>
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: Luck, Tony <tony.luck@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: linux-efi@xxxxxxxxxxxxxxx
> Link: http://lkml.kernel.org/r/1461614832-17633-8-git-send-email-matt@xxxxxxxxxxxxxxxxxxx
> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxx>
---
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. */
};