platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] x86/realmode: use a dummy trampoline for Xen PV guests
@ 2022-11-22 16:38 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
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2022-11-22 16:38 UTC (permalink / raw)
  To: linux-kernel, x86, linux-efi, platform-driver-x86
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin, Ard Biesheuvel, Darren Hart,
	Andy Shevchenko, Boris Ostrovsky, xen-devel

A Xen PV guests can't run in realmode, so the realmode trampoline can
omitted.

Changes in V2:
- complete new approach

Juergen Gross (3):
  x86/realmode: test real_mode_header outside of real_mode_size_needed()
  x86/realmode: add trampoline reference structure
  x86/xen: add a dummy trampoline for Xen PV guests

 arch/x86/include/asm/realmode.h | 15 +++++++++++----
 arch/x86/platform/efi/quirks.c  |  3 ++-
 arch/x86/realmode/init.c        | 25 ++++++++++++++++++++-----
 arch/x86/xen/enlighten_pv.c     | 17 +++++++++++++++++
 4 files changed, 50 insertions(+), 10 deletions(-)

-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 1/3] x86/realmode: test real_mode_header outside of real_mode_size_needed()
  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 ` Juergen Gross
  0 siblings, 0 replies; 2+ messages in thread
From: Juergen Gross @ 2022-11-22 16:38 UTC (permalink / raw)
  To: linux-kernel, x86, linux-efi, platform-driver-x86
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin, Ard Biesheuvel, Darren Hart,
	Andy Shevchenko

Move the test for the realmode trampoline memory having been allocated
already to the callers of real_mode_size_needed(). This allows to use
that function in setup_real_mode() and set_real_mode_permissions(),
too.

While at it change the size calculation to use PAGE_ALIGN() instead of
open coding it.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/include/asm/realmode.h | 5 +----
 arch/x86/platform/efi/quirks.c  | 3 ++-
 arch/x86/realmode/init.c        | 6 +++---
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
index fd6f6e5b755a..1eb3d4232e81 100644
--- a/arch/x86/include/asm/realmode.h
+++ b/arch/x86/include/asm/realmode.h
@@ -78,10 +78,7 @@ extern unsigned char secondary_startup_64_no_verify[];
 
 static inline size_t real_mode_size_needed(void)
 {
-	if (real_mode_header)
-		return 0;	/* already allocated. */
-
-	return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE);
+	return PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
 }
 
 static inline void set_real_mode_mem(phys_addr_t mem)
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index b0b848d6933a..7c18ca720eee 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -445,7 +445,8 @@ void __init efi_free_boot_services(void)
 		 * panicking early.)
 		 */
 		rm_size = real_mode_size_needed();
-		if (rm_size && (start + rm_size) < (1<<20) && size >= rm_size) {
+		if (!real_mode_header && rm_size &&
+		    (start + rm_size) < (1<<20) && size >= rm_size) {
 			set_real_mode_mem(start);
 			start += rm_size;
 			size -= rm_size;
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 41d7669a97ad..37a3658efaa0 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -48,7 +48,7 @@ void __init reserve_real_mode(void)
 	phys_addr_t mem;
 	size_t size = real_mode_size_needed();
 
-	if (!size)
+	if (real_mode_header || !size)
 		return;
 
 	WARN_ON(slab_is_available());
@@ -94,7 +94,7 @@ static void __init setup_real_mode(void)
 	unsigned char *base;
 	unsigned long phys_base;
 	struct trampoline_header *trampoline_header;
-	size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
+	size_t size = real_mode_size_needed();
 #ifdef CONFIG_X86_64
 	u64 *trampoline_pgd;
 	u64 efer;
@@ -182,7 +182,7 @@ static void __init setup_real_mode(void)
 static void __init set_real_mode_permissions(void)
 {
 	unsigned char *base = (unsigned char *) real_mode_header;
-	size_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);
+	size_t size = real_mode_size_needed();
 
 	size_t ro_size =
 		PAGE_ALIGN(real_mode_header->ro_end) -
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-22 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).