linux-stable/arch
Tom Lendacky e7d445ab26 x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c
When runtime support for converting between 4-level and 5-level pagetables
was added to the kernel, the SME code that built pagetables was updated
to use the pagetable functions, e.g. p4d_offset(), etc., in order to
simplify the code. However, the use of the pagetable functions in early
boot code requires the use of the USE_EARLY_PGTABLE_L5 #define in order to
ensure that the proper definition of pgtable_l5_enabled() is used.

Without the #define, pgtable_l5_enabled() is #defined as
cpu_feature_enabled(X86_FEATURE_LA57). In early boot, the CPU features
have not yet been discovered and populated, so pgtable_l5_enabled() will
return false even when 5-level paging is enabled. This causes the SME code
to always build 4-level pagetables to perform the in-place encryption.
If 5-level paging is enabled, switching to the SME pagetables results in
a page-fault that kills the boot.

Adding the #define results in pgtable_l5_enabled() using the
__pgtable_l5_enabled variable set in early boot and the SME code building
pagetables for the proper paging level.

Fixes: aad983913d ("x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: <stable@vger.kernel.org> # 4.18.x
Link: https://lkml.kernel.org/r/2cb8329655f5c753905812d951e212022a480475.1634318656.git.thomas.lendacky@amd.com
2021-10-19 14:07:17 +02:00
..
alpha alpha: enable GENERIC_PCI_IOMAP unconditionally 2021-09-19 10:37:00 -07:00
arc Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
arm asm-generic: build fixes for v5.15 2021-10-08 11:57:54 -07:00
arm64 asm-generic: build fixes for v5.15 2021-10-08 11:57:54 -07:00
csky entry: rseq: Call rseq_handle_notify_resume() in tracehook_notify_resume() 2021-09-22 10:24:01 -04:00
h8300 Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
hexagon Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
ia64 firmware: include drivers/firmware/Kconfig unconditionally 2021-10-07 16:51:26 +02:00
m68k m68k: Remove set_fs() 2021-09-24 13:35:07 +02:00
microblaze Microblaze patches for 5.15-rc1 2021-09-08 16:02:13 -07:00
mips asm-generic: build fixes for v5.15 2021-10-08 11:57:54 -07:00
nds32 nds32/setup: remove unused memblock_region variable in setup_memory() 2021-09-08 18:45:53 -07:00
nios2 NIOS2: setup.c: drop unused variable 'dram_start' 2021-09-27 08:34:54 -05:00
openrisc Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
parisc asm-generic: build fixes for v5.15 2021-10-08 11:57:54 -07:00
powerpc powerpc fixes for 5.15 #3 2021-10-10 10:12:42 -07:00
riscv RISC-V Fixes for 5.15-rc5 2021-10-09 09:07:58 -07:00
s390 s390/pci: fix zpci_zdev_put() on reserve 2021-10-04 09:49:10 +02:00
sh sh: pgtable-3level: fix cast to pointer from integer of different size 2021-09-24 16:13:35 -07:00
sparc sparc64: fix pci_iounmap() when CONFIG_PCI is not set 2021-09-20 10:56:32 -07:00
um This pull request contains the following changes for UML: 2021-09-09 13:45:26 -07:00
x86 x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c 2021-10-19 14:07:17 +02:00
xtensa xtensa: xtfpga: Try software restart before simulating CPU reset 2021-10-05 12:19:05 -07:00
.gitignore
Kconfig Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00