Skip to content

Commit de956b8

Browse files
committed
Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull EFI updates from Ingo Molnar: "Main changes in this cycle were: - Refactor the EFI memory map code into architecture neutral files and allow drivers to permanently reserve EFI boot services regions on x86, as well as ARM/arm64. (Matt Fleming) - Add ARM support for the EFI ESRT driver. (Ard Biesheuvel) - Make the EFI runtime services and efivar API interruptible by swapping spinlocks for semaphores. (Sylvain Chouleur) - Provide the EFI identity mapping for kexec which allows kexec to work on SGI/UV platforms with requiring the "noefi" kernel command line parameter. (Alex Thorlton) - Add debugfs node to dump EFI page tables on arm64. (Ard Biesheuvel) - Merge the EFI test driver being carried out of tree until now in the FWTS project. (Ivan Hu) - Expand the list of flags for classifying EFI regions as "RAM" on arm64 so we align with the UEFI spec. (Ard Biesheuvel) - Optimise out the EFI mixed mode if it's unsupported (CONFIG_X86_32) or disabled (CONFIG_EFI_MIXED=n) and switch the early EFI boot services function table for direct calls, alleviating us from having to maintain the custom function table. (Lukas Wunner) - Miscellaneous cleanups and fixes" * 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (30 commits) x86/efi: Round EFI memmap reservations to EFI_PAGE_SIZE x86/efi: Allow invocation of arbitrary boot services x86/efi: Optimize away setup_gop32/64 if unused x86/efi: Use kmalloc_array() in efi_call_phys_prolog() efi/arm64: Treat regions with WT/WC set but WB cleared as memory efi: Add efi_test driver for exporting UEFI runtime service interfaces x86/efi: Defer efi_esrt_init until after memblock_x86_fill efi/arm64: Add debugfs node to dump UEFI runtime page tables x86/efi: Remove unused find_bits() function fs/efivarfs: Fix double kfree() in error path x86/efi: Map in physical addresses in efi_map_region_fixed lib/ucs2_string: Speed up ucs2_utf8size() firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy" x86/efi: Initialize status to ensure garbage is not returned on small size efi: Replace runtime services spinlock with semaphore efi: Don't use spinlocks for efi vars efi: Use a file local lock for efivars efi/arm*: esrt: Add missing call to efi_esrt_init() efi/esrt: Use memremap not ioremap to access ESRT table in memory x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data ...
2 parents d7a0dab + 2ab78a7 commit de956b8

31 files changed

Lines changed: 1782 additions & 547 deletions

File tree

‎MAINTAINERS‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,6 +4587,13 @@ M: Peter Jones <pjones@redhat.com>
45874587
S: Maintained
45884588
F: drivers/video/fbdev/efifb.c
45894589

4590+
EFI TEST DRIVER
4591+
L: linux-efi@vger.kernel.org
4592+
M: Ivan Hu <ivan.hu@canonical.com>
4593+
M: Matt Fleming <matt@codeblueprint.co.uk>
4594+
S: Maintained
4595+
F: drivers/firmware/efi/test/
4596+
45904597
EFS FILESYSTEM
45914598
W: http://aeschi.ch.eu.org/efs/
45924599
S: Orphan

‎arch/x86/boot/compressed/eboot.c‎

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,11 @@ __pure const struct efi_config *__efi_early(void)
2929
static void setup_boot_services##bits(struct efi_config *c) \
3030
{ \
3131
efi_system_table_##bits##_t *table; \
32-
efi_boot_services_##bits##_t *bt; \
3332
\
3433
table = (typeof(table))sys_table; \
3534
\
35+
c->boot_services = table->boottime; \
3636
c->text_output = table->con_out; \
37-
\
38-
bt = (typeof(bt))(unsigned long)(table->boottime); \
39-
\
40-
c->allocate_pool = bt->allocate_pool; \
41-
c->allocate_pages = bt->allocate_pages; \
42-
c->get_memory_map = bt->get_memory_map; \
43-
c->free_pool = bt->free_pool; \
44-
c->free_pages = bt->free_pages; \
45-
c->locate_handle = bt->locate_handle; \
46-
c->handle_protocol = bt->handle_protocol; \
47-
c->exit_boot_services = bt->exit_boot_services; \
4837
}
4938
BOOT_SERVICES(32);
5039
BOOT_SERVICES(64);
@@ -286,29 +275,6 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str)
286275
}
287276
}
288277

