mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	xen-devel@lists.xenproject.org
Subject: [PATCH v2 3/3] x86/xen: add a dummy trampoline for Xen PV guests
Date: Tue, 22 Nov 2022 17:38:10 +0100	[thread overview]
Message-ID: <20221122163810.29752-4-jgross@suse.com> (raw)
In-Reply-To: <20221122163810.29752-1-jgross@suse.com>

When running as a Xen PV guest there is no need for setting up the
realmode trampoline, as realmode isn't supported in this environment.

Trying to setup the trampoline has been proven to be problematic in
some cases, especially when trying to debug early boot problems with
Xen requiring to keep the EFI boot-services memory mapped (some
firmware variants seem to claim basically all memory below 1M for boot
services).

Setup a dummy trampoline in order to make init_real_mode() happy.
In order to avoid too tight coupling between the Xen PV specific code
and the trampoline handling, modify the trampoline handling to do
nothing if the detected trampoline size is 0.

Fixes: 084ee1c641a0 ("x86, realmode: Relocator for realmode code")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/realmode/init.c    |  6 ++++++
 arch/x86/xen/enlighten_pv.c | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 5a670a9ed2f7..538328ce5ff5 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -110,6 +110,9 @@ static void __init setup_real_mode(void)
 	int i;
 #endif
 
+	if (!size)
+		return;
+
 	base = (unsigned char *)real_mode_header;
 
 	/*
@@ -204,6 +207,9 @@ static void __init set_real_mode_permissions(void)
 	unsigned long text_start =
 		(unsigned long) __va(real_mode_header->text_start);
 
+	if (!size)
+		return;
+
 	set_memory_nx((unsigned long) base, size >> PAGE_SHIFT);
 	set_memory_ro((unsigned long) base, ro_size >> PAGE_SHIFT);
 	set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 038da45f057a..a6194a6a6806 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -71,6 +71,7 @@
 #include <asm/mwait.h>
 #include <asm/pci_x86.h>
 #include <asm/cpu.h>
+#include <asm/realmode.h>
 #ifdef CONFIG_X86_IOPL_IOPERM
 #include <asm/io_bitmap.h>
 #endif
@@ -137,12 +138,28 @@ static void __init xen_pv_init_platform(void)
 	xen_init_time_ops();
 }
 
+static struct real_mode_header xen_rm_header;
+
+static __initdata struct trampoline_ref xen_dummy_trampoline = {
+	.blob = (unsigned char *)&xen_rm_header,
+	.blob_end = (unsigned char *)&xen_rm_header,
+};
+
+/* Setup dummy trampoline of size 0 with no relocations. */
+static void __init xen_setup_trampoline(void)
+{
+	real_mode_header = &xen_rm_header;
+	real_mode_trampoline = &xen_dummy_trampoline;
+}
+
 static void __init xen_pv_guest_late_init(void)
 {
 #ifndef CONFIG_SMP
 	/* Setup shared vcpu info for non-smp configurations */
 	xen_setup_vcpu_info_placement();
 #endif
+
+	xen_setup_trampoline();
 }
 
 static __read_mostly unsigned int cpuid_leaf5_ecx_val;
-- 
2.35.3


  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 " 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 ` [PATCH v2 2/3] x86/realmode: add trampoline reference structure Juergen Gross
2022-11-22 16:38 ` Juergen Gross [this message]
2022-11-23  9:37   ` [PATCH v2 3/3] x86/xen: add a dummy trampoline for Xen PV guests 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-4-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.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 \
    --cc=xen-devel@lists.xenproject.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®