Skip to content

Commit d9e3d2c

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
efi/x86: Don't map the entire kernel text RW for mixed mode
The mixed mode thunking routine requires a part of it to be mapped 1:1, and for this reason, we currently map the entire kernel .text read/write in the EFI page tables, which is bad. In fact, the kernel_map_pages_in_pgd() invocation that installs this mapping is entirely redundant, since all of DRAM is already 1:1 mapped read/write in the EFI page tables when we reach this point, which means that .rodata is mapped read-write as well. So let's remap both .text and .rodata read-only in the EFI page tables. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 75fbef0 commit d9e3d2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/platform/efi/efi_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
391391

392392
efi_scratch.phys_stack = page_to_phys(page + 1); /* stack grows down */
393393

394-
npages = (_etext - _text) >> PAGE_SHIFT;
394+
npages = (__end_rodata_aligned - _text) >> PAGE_SHIFT;
395395
text = __pa(_text);
396396
pfn = text >> PAGE_SHIFT;
397397

398-
pf = _PAGE_RW | _PAGE_ENC;
398+
pf = _PAGE_ENC;
399399
if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, pf)) {
400400
pr_err("Failed to map kernel text 1:1\n");
401401
return 1;

0 commit comments

Comments
 (0)