289-
static void find_bits(unsigned long mask, u8 *pos, u8 *size)
290-
{
291-
u8 first, len;
292-
293-
first = 0;
294-
len = 0;
295-
296-
if (mask) {
297-
while (!(mask & 0x1)) {
298-
mask = mask >> 1;
299-
first++;
300-
}
301-
302-
while (mask & 0x1) {
303-
mask = mask >> 1;
304-
len++;
305-
}
306-
}
307-
308-
*pos = first;
309-
*size = len;
310-
}
311-
312278
static efi_status_t
313279
__setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom)
314280
{
@@ -578,7 +544,7 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
578544
efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
579545
unsigned long nr_ugas;
580546
u32 *handles = (u32 *)uga_handle;;
581-
efi_status_t status;
547+
efi_status_t status = EFI_INVALID_PARAMETER;
582548
int i;
583549

584550
first_uga = NULL;
@@ -623,7 +589,7 @@ setup_uga64(void **uga_handle, unsigned long size, u32 *width, u32 *height)
623589
efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
624590
unsigned long nr_ugas;
625591
u64 *handles = (u64 *)uga_handle;;
626-
efi_status_t status;
592+
efi_status_t status = EFI_INVALID_PARAMETER;
627593
int i;
628594

629595
first_uga = NULL;

‎arch/x86/boot/compressed/head_32.S‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ENTRY(efi_pe_entry)
8282

8383
/* Relocate efi_config->call() */
8484
leal efi32_config(%esi), %eax
85-
add %esi, 88(%eax)
85+
add %esi, 32(%eax)
8686
pushl %eax
8787

8888
call make_boot_params
@@ -108,7 +108,7 @@ ENTRY(efi32_stub_entry)
108108

109109
/* Relocate efi_config->call() */
110110
leal efi32_config(%esi), %eax
111-
add %esi, 88(%eax)
111+
add %esi, 32(%eax)
112112
pushl %eax
113113
2:
114114
call efi_main
@@ -264,7 +264,7 @@ relocated:
264264
#ifdef CONFIG_EFI_STUB
265265
.data
266266
efi32_config:
267-
.fill 11,8,0
267+
.fill 4,8,0
268268
.long efi_call_phys
269269
.long 0
270270
.byte 0

‎arch/x86/boot/compressed/head_64.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ ENTRY(efi_pe_entry)
265265
/*
266266
* Relocate efi_config->call().
267267
*/
268-
addq %rbp, efi64_config+88(%rip)
268+
addq %rbp, efi64_config+32(%rip)
269269

270270
movq %rax, %rdi
271271
call make_boot_params
@@ -285,7 +285,7 @@ handover_entry:
285285
* Relocate efi_config->call().
286286
*/
287287
movq efi_config(%rip), %rax
288-
addq %rbp, 88(%rax)
288+
addq %rbp, 32(%rax)
289289
2:
290290
movq efi_config(%rip), %rdi
291291
call efi_main
@@ -457,14 +457,14 @@ efi_config:
457457
#ifdef CONFIG_EFI_MIXED
458458
.global efi32_config
459459
efi32_config:
460-
.fill 11,8,0
460+
.fill 4,8,0
461461
.quad efi64_thunk
462462
.byte 0
463463
#endif
464464

465465
.global efi64_config
466466
efi64_config:
467-
.fill 11,8,0
467+
.fill 4,8,0
468468
.quad efi_call
469469
.byte 1
470470
#endif /* CONFIG_EFI_STUB */

‎arch/x86/include/asm/efi.h‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ extern int __init efi_memblock_x86_reserve_range(void);
117117
extern pgd_t * __init efi_call_phys_prolog(void);
118118
extern void __init efi_call_phys_epilog(pgd_t *save_pgd);
119119
extern void __init efi_print_memmap(void);
120-
extern void __init efi_unmap_memmap(void);
121120
extern void __init efi_memory_uc(u64 addr, unsigned long size);
122121
extern void __init efi_map_region(efi_memory_desc_t *md);
123122
extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
@@ -192,29 +191,35 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(
192191
struct efi_config {
193192
u64 image_handle;
194193
u64 table;
195-
u64 allocate_pool;
196-
u64 allocate_pages;
197-
u64 get_memory_map;
198-
u64 free_pool;
199-
u64 free_pages;
200-
u64 locate_handle;
201-
u64 handle_protocol;
202-
u64 exit_boot_services;
194+
u64 boot_services;
203195
u64 text_output;
204196
efi_status_t (*call)(unsigned long, ...);
205197
bool is64;
206198
} __packed;
207199

208200
__pure const struct efi_config *__efi_early(void);
209201

202+
static inline bool efi_is_64bit(void)
203+
{
204+
if (!IS_ENABLED(CONFIG_X86_64))
205+
return false;
206+
207+
if (!IS_ENABLED(CONFIG_EFI_MIXED))
208+
return true;
209+
210+
return __efi_early()->is64;
211+
}
212+
210213
#define efi_call_early(f, ...) \
211-
__efi_early()->call(__efi_early()->f, __VA_ARGS__);
214+
__efi_early()->call(efi_is_64bit() ? \
215+
((efi_boot_services_64_t *)(unsigned long) \
216+
__efi_early()->boot_services)->f : \
217+
((efi_boot_services_32_t *)(unsigned long) \
218+
__efi_early()->boot_services)->f, __VA_ARGS__)
212219

213220
#define __efi_call_early(f, ...) \
214221
__efi_early()->call((unsigned long)f, __VA_ARGS__);
215222

216-
#define efi_is_64bit() __efi_early()->is64
217-
218223
extern bool efi_reboot_required(void);
219224

220225
#else

‎arch/x86/kernel/setup.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,19 +1096,19 @@ void __init setup_arch(char **cmdline_p)
10961096
memblock_set_current_limit(ISA_END_ADDRESS);
10971097
memblock_x86_fill();
10981098

1099-
if (efi_enabled(EFI_BOOT)) {
1099+
reserve_bios_regions();
1100+
1101+
if (efi_enabled(EFI_MEMMAP)) {
11001102
efi_fake_memmap();
11011103
efi_find_mirror();
1102-
}
1103-
1104-
reserve_bios_regions();
1104+
efi_esrt_init();
11051105

1106-
/*
1107-
* The EFI specification says that boot service code won't be called
1108-
* after ExitBootServices(). This is, in fact, a lie.
1109-
*/
1110-
if (efi_enabled(EFI_MEMMAP))
1106+
/*
1107+
* The EFI specification says that boot service code won't be
1108+
* called after ExitBootServices(). This is, in fact, a lie.
1109+
*/
11111110
efi_reserve_boot_services();
1111+
}
11121112

11131113
/* preallocate 4k for mptable mpc */
11141114
early_reserve_e820_mpc_new();

‎arch/x86/platform/efi/efi-bgrt.c‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,12 @@ void __init efi_bgrt_init(void)
8282
}
8383
bgrt_image_size = bmp_header.size;
8484

85-
bgrt_image = kmalloc(bgrt_image_size, GFP_KERNEL | __GFP_NOWARN);
85+
bgrt_image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB);
8686
if (!bgrt_image) {
87-
pr_notice("Ignoring BGRT: failed to allocate memory for image (wanted %zu bytes)\n",
88-
bgrt_image_size);
89-
return;
90-
}
91-
92-
image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB);
93-
if (!image) {
9487
pr_notice("Ignoring BGRT: failed to map image memory\n");
95-
kfree(bgrt_image);
9688
bgrt_image = NULL;
9789
return;
9890
}
9991

100-
memcpy(bgrt_image, image, bgrt_image_size);
101-
memunmap(image);
92+
efi_mem_reserve(bgrt_tab->image_address, bgrt_image_size);
10293
}

0 commit comments

Comments
 (0)