Commit 9cd437ac authored by Ard Biesheuvel's avatar Ard Biesheuvel
Browse files

efi/x86: Make fw_vendor, config_table and runtime sysfs nodes x86 specific



There is some code that exposes physical addresses of certain parts of
the EFI firmware implementation via sysfs nodes. These nodes are only
used on x86, and are of dubious value to begin with, so let's move
their handling into the x86 arch code.

Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 0a67361d
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,8 @@
#include <asm/mmu_context.h>
#include <asm/mmu_context.h>
#include <linux/build_bug.h>
#include <linux/build_bug.h>


extern unsigned long efi_fw_vendor, efi_config_table;

/*
/*
 * We map the EFI regions needed for runtime services non-contiguously,
 * We map the EFI regions needed for runtime services non-contiguously,
 * with preserved alignment on virtual addresses starting from -4G down
 * with preserved alignment on virtual addresses starting from -4G down
+2 −2
Original line number Original line Diff line number Diff line
@@ -141,8 +141,8 @@ prepare_add_efi_setup_data(struct boot_params *params,
	struct setup_data *sd = (void *)params + efi_setup_data_offset;
	struct setup_data *sd = (void *)params + efi_setup_data_offset;
	struct efi_setup_data *esd = (void *)sd + sizeof(struct setup_data);
	struct efi_setup_data *esd = (void *)sd + sizeof(struct setup_data);


	esd->fw_vendor = efi.fw_vendor;
	esd->fw_vendor = efi_fw_vendor;
	esd->tables = efi.config_table;
	esd->tables = efi_config_table;
	esd->smbios = efi.smbios;
	esd->smbios = efi.smbios;


	sd->type = SETUP_EFI;
	sd->type = SETUP_EFI;
+48 −12
Original line number Original line Diff line number Diff line
@@ -59,6 +59,9 @@ static u64 efi_systab_phys __initdata;


static unsigned long prop_phys = EFI_INVALID_TABLE_ADDR;
static unsigned long prop_phys = EFI_INVALID_TABLE_ADDR;
static unsigned long uga_phys = EFI_INVALID_TABLE_ADDR;
static unsigned long uga_phys = EFI_INVALID_TABLE_ADDR;
static unsigned long efi_runtime, efi_nr_tables;

unsigned long efi_fw_vendor, efi_config_table;


static const efi_config_table_type_t arch_tables[] __initconst = {
static const efi_config_table_type_t arch_tables[] __initconst = {
	{EFI_PROPERTIES_TABLE_GUID, "PROP", &prop_phys},
	{EFI_PROPERTIES_TABLE_GUID, "PROP", &prop_phys},
@@ -78,9 +81,9 @@ static const unsigned long * const efi_tables[] = {
#ifdef CONFIG_X86_UV
#ifdef CONFIG_X86_UV
	&uv_systab_phys,
	&uv_systab_phys,
#endif
#endif
	&efi.fw_vendor,
	&efi_fw_vendor,
	&efi.runtime,
	&efi_runtime,
	&efi.config_table,
	&efi_config_table,
	&efi.esrt,
	&efi.esrt,
	&prop_phys,
	&prop_phys,
	&efi_mem_attr_table,
	&efi_mem_attr_table,
@@ -434,7 +437,7 @@ static int __init efi_config_init(const efi_config_table_type_t *arch_tables)
	void *config_tables;
	void *config_tables;
	int sz, ret;
	int sz, ret;


	if (efi.systab->nr_tables == 0)
	if (efi_nr_tables == 0)
		return 0;
		return 0;


	if (efi_enabled(EFI_64BIT))
	if (efi_enabled(EFI_64BIT))
@@ -445,17 +448,16 @@ static int __init efi_config_init(const efi_config_table_type_t *arch_tables)
	/*
	/*
	 * Let's see what config tables the firmware passed to us.
	 * Let's see what config tables the firmware passed to us.
	 */
	 */
	config_tables = early_memremap(efi.systab->tables,
	config_tables = early_memremap(efi_config_table, efi_nr_tables * sz);
				       efi.systab->nr_tables * sz);
	if (config_tables == NULL) {
	if (config_tables == NULL) {
		pr_err("Could not map Configuration table!\n");
		pr_err("Could not map Configuration table!\n");
		return -ENOMEM;
		return -ENOMEM;
	}
	}


	ret = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
	ret = efi_config_parse_tables(config_tables, efi_nr_tables,
				      arch_tables);
				      arch_tables);


	early_memunmap(config_tables, efi.systab->nr_tables * sz);
	early_memunmap(config_tables, efi_nr_tables * sz);
	return ret;
	return ret;
}
}


