Disable VMAP_STACK as it causes crash in EFI

Bug #1992458 reported by Alexandre Ghiti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux-riscv (Ubuntu)
New
Undecided
Unassigned

Bug Description

[ Impact ]

The kernel crashes when trying to access the EFI runtime services/variables if the kernel is configured with CONFIG_VMAP_STACK. Indeed, to access EFI variables/services, the kernel switches to the EFI page table which is created during the boot process *but* is never updated during the life of the kernel: as CONFIG_VMAP_STACK allocates the kernel stack in the vmalloc region and maps it in the *kernel page table*, the EFI page table never has this new mapping and then segfaults when trying to access the kernel stack of the current process.

This is easier to reproduce on the Unmatched than on QEMU (never reproduced on this platform):

ubuntu@ubuntu:~$ cat /sys/firmware/efi/efivars/*

Which gives rise to a kernel crash, gdb traces below:

(gdb) bt
#0 handle_exception () at /home/alex/work/linux/arch/riscv/kernel/entry.S:27
#1 0xffffffff8080741a in efi_virtmap_load () at /home/alex/work/linux/arch/riscv/include/asm/current.h:31
#2 0x0000000000000000 in ?? ()
(gdb) p/x $stval
$1 = 0xffffffc8946cbc38
(gdb) display /i $sepc
1: x/i $sepc
   0xffffffff8000392c <handle_exception+44>: sd ra,8(sp)
(gdb) p/x $sp
$6 = 0xffffffc8946cbc30

A workaround can be to disable CONFIG_VMAP_STACK but actually any mapping in the kernel page table that is not also added to the EFI page table can cause such crash: but I'm not sure this can happen and this workaround was enough in the previous release to fix this bug and to be able to live install a system.

I advise to implement this workaround for now as I'm implementing the proper patch which consists in updating the EFI page table before switching to it, just like x86 does.

[ Test Plan ]

Use a kernel with CONFIG_VMAP_STACK disabled and simply enter the following command, preferably on the Unmatched:

ubuntu@ubuntu:~$ cat /sys/firmware/efi/efivars/*

This should not trigger a crash.

[ Where problems could occur ]

As said above, just disabling CONFIG_VMAP_STACK may not be enough.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.