Skip to content

Commit

Permalink
efi: x86: move efi_is_table_address() into arch/x86
Browse files Browse the repository at this point in the history
The function efi_is_table_address() and the associated array of table
pointers is specific to x86. Since we will be adding some more x86
specific tables, let's move this code out of the generic code first.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
  • Loading branch information
Ard Biesheuvel committed Aug 8, 2019
1 parent 5f9e832 commit e55f31a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
5 changes: 5 additions & 0 deletions arch/x86/include/asm/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,18 @@ static inline bool efi_is_64bit(void)
__efi_early()->runtime_services), __VA_ARGS__)

extern bool efi_reboot_required(void);
extern bool efi_is_table_address(unsigned long phys_addr);

#else
static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {}
static inline bool efi_reboot_required(void)
{
return false;
}
static inline bool efi_is_table_address(unsigned long phys_addr)
{
return false;
}
#endif /* CONFIG_EFI */

#endif /* _ASM_X86_EFI_H */
1 change: 1 addition & 0 deletions arch/x86/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <asm/set_memory.h>
#include <asm/e820/api.h>
#include <asm/efi.h>
#include <asm/fixmap.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
Expand Down
33 changes: 33 additions & 0 deletions arch/x86/platform/efi/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ static efi_config_table_type_t arch_tables[] __initdata = {
{NULL_GUID, NULL, NULL},
};

static const unsigned long * const efi_tables[] = {
&efi.mps,
&efi.acpi,
&efi.acpi20,
&efi.smbios,
&efi.smbios3,
&efi.sal_systab,
&efi.boot_info,
&efi.hcdp,
&efi.uga,
&efi.uv_systab,
&efi.fw_vendor,
&efi.runtime,
&efi.config_table,
&efi.esrt,
&efi.properties_table,
&efi.mem_attr_table,
};

u64 efi_setup; /* efi setup_data physical address */

static int add_efi_memmap __initdata;
Expand Down Expand Up @@ -1049,3 +1068,17 @@ static int __init arch_parse_efi_cmdline(char *str)
return 0;
}
early_param("efi", arch_parse_efi_cmdline);

bool efi_is_table_address(unsigned long phys_addr)
{
unsigned int i;

if (phys_addr == EFI_INVALID_TABLE_ADDR)
return false;

for (i = 0; i < ARRAY_SIZE(efi_tables); i++)
if (*(efi_tables[i]) == phys_addr)
return true;

return false;
}
33 changes: 0 additions & 33 deletions drivers/firmware/efi/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,6 @@ struct efi __read_mostly efi = {
};
EXPORT_SYMBOL(efi);

static unsigned long *efi_tables[] = {
&efi.mps,
&efi.acpi,
&efi.acpi20,
&efi.smbios,
&efi.smbios3,
&efi.sal_systab,
&efi.boot_info,
&efi.hcdp,
&efi.uga,
&efi.uv_systab,
&efi.fw_vendor,
&efi.runtime,
&efi.config_table,
&efi.esrt,
&efi.properties_table,
&efi.mem_attr_table,
};

struct mm_struct efi_mm = {
.mm_rb = RB_ROOT,
.mm_users = ATOMIC_INIT(2),
Expand Down Expand Up @@ -964,20 +945,6 @@ int efi_status_to_err(efi_status_t status)
return err;
}

bool efi_is_table_address(unsigned long phys_addr)
{
unsigned int i;

if (phys_addr == EFI_INVALID_TABLE_ADDR)
return false;

for (i = 0; i < ARRAY_SIZE(efi_tables); i++)
if (*(efi_tables[i]) == phys_addr)
return true;

return false;
}

static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock);
static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init;

Expand Down
7 changes: 0 additions & 7 deletions include/linux/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,6 @@ static inline bool efi_enabled(int feature)
return test_bit(feature, &efi.flags) != 0;
}
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);

extern bool efi_is_table_address(unsigned long phys_addr);
#else
static inline bool efi_enabled(int feature)
{
Expand All @@ -1226,11 +1224,6 @@ efi_capsule_pending(int *reset_type)
{
return false;
}

static inline bool efi_is_table_address(unsigned long phys_addr)
{
return false;
}
#endif

extern int efi_status_to_err(efi_status_t status);
Expand Down

0 comments on commit e55f31a

Please sign in to comment.