@@ -474,11 +476,12 @@ void __init efi_init(void)
	if (efi_systab_init(efi_systab_phys))
	if (efi_systab_init(efi_systab_phys))
		return;
		return;


	efi.config_table = (unsigned long)efi.systab->tables;
	efi_config_table = (unsigned long)efi.systab->tables;
	efi.fw_vendor	 = (unsigned long)efi.systab->fw_vendor;
	efi_nr_tables    = efi.systab->nr_tables;
	efi.runtime	 = (unsigned long)efi.systab->runtime;
	efi_fw_vendor    = (unsigned long)efi.systab->fw_vendor;
	efi_runtime      = (unsigned long)efi.systab->runtime;


	if (efi_reuse_config(efi.systab->tables, efi.systab->nr_tables))
	if (efi_reuse_config(efi_config_table, efi_nr_tables))
		return;
		return;


	if (efi_config_init(arch_tables))
	if (efi_config_init(arch_tables))
@@ -1023,3 +1026,36 @@ char *efi_systab_show_arch(char *str)
		str += sprintf(str, "UGA=0x%lx\n", uga_phys);
		str += sprintf(str, "UGA=0x%lx\n", uga_phys);
	return str;
	return str;
}
}

#define EFI_FIELD(var) efi_ ## var

#define EFI_ATTR_SHOW(name) \
static ssize_t name##_show(struct kobject *kobj, \
				struct kobj_attribute *attr, char *buf) \
{ \
	return sprintf(buf, "0x%lx\n", EFI_FIELD(name)); \
}

EFI_ATTR_SHOW(fw_vendor);
EFI_ATTR_SHOW(runtime);
EFI_ATTR_SHOW(config_table);

struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);

umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{
	if (attr == &efi_attr_fw_vendor.attr) {
		if (efi_enabled(EFI_PARAVIRT) ||
				efi_fw_vendor == EFI_INVALID_TABLE_ADDR)
			return 0;
	} else if (attr == &efi_attr_runtime.attr) {
		if (efi_runtime == EFI_INVALID_TABLE_ADDR)
			return 0;
	} else if (attr == &efi_attr_config_table.attr) {
		if (efi_config_table == EFI_INVALID_TABLE_ADDR)
			return 0;
	}
	return attr->mode;
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -537,7 +537,7 @@ int __init efi_reuse_config(u64 tables, int nr_tables)
		goto out_memremap;
		goto out_memremap;
	}
	}


	for (i = 0; i < efi.systab->nr_tables; i++) {
	for (i = 0; i < nr_tables; i++) {
		efi_guid_t guid;
		efi_guid_t guid;


		guid = ((efi_config_table_64_t *)p)->guid;
		guid = ((efi_config_table_64_t *)p)->guid;
+0 −3
Original line number Original line Diff line number Diff line
@@ -120,9 +120,6 @@ static int __init uefi_init(void)
	retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
	retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
					 arch_tables);
					 arch_tables);


	if (!retval)
		efi.config_table = (unsigned long)efi.systab->tables;

	early_memunmap(config_tables, table_size);
	early_memunmap(config_tables, table_size);
out:
out:
	early_memunmap(efi.systab,  sizeof(efi_system_table_t));
	early_memunmap(efi.systab,  sizeof(efi_system_table_t));
Loading