Commit ccc27ae7 authored by Ard Biesheuvel's avatar Ard Biesheuvel
Browse files

efi/libstub: Drop __pure getter for efi_system_table



The practice of using __pure getter functions to access global
variables in the EFI stub dates back to the time when we had to
carefully prevent GOT entries from being emitted, because we
could not rely on the toolchain to do this for us.

Today, we use the hidden visibility pragma for all EFI stub source
files, which now all live in the same subdirectory, and we apply a
sanity check on the objects, so we can get rid of these getter
functions and simply refer to global data objects directly.

Start with efi_system_table(), and convert it into a global variable.
While at it, make it a pointer-to-const, because we can.

Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 54439370
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -339,15 +339,17 @@ static inline u32 efi64_convert_status(efi_status_t status)

#define efi_bs_call(func, ...)						\
	(efi_is_native()						\
		? efi_system_table()->boottime->func(__VA_ARGS__)	\
		: __efi64_thunk_map(efi_table_attr(efi_system_table(),	\
				boottime), func, __VA_ARGS__))
		? efi_system_table->boottime->func(__VA_ARGS__)		\
		: __efi64_thunk_map(efi_table_attr(efi_system_table,	\
						   boottime),		\
				    func, __VA_ARGS__))

#define efi_rt_call(func, ...)						\
	(efi_is_native()						\
		? efi_system_table()->runtime->func(__VA_ARGS__)	\
		: __efi64_thunk_map(efi_table_attr(efi_system_table(),	\
				runtime), func, __VA_ARGS__))
		? efi_system_table->runtime->func(__VA_ARGS__)		\
		: __efi64_thunk_map(efi_table_attr(efi_system_table,	\
						   runtime),		\
				    func, __VA_ARGS__))

extern bool efi_reboot_required(void);
extern bool efi_is_table_address(unsigned long phys_addr);
+3 −3
Original line number Diff line number Diff line
@@ -287,8 +287,8 @@ efi_status_t efi_exit_boot_services(void *handle,

void *get_efi_config_table(efi_guid_t guid)
{
	unsigned long tables = efi_table_attr(efi_system_table(), tables);
	int nr_tables = efi_table_attr(efi_system_table(), nr_tables);
	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++) {
@@ -305,7 +305,7 @@ 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_call_proto(efi_table_attr(efi_system_table, con_out),
		       output_string, str);
}

+4 −9
Original line number Diff line number Diff line
@@ -38,12 +38,7 @@
static u64 virtmap_base = EFI_RT_VIRTUAL_BASE;
static bool flat_va_mapping;

static efi_system_table_t *sys_table;

__pure efi_system_table_t *efi_system_table(void)
{
	return sys_table;
}
const efi_system_table_t *efi_system_table;

static struct screen_info *setup_graphics(void)
{
@@ -167,10 +162,10 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
	efi_properties_table_t *prop_tbl;
	unsigned long max_addr;

	sys_table = sys_table_arg;
	efi_system_table = sys_table_arg;

	/* Check if we were booted by the EFI firmware */
	if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) {
	if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) {
		status = EFI_INVALID_PARAMETER;
		goto fail;
	}
@@ -184,7 +179,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
	 * information about the running image, such as size and the command
	 * line.
	 */
	status = sys_table->boottime->handle_protocol(handle,
	status = efi_system_table->boottime->handle_protocol(handle,
					&loaded_image_proto, (void *)&image);
	if (status != EFI_SUCCESS) {
		pr_efi_err("Failed to get loaded image protocol\n");
+3 −3
Original line number Diff line number Diff line
@@ -31,13 +31,13 @@ extern bool __pure noinitrd(void);
extern bool __pure is_quiet(void);
extern bool __pure novamap(void);

extern __pure efi_system_table_t  *efi_system_table(void);
extern const efi_system_table_t *efi_system_table;

#ifndef efi_bs_call
#define efi_bs_call(func, ...)	efi_system_table()->boottime->func(__VA_ARGS__)
#define efi_bs_call(func, ...)	efi_system_table->boottime->func(__VA_ARGS__)
#endif
#ifndef efi_rt_call
#define efi_rt_call(func, ...)	efi_system_table()->runtime->func(__VA_ARGS__)
#define efi_rt_call(func, ...)	efi_system_table->runtime->func(__VA_ARGS__)
#endif
#ifndef efi_is_native
#define efi_is_native()		(true)
+3 −3
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size,

	/* Add FDT entries for EFI runtime services in chosen node. */
	node = fdt_subnode_offset(fdt, 0, "chosen");
	fdt_val64 = cpu_to_fdt64((u64)(unsigned long)efi_system_table());
	fdt_val64 = cpu_to_fdt64((u64)(unsigned long)efi_system_table);

	status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64);
	if (status)
@@ -314,7 +314,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
			return EFI_SUCCESS;

		/* Install the new virtual address map */
		svam = efi_system_table()->runtime->set_virtual_address_map;
		svam = efi_system_table->runtime->set_virtual_address_map;
		status = svam(runtime_entry_count * desc_size, desc_size,
			      desc_ver, runtime_map);

@@ -348,7 +348,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
	efi_free(MAX_FDT_SIZE, *new_fdt_addr);

fail:
	efi_system_table()->boottime->free_pool(runtime_map);
	efi_system_table->boottime->free_pool(runtime_map);

	return EFI_LOAD_ERROR;
}
Loading