efi/libstub: Drop 'table' argument from efi_table_attr() macro
authorArd Biesheuvel <ardb@kernel.org>
Tue, 24 Dec 2019 15:10:22 +0000 (16:10 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 25 Dec 2019 09:49:24 +0000 (10:49 +0100)
None of the definitions of the efi_table_attr() still refer to
their 'table' argument so let's get rid of it entirely.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>
Cc: James Morse <james.morse@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224151025.32482-23-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/arm/include/asm/efi.h
arch/arm64/include/asm/efi.h
arch/x86/boot/compressed/eboot.c
arch/x86/include/asm/efi.h
drivers/firmware/efi/libstub/efi-stub-helper.c
drivers/firmware/efi/libstub/gop.c

index bdc5288cc643fd028e2d532e307d7b8cf3880c3f..bc720024a2603f2579d544cd7c7adef74ac61d68 100644 (file)
@@ -54,8 +54,7 @@ void efi_virtmap_unload(void);
 #define efi_call_runtime(f, ...)       efi_system_table()->runtime->f(__VA_ARGS__)
 #define efi_is_native()                        (true)
 
-#define efi_table_attr(table, attr, instance)                          \
-       instance->attr
+#define efi_table_attr(inst, attr)     (inst->attr)
 
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
index 4bc1e89671abb2b6e3b5d8c5c2aed1d7ac0b419e..6f041ae446d2c6ab7bab1b5404d9597b1db21da8 100644 (file)
@@ -97,8 +97,7 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
 #define efi_call_runtime(f, ...)       efi_system_table()->runtime->f(__VA_ARGS__)
 #define efi_is_native()                        (true)
 
-#define efi_table_attr(table, attr, instance)                          \
-       instance->attr
+#define efi_table_attr(inst, attr)     (inst->attr)
 
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
index 751fd5fc3367b58821e44997e1c82dc49f4cb8a4..cccd9e16b3292ae8d91367dc84594333c5aed0b7 100644 (file)
@@ -47,8 +47,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
         * large romsize. The UEFI spec limits the size of option ROMs to 16
         * MiB so we reject any ROMs over 16 MiB in size to catch this.
         */
-       romimage = efi_table_attr(efi_pci_io_protocol, romimage, pci);
-       romsize = efi_table_attr(efi_pci_io_protocol, romsize, pci);
+       romimage = efi_table_attr(pci, romimage);
+       romsize = efi_table_attr(pci, romsize);
        if (!romimage || !romsize || romsize > SZ_16M)
                return EFI_INVALID_PARAMETER;
 
@@ -183,7 +183,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
        if (status != EFI_SUCCESS)
                return;
 
-       if (efi_table_attr(apple_properties_protocol, version, p) != 0x10000) {
+       if (efi_table_attr(p, version) != 0x10000) {
                efi_printk("Unsupported properties proto version\n");
                return;
        }
@@ -226,7 +226,7 @@ static const efi_char16_t apple[] = L"Apple";
 static void setup_quirks(struct boot_params *boot_params)
 {
        efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long)
-               efi_table_attr(efi_system_table, fw_vendor, sys_table);
+               efi_table_attr(efi_system_table(), fw_vendor);
 
        if (!memcmp(fw_vendor, apple, sizeof(apple))) {
                if (IS_ENABLED(CONFIG_APPLE_PROPERTIES))
index b7cd14e3a6349a8031b3642c05684141dbcca306..39814a0a92f7f82e0a4aa1ce1533572be679fea9 100644 (file)
@@ -216,16 +216,11 @@ static inline bool efi_is_native(void)
                __builtin_types_compatible_p(u32, __typeof__(attr)),    \
                        (unsigned long)(attr), (attr))
 
-#define efi_table_attr(table, attr, instance) ({                       \
-       __typeof__(instance->attr) __ret;                               \
-       if (efi_is_native()) {                                          \
-               __ret = instance->attr;                                 \
-       } else {                                                        \
-               __ret = (__typeof__(__ret))                             \
-                       efi_mixed_mode_cast(instance->mixed_mode.attr); \
-       }                                                               \
-       __ret;                                                          \
-})
+#define efi_table_attr(inst, attr)                                     \
+       (efi_is_native()                                                \
+               ? inst->attr                                            \
+               : (__typeof__(inst->attr))                              \
+                       efi_mixed_mode_cast(inst->mixed_mode.attr))
 
 #define efi_call_proto(inst, func, ...)                                        \
        (efi_is_native()                                                \
@@ -235,16 +230,14 @@ static inline bool efi_is_native(void)
 #define efi_call_early(f, ...)                                         \
        (efi_is_native()                                                \
                ? efi_system_table()->boottime->f(__VA_ARGS__)          \
-               : efi64_thunk(efi_table_attr(efi_boot_services,         \
-                       boottime, efi_system_table())->mixed_mode.f,    \
-                       __VA_ARGS__))
+               : efi64_thunk(efi_table_attr(efi_system_table(),        \
+                               boottime)->mixed_mode.f, __VA_ARGS__))
 
 #define efi_call_runtime(f, ...)                                       \
        (efi_is_native()                                                \
                ? efi_system_table()->runtime->f(__VA_ARGS__)           \
-               : efi64_thunk(efi_table_attr(efi_runtime_services,      \
-                       runtime, efi_system_table())->mixed_mode.f,     \
-                       __VA_ARGS__))
+               : efi64_thunk(efi_table_attr(efi_system_table(),        \
+                               runtime)->mixed_mode.f, __VA_ARGS__))
 
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
index 48eab7b9d0666d1aaf6f5f574a54d13f08c6729d..8754ec04788b8b1d70220c939a3153c8b053f2c6 100644 (file)
@@ -933,17 +933,15 @@ fail:
 
 void *get_efi_config_table(efi_guid_t guid)
 {
-       unsigned long tables = efi_table_attr(efi_system_table, tables,
-                                             efi_system_table());
-       int nr_tables = efi_table_attr(efi_system_table, nr_tables,
-                                      efi_system_table());
+       unsigned long tables = efi_table_attr(efi_system_table(), tables);
+       int nr_tables = efi_table_attr(efi_system_table(), nr_tables);
        int i;
 
        for (i = 0; i < nr_tables; i++) {
                efi_config_table_t *t = (void *)tables;
 
                if (efi_guidcmp(t->guid, guid) == 0)
-                       return efi_table_attr(efi_config_table, table, t);
+                       return efi_table_attr(t, table);
 
                tables += efi_is_native() ? sizeof(efi_config_table_t)
                                          : sizeof(efi_config_table_32_t);
@@ -953,7 +951,6 @@ void *get_efi_config_table(efi_guid_t guid)
 
 void efi_char16_printk(efi_char16_t *str)
 {
-       efi_call_proto(efi_table_attr(efi_system_table, con_out,
-                                     efi_system_table()),
+       efi_call_proto(efi_table_attr(efi_system_table(), con_out),
                       output_string, str);
 }
index c3afe8d4a68888e539a1610f9de57a427933ed29..8f746282c2191717d6b7ce970532ec8871229351 100644 (file)
@@ -85,9 +85,6 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
        }
 }
 
-#define efi_gop_attr(table, attr, instance) \
-       (efi_table_attr(efi_graphics_output_protocol##table, attr, instance))
-
 static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
                              unsigned long size, void **handles)
 {
@@ -123,9 +120,9 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
                if (status == EFI_SUCCESS)
                        conout_found = true;
 
-               mode = (void *)(unsigned long)efi_gop_attr(, mode, gop);
-               info = (void *)(unsigned long)efi_gop_attr(_mode, info, mode);
-               current_fb_base = efi_gop_attr(_mode, frame_buffer_base, mode);
+               mode = efi_table_attr(gop, mode);
+               info = efi_table_attr(mode, info);
+               current_fb_base = efi_table_attr(mode, frame_buffer_base);
 
                if ((!first_gop || conout_found) &&
                    info->pixel_format != PIXEL_BLT_ONLY) {