]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Jun 2023 23:39:41 +0000 (01:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Aug 2023 17:48:24 +0000 (19:48 +0200)
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 <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.670360645@linutronix.de
Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/mem_encrypt.h
arch/x86/kernel/cpu/common.c
init/main.c

index e7d96c0766fe170eb8c7e5456e81a6f29ee51738..51c34aa43d660508aa7ebd55e65baf343c2300e6 100644 (file)
@@ -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 */
 
 /*
index 3b1b0a7345769930363fb0d91414c75d47c1662f..3c16ecd213ab98c325c6781452e06475e3ea0688 100644 (file)
@@ -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>
@@ -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();
 }
index e35f1391d6c2a625126e09fc7f0b327656759035..9afb1eedf95d0ce8a0068e5bf56c1c388ac380e9 100644 (file)
@@ -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
  */
@@ -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) {