From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Juergen Gross <jgross@suse.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH v2 2/3] x86/realmode: add trampoline reference structure
Date: Tue, 22 Nov 2022 17:38:09 +0100 [thread overview]
Message-ID: <20221122163810.29752-3-jgross@suse.com> (raw)
In-Reply-To: <20221122163810.29752-1-jgross@suse.com>
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@suse.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
next prev parent reply other threads:[~2022-11-22 16:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 16:38 [PATCH v2 0/3] x86/realmode: use a dummy trampoline for Xen PV guests Juergen Gross
2022-11-22 16:38 ` [PATCH v2 1/3] x86/realmode: test real_mode_header outside of real_mode_size_needed() Juergen Gross
2022-11-22 16:38 ` Juergen Gross [this message]
2022-11-22 16:38 ` [PATCH v2 3/3] x86/xen: add a dummy trampoline for Xen PV guests Juergen Gross
2022-11-23 9:37 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221122163810.29752-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®