Skip to content

Commit e42bebf

Browse files
committed
Merge tag 'efi-fixes-for-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: - Missing x86 patch for the runtime cleanup that was merged in -rc1 - Kconfig tweak for kexec on x86 so EFI support does not get disabled inadvertently - Use the right EFI memory type for the unaccepted memory table so kexec/kdump exposes it to the crash kernel as well - Work around EFI implementations which do not implement QueryVariableInfo, which is now called by statfs() on efivarfs * tag 'efi-fixes-for-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efivarfs: fix statfs() on efivarfs efi/unaccepted: Use ACPI reclaim memory for unaccepted memory table efi/x86: Ensure that EFI_RUNTIME_MAP is enabled for kexec efi/x86: Move EFI runtime call setup/teardown helpers out of line
2 parents 02e768c + 79b8360 commit e42bebf

File tree

6 files changed

+43
-38
lines changed

6 files changed

+43
-38
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,7 @@ config EFI
19451945
select UCS2_STRING
19461946
select EFI_RUNTIME_WRAPPERS
19471947
select ARCH_USE_MEMREMAP_PROT
1948+
select EFI_RUNTIME_MAP if KEXEC_CORE
19481949
help
19491950
This enables the kernel to use EFI runtime services that are
19501951
available (such as the EFI variable services).
@@ -2020,7 +2021,6 @@ config EFI_MAX_FAKE_MEM
20202021
config EFI_RUNTIME_MAP
20212022
bool "Export EFI runtime maps to sysfs" if EXPERT
20222023
depends on EFI
2023-
default KEXEC_CORE
20242024
help
20252025
Export EFI runtime memory regions to /sys/firmware/efi/runtime-map.
20262026
That memory map is required by the 2nd kernel to set up EFI virtual

arch/x86/include/asm/efi.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,6 @@ static inline void efi_fpu_end(void)
9191

9292
#ifdef CONFIG_X86_32
9393
#define EFI_X86_KERNEL_ALLOC_LIMIT (SZ_512M - 1)
94-
95-
#define arch_efi_call_virt_setup() \
96-
({ \
97-
efi_fpu_begin(); \
98-
firmware_restrict_branch_speculation_start(); \
99-
})
100-
101-
#define arch_efi_call_virt_teardown() \
102-
({ \
103-
firmware_restrict_branch_speculation_end(); \
104-
efi_fpu_end(); \
105-
})
106-
10794
#else /* !CONFIG_X86_32 */
10895
#define EFI_X86_KERNEL_ALLOC_LIMIT EFI_ALLOC_LIMIT
10996

@@ -116,14 +103,6 @@ extern bool efi_disable_ibt_for_runtime;
116103
__efi_call(__VA_ARGS__); \
117104
})
118105

119-
#define arch_efi_call_virt_setup() \
120-
({ \
121-
efi_sync_low_kernel_mappings(); \
122-
efi_fpu_begin(); \
123-
firmware_restrict_branch_speculation_start(); \
124-
efi_enter_mm(); \
125-
})
126-
127106
#undef arch_efi_call_virt
128107
#define arch_efi_call_virt(p, f, args...) ({ \
129108
u64 ret, ibt = ibt_save(efi_disable_ibt_for_runtime); \
@@ -132,13 +111,6 @@ extern bool efi_disable_ibt_for_runtime;
132111
ret; \
133112
})
134113

135-
#define arch_efi_call_virt_teardown() \
136-
({ \
137-
efi_leave_mm(); \
138-
firmware_restrict_branch_speculation_end(); \
139-
efi_fpu_end(); \
140-
})
141-
142114
#ifdef CONFIG_KASAN
143115
/*
144116
* CONFIG_KASAN may redefine memset to __memset. __memset function is present
@@ -168,8 +140,8 @@ extern void efi_delete_dummy_variable(void);
168140
extern void efi_crash_gracefully_on_page_fault(unsigned long phys_addr);
169141
extern void efi_free_boot_services(void);
170142

171-
void efi_enter_mm(void);
172-
void efi_leave_mm(void);
143+
void arch_efi_call_virt_setup(void);
144+
void arch_efi_call_virt_teardown(void);
173145

174146
/* kexec external ABI */
175147
struct efi_setup_data {

arch/x86/platform/efi/efi_32.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,15 @@ void __init efi_runtime_update_mappings(void)
140140
}
141141
}
142142
}
143+
144+
void arch_efi_call_virt_setup(void)
145+
{
146+
efi_fpu_begin();
147+
firmware_restrict_branch_speculation_start();
148+
}
149+
150+
void arch_efi_call_virt_teardown(void)
151+
{
152+
firmware_restrict_branch_speculation_end();
153+
efi_fpu_end();
154+
}

arch/x86/platform/efi/efi_64.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,34 @@ void __init efi_dump_pagetable(void)
474474
* can not change under us.
475475
* It should be ensured that there are no concurrent calls to this function.
476476
*/
477-
void efi_enter_mm(void)
477+
static void efi_enter_mm(void)
478478
{
479479
efi_prev_mm = current->active_mm;
480480
current->active_mm = &efi_mm;
481481
switch_mm(efi_prev_mm, &efi_mm, NULL);
482482
}
483483

484-
void efi_leave_mm(void)
484+
static void efi_leave_mm(void)
485485
{
486486
current->active_mm = efi_prev_mm;
487487
switch_mm(&efi_mm, efi_prev_mm, NULL);
488488
}
489489

490+
void arch_efi_call_virt_setup(void)
491+
{
492+
efi_sync_low_kernel_mappings();
493+
efi_fpu_begin();
494+
firmware_restrict_branch_speculation_start();
495+
efi_enter_mm();
496+
}
497+
498+
void arch_efi_call_virt_teardown(void)
499+
{
500+
efi_leave_mm();
501+
firmware_restrict_branch_speculation_end();
502+
efi_fpu_end();
503+
}
504+
490505
static DEFINE_SPINLOCK(efi_runtime_lock);
491506

492507
/*

drivers/firmware/efi/libstub/unaccepted_memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc,
6262
bitmap_size = DIV_ROUND_UP(unaccepted_end - unaccepted_start,
6363
EFI_UNACCEPTED_UNIT_SIZE * BITS_PER_BYTE);
6464

65-
status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
65+
status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
6666
sizeof(*unaccepted_table) + bitmap_size,
6767
(void **)&unaccepted_table);
6868
if (status != EFI_SUCCESS) {

fs/efivarfs/super.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ static int efivarfs_statfs(struct dentry *dentry, struct kstatfs *buf)
3232
u64 storage_space, remaining_space, max_variable_size;
3333
efi_status_t status;
3434

35-
status = efivar_query_variable_info(attr, &storage_space, &remaining_space,
36-
&max_variable_size);
37-
if (status != EFI_SUCCESS)
38-
return efi_status_to_err(status);
35+
/* Some UEFI firmware does not implement QueryVariableInfo() */
36+
storage_space = remaining_space = 0;
37+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
38+
status = efivar_query_variable_info(attr, &storage_space,
39+
&remaining_space,
40+
&max_variable_size);
41+
if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED)
42+
pr_warn_ratelimited("query_variable_info() failed: 0x%lx\n",
43+
status);
44+
}
3945

4046
/*
4147
* This is not a normal filesystem, so no point in pretending it has a block

0 commit comments

Comments
 (0)