Skip to content

Commit

Permalink
init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
Browse files Browse the repository at this point in the history
commit 439e17576eb47f26b78c5bbc72e344d4206d2327 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]>
  • Loading branch information
KAGA-KOKO authored and gregkh committed Aug 8, 2023
1 parent b90a399 commit ef54e26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions arch/x86/include/asm/mem_encrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static inline void __init sme_early_init(void) { }
static inline void __init sme_encrypt_kernel(struct boot_params *bp) { }
static inline void __init sme_enable(struct boot_params *bp) { }

static inline void mem_encrypt_init(void) { }

#endif /* CONFIG_AMD_MEM_ENCRYPT */

/*
Expand Down
11 changes: 11 additions & 0 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/init.h>
#include <linux/kprobes.h>
#include <linux/kgdb.h>
#include <linux/mem_encrypt.h>
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/io.h>
Expand Down Expand Up @@ -2049,4 +2050,14 @@ void __init arch_cpu_finalize_init(void)
} else {
fpu__init_check_bugs();
}

/*
* This needs to be called before any devices perform DMA
* operations that might use the SWIOTLB bounce buffers. It will
* mark the bounce buffers as decrypted so that their usage will
* not cause "plain-text" data to be decrypted when accessed. It
* must be called after late_time_init() so that Hyper-V x86/x64
* hypercalls work when the SWIOTLB bounce buffers are decrypted.
*/
mem_encrypt_init();
}
10 changes: 0 additions & 10 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,6 @@ void __init __weak thread_stack_cache_init(void)
}
#endif

void __init __weak mem_encrypt_init(void) { }

/*
* Set up kernel memory allocators
*/
Expand Down Expand Up @@ -648,14 +646,6 @@ asmlinkage __visible void __init start_kernel(void)
*/
locking_selftest();

/*
* This needs to be called before any devices perform DMA
* operations that might use the SWIOTLB bounce buffers. It will
* mark the bounce buffers as decrypted so that their usage will
* not cause "plain-text" data to be decrypted when accessed.
*/
mem_encrypt_init();

#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start && !initrd_below_start_ok &&
page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
Expand Down

0 comments on commit ef54e26

Please sign in to comment.