Skip to content

Commit 439e175

Browse files
committed
init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
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 <tglx@linutronix.de> Link: https://lore.kernel.org/r/20230613224545.670360645@linutronix.de
1 parent 9df9d2f commit 439e175

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
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 */
@@ -83,13 +85,12 @@ early_set_mem_enc_dec_hypercall(unsigned long vaddr, int npages, bool enc) {}
8385

8486
static inline void mem_encrypt_free_decrypted_mem(void) { }
8587

88+
static inline void mem_encrypt_init(void) { }
89+
8690
#define __bss_decrypted
8791

8892
#endif /* CONFIG_AMD_MEM_ENCRYPT */
8993

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

9596
/*

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>
@@ -2414,4 +2415,14 @@ void __init arch_cpu_finalize_init(void)
24142415
} else {
24152416
fpu__init_check_bugs();
24162417
}
2418+
2419+
/*
2420+
* This needs to be called before any devices perform DMA
2421+
* operations that might use the SWIOTLB bounce buffers. It will
2422+
* mark the bounce buffers as decrypted so that their usage will
2423+
* not cause "plain-text" data to be decrypted when accessed. It
2424+
* must be called after late_time_init() so that Hyper-V x86/x64
2425+
* hypercalls work when the SWIOTLB bounce buffers are decrypted.
2426+
*/
2427+
mem_encrypt_init();
24172428
}

init/main.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
#include <linux/cache.h>
9696
#include <linux/rodata_test.h>
9797
#include <linux/jump_label.h>
98-
#include <linux/mem_encrypt.h>
9998
#include <linux/kcsan.h>
10099
#include <linux/init_syscalls.h>
101100
#include <linux/stackdepot.h>
@@ -786,8 +785,6 @@ void __init __weak thread_stack_cache_init(void)
786785
}
787786
#endif
788787

789-
void __init __weak mem_encrypt_init(void) { }
790-
791788
void __init __weak poking_init(void) { }
792789

793790
void __init __weak pgtable_cache_init(void) { }
@@ -1043,16 +1040,6 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
10431040

10441041
arch_cpu_finalize_init();
10451042

1046-
/*
1047-
* This needs to be called before any devices perform DMA
1048-
* operations that might use the SWIOTLB bounce buffers. It will
1049-
* mark the bounce buffers as decrypted so that their usage will
1050-
* not cause "plain-text" data to be decrypted when accessed. It
1051-
* must be called after late_time_init() so that Hyper-V x86/x64
1052-
* hypercalls work when the SWIOTLB bounce buffers are decrypted.
1053-
*/
1054-
mem_encrypt_init();
1055-
10561043
pid_idr_init();
10571044
anon_vma_init();
10581045
#ifdef CONFIG_X86

0 commit comments

Comments
 (0)