Skip to content

Commit 1cd9c22

Browse files
kirylIngo Molnar
authored andcommitted
x86/mm/encrypt: Move page table helpers into separate translation unit
There are bunch of functions in mem_encrypt.c that operate on the identity mapping, which means they want virtual addresses to be equal to physical one, without PAGE_OFFSET shift. We also need to avoid paravirtualizaion call there. Getting this done is tricky. We cannot use usual page table helpers. It forces us to open-code a lot of things. It makes code ugly and hard to modify. We can get it work with the page table helpers, but it requires few preprocessor tricks. These tricks may have side effects for the rest of the file. Let's isolate such functions into own translation unit. Tested-by: Tom Lendacky <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 515ab7c commit 1cd9c22

File tree

4 files changed

+608
-582
lines changed

4 files changed

+608
-582
lines changed

arch/x86/include/asm/mem_encrypt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifdef CONFIG_AMD_MEM_ENCRYPT
2323

2424
extern u64 sme_me_mask;
25+
extern bool sev_enabled;
2526

2627
void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr,
2728
unsigned long decrypted_kernel_vaddr,

arch/x86/mm/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
# Kernel does not boot with instrumentation of tlb.c and mem_encrypt.c
3-
KCOV_INSTRUMENT_tlb.o := n
4-
KCOV_INSTRUMENT_mem_encrypt.o := n
2+
# Kernel does not boot with instrumentation of tlb.c and mem_encrypt*.c
3+
KCOV_INSTRUMENT_tlb.o := n
4+
KCOV_INSTRUMENT_mem_encrypt.o := n
5+
KCOV_INSTRUMENT_mem_encrypt_identity.o := n
56

6-
KASAN_SANITIZE_mem_encrypt.o := n
7+
KASAN_SANITIZE_mem_encrypt.o := n
8+
KASAN_SANITIZE_mem_encrypt_identity.o := n
79

810
ifdef CONFIG_FUNCTION_TRACER
9-
CFLAGS_REMOVE_mem_encrypt.o = -pg
11+
CFLAGS_REMOVE_mem_encrypt.o = -pg
12+
CFLAGS_REMOVE_mem_encrypt_identity.o = -pg
1013
endif
1114

1215
obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
@@ -47,4 +50,5 @@ obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o
4750
obj-$(CONFIG_PAGE_TABLE_ISOLATION) += pti.o
4851

4952
obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt.o
53+
obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt_identity.o
5054
obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt_boot.o

0 commit comments

Comments
 (0)