lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221122163810.29752-3-jgross@suse.com>
Date:   Tue, 22 Nov 2022 17:38:09 +0100
From:   Juergen Gross <jgross@...e.com>
To:     linux-kernel@...r.kernel.org, x86@...nel.org
Cc:     Juergen Gross <jgross@...e.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH v2 2/3] x86/realmode: add trampoline reference structure

Add a new struct trampoline_ref containing the relevant pointers for
handling the realmode trampoline. Use a central pointer for accessing
this new structure in preparation of adding support of replacing it
with a dummy trampoline.

Signed-off-by: Juergen Gross <jgross@...e.com>
---
 arch/x86/include/asm/realmode.h | 12 +++++++++++-
 arch/x86/realmode/init.c        | 13 +++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
index 1eb3d4232e81..778d6cb1db6c 100644
--- a/arch/x86/include/asm/realmode.h
+++ b/arch/x86/include/asm/realmode.h
@@ -14,6 +14,13 @@
 #include <linux/types.h>
 #include <asm/io.h>
 
+/* Pointers for installing the realmode trampoline. */
+struct trampoline_ref {
+	unsigned char *blob;
+	unsigned char *blob_end;
+	unsigned char *relocs;
+};
+
 /* This must match data at realmode/rm/header.S */
 struct real_mode_header {
 	u32	text_start;
@@ -56,6 +63,8 @@ struct trampoline_header {
 };
 
 extern struct real_mode_header *real_mode_header;
+extern struct trampoline_ref *real_mode_trampoline __initdata;
+
 extern unsigned char real_mode_blob_end[];
 
 extern unsigned long initial_code;
@@ -78,7 +87,8 @@ extern unsigned char secondary_startup_64_no_verify[];
 
 static inline size_t real_mode_size_needed(void)
 {
-	return PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
+	return PAGE_ALIGN(real_mode_trampoline->blob_end -
+			  real_mode_trampoline->blob);
 }
 
 static inline void set_real_mode_mem(phys_addr_t mem)
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 37a3658efaa0..5a670a9ed2f7 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -12,6 +12,15 @@
 #include <asm/sev.h>
 
 struct real_mode_header *real_mode_header;
+
+static __initdata struct trampoline_ref realmode_trampoline = {
+	.blob = real_mode_blob,
+	.blob_end = real_mode_blob_end,
+	.relocs = real_mode_relocs,
+};
+
+struct trampoline_ref *real_mode_trampoline __initdata = &realmode_trampoline;
+
 u32 *trampoline_cr4_features;
 
 /* Hold the pgd entry used on booting additional CPUs */
@@ -111,12 +120,12 @@ static void __init setup_real_mode(void)
 	if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))
 		set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT);
 
-	memcpy(base, real_mode_blob, size);
+	memcpy(base, real_mode_trampoline->blob, size);
 
 	phys_base = __pa(base);
 	real_mode_seg = phys_base >> 4;
 
-	rel = (u32 *) real_mode_relocs;
+	rel = (u32 *) real_mode_trampoline->relocs;
 
 	/* 16-bit segment relocations. */
 	count = *rel++;
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