kernel - Fix efivar panic
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 29 May 2020 05:41:32 +0000 (22:41 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 29 May 2020 06:52:48 +0000 (23:52 -0700)
commit8d2aaeec20170c5188010f1b7bfbc1684364c84b
treeb6327105f099ee942842e3fbbe9e30a0150fee3c
parentb94b84ca5c08efb447331811e050106ac4c7d3f1
kernel - Fix efivar panic

* The efirt driver uses direct-map mode, and creates an independent
  pmap to hold it.  The direct map typically uses userspace addresses,
  so SMAP must be disabled across any EFI call.

* Add smap_open(), smap_close(), smap_smep_disable(), and
  smap_smep_enable() calls for C.

  NOTE: We also have to set pcb_onfault to non-NULL to bypass failsafe
checks done in trap().

* Hack the EFI address space code to disable SMAP and SMEP across
  the EFI call.  Unfortunately since we also have to disable SMEP,
  these functions have to manipulate CR4.

Reported-by: daftaupe
sys/cpu/x86_64/include/cpufunc.h
sys/platform/pc64/x86_64/efirt.c
sys/platform/pc64/x86_64/pmap.c
sys/platform/pc64/x86_64/support.s
sys/platform/pc64/x86_64/trap.c
sys/vm/pmap.h