Skip to content

Commit b083788

Browse files
KAGA-KOKOgregkh
authored andcommitted
init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
commit 439e175 upstream Invoke the X86ism mem_encrypt_init() from X86 arch_cpu_finalize_init() and remove the weak fallback from the core code. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Sneddon <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8183a89 commit b083788

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

arch/x86/include/asm/mem_encrypt.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ void __init mem_encrypt_free_decrypted_mem(void);
5151

5252
void __init sev_es_init_vc_handling(void);
5353

54+
void __init mem_encrypt_init(void);
55+
5456
#define __bss_decrypted __section(".bss..decrypted")
5557

5658
#else /* !CONFIG_AMD_MEM_ENCRYPT */
@@ -82,13 +84,12 @@ early_set_mem_enc_dec_hypercall(unsigned long vaddr, int npages, bool enc) {}
8284

8385
static inline void mem_encrypt_free_decrypted_mem(void) { }
8486

87+
static inline void mem_encrypt_init(void) { }
88+
8589
#define __bss_decrypted
8690

8791
#endif /* CONFIG_AMD_MEM_ENCRYPT */
8892

89-
/* Architecture __weak replacement functions */
90-
void __init mem_encrypt_init(void);
91-
9293
void add_encrypt_protection_map(void);
9394

9495
/*

arch/x86/kernel/cpu/common.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/init.h>
1919
#include <linux/kprobes.h>
2020
#include <linux/kgdb.h>
21+
#include <linux/mem_encrypt.h>
2122
#include <linux/smp.h>
2223
#include <linux/cpu.h>
2324
#include <linux/io.h>
@@ -2421,4 +2422,14 @@ void __init arch_cpu_finalize_init(void)
24212422
} else {
24222423
fpu__init_check_bugs();
24232424
}
2425+
2426+
/*
2427+
* This needs to be called before any devices perform DMA
2428+
* operations that might use the SWIOTLB bounce buffers. It will
2429+
* mark the bounce buffers as decrypted so that their usage will
2430+
* not cause "plain-text" data to be decrypted when accessed. It
2431+
* must be called after late_time_init() so that Hyper-V x86/x64
2432+
* hypercalls work when the SWIOTLB bounce buffers are decrypted.
2433+
*/
2434+
mem_encrypt_init();
24242435
}

init/main.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
#include <linux/cache.h>
9797
#include <linux/rodata_test.h>
9898
#include <linux/jump_label.h>
99-
#include <linux/mem_encrypt.h>
10099
#include <linux/kcsan.h>
101100
#include <linux/init_syscalls.h>
102101
#include <linux/stackdepot.h>
@@ -780,8 +779,6 @@ void __init __weak thread_stack_cache_init(void)
780779
}
781780
#endif
782781

783-
void __init __weak mem_encrypt_init(void) { }
784-
785782
void __init __weak poking_init(void) { }
786783

787784
void __init __weak pgtable_cache_init(void) { }
@@ -1083,14 +1080,6 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
10831080
*/
10841081
locking_selftest();
10851082

1086-
/*
1087-
* This needs to be called before any devices perform DMA
1088-
* operations that might use the SWIOTLB bounce buffers. It will
1089-
* mark the bounce buffers as decrypted so that their usage will
1090-
* not cause "plain-text" data to be decrypted when accessed.
1091-
*/
1092-
mem_encrypt_init();
1093-
10941083
#ifdef CONFIG_BLK_DEV_INITRD
10951084
if (initrd_start && !initrd_below_start_ok &&
10961085
page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {

0 commit comments

Comments
 (0)