mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/mm: fix poking_init() for Xen PV guests
@ 2023-01-09 15:09 Juergen Gross
  2023-01-12  9:06 ` [tip: x86/urgent] " tip-bot2 for Juergen Gross
  2023-01-12 10:34 ` tip-bot2 for Juergen Gross
  0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2023-01-09 15:09 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: xen-devel, Juergen Gross, Dave Hansen, Andy Lutomirski,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin

Commit 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()") broke
the kernel for running as Xen PV guest.

It seems as if the new address space is never activated before being
used, resulting in Xen rejecting to accept the new CR3 value (the PGD
isn't pinned).

Fix that by adding the now missing call of paravirt_arch_dup_mmap() to
poking_init(). That call was previously done by dup_mm()->dup_mmap() and
it is a NOP for all cases but for Xen PV, where it is just doing the
pinning of the PGD.

Fixes: 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/mm/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d3987359d441..5f8ba537d9d3 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -804,6 +804,9 @@ void __init poking_init(void)
 	poking_mm = mm_alloc();
 	BUG_ON(!poking_mm);
 
+	/* Xen PV guests need the PGD to be pinned. */
+	paravirt_arch_dup_mmap(NULL, poking_mm);
+
 	/*
 	 * Randomize the poking address, but make sure that the following page
 	 * will be mapped at the same PMD. We need 2 pages, so find space for 3,
-- 
2.35.3


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

* [tip: x86/urgent] x86/mm: fix poking_init() for Xen PV guests
  2023-01-09 15:09 [PATCH] x86/mm: fix poking_init() for Xen PV guests Juergen Gross
@ 2023-01-12  9:06 ` tip-bot2 for Juergen Gross
  2023-01-12 10:34 ` tip-bot2 for Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Juergen Gross @ 2023-01-12  9:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Juergen Gross, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     8a6b240fef388e9c2c40dcb72d142ee781f6432a
Gitweb:        https://git.kernel.org/tip/8a6b240fef388e9c2c40dcb72d142ee781f6432a
Author:        Juergen Gross <jgross@suse.com>
AuthorDate:    Mon, 09 Jan 2023 16:09:22 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 12 Jan 2023 09:48:02 +01:00

x86/mm: fix poking_init() for Xen PV guests

Commit 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()") broke
the kernel for running as Xen PV guest.

It seems as if the new address space is never activated before being
used, resulting in Xen rejecting to accept the new CR3 value (the PGD
isn't pinned).

Fix that by adding the now missing call of paravirt_arch_dup_mmap() to
poking_init(). That call was previously done by dup_mm()->dup_mmap() and
it is a NOP for all cases but for Xen PV, where it is just doing the
pinning of the PGD.

Fixes: 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()")
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230109150922.10578-1-jgross@suse.com
---
 arch/x86/mm/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d398735..5f8ba53 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -804,6 +804,9 @@ void __init poking_init(void)
 	poking_mm = mm_alloc();
 	BUG_ON(!poking_mm);
 
+	/* Xen PV guests need the PGD to be pinned. */
+	paravirt_arch_dup_mmap(NULL, poking_mm);
+
 	/*
 	 * Randomize the poking address, but make sure that the following page
 	 * will be mapped at the same PMD. We need 2 pages, so find space for 3,

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

* [tip: x86/urgent] x86/mm: fix poking_init() for Xen PV guests
  2023-01-09 15:09 [PATCH] x86/mm: fix poking_init() for Xen PV guests Juergen Gross
  2023-01-12  9:06 ` [tip: x86/urgent] " tip-bot2 for Juergen Gross
@ 2023-01-12 10:34 ` tip-bot2 for Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Juergen Gross @ 2023-01-12 10:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Juergen Gross, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     26ce6ec364f18d2915923bc05784084e54a5c4cc
Gitweb:        https://git.kernel.org/tip/26ce6ec364f18d2915923bc05784084e54a5c4cc
Author:        Juergen Gross <jgross@suse.com>
AuthorDate:    Mon, 09 Jan 2023 16:09:22 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 12 Jan 2023 11:22:20 +01:00

x86/mm: fix poking_init() for Xen PV guests

Commit 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()") broke
the kernel for running as Xen PV guest.

It seems as if the new address space is never activated before being
used, resulting in Xen rejecting to accept the new CR3 value (the PGD
isn't pinned).

Fix that by adding the now missing call of paravirt_arch_dup_mmap() to
poking_init(). That call was previously done by dup_mm()->dup_mmap() and
it is a NOP for all cases but for Xen PV, where it is just doing the
pinning of the PGD.

Fixes: 3f4c8211d982 ("x86/mm: Use mm_alloc() in poking_init()")
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230109150922.10578-1-jgross@suse.com
---
 arch/x86/mm/init.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d398735..cb258f5 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -26,6 +26,7 @@
 #include <asm/pti.h>
 #include <asm/text-patching.h>
 #include <asm/memtype.h>
+#include <asm/paravirt.h>
 
 /*
  * We need to define the tracepoints somewhere, and tlb.c
@@ -804,6 +805,9 @@ void __init poking_init(void)
 	poking_mm = mm_alloc();
 	BUG_ON(!poking_mm);
 
+	/* Xen PV guests need the PGD to be pinned. */
+	paravirt_arch_dup_mmap(NULL, poking_mm);
+
 	/*
 	 * Randomize the poking address, but make sure that the following page
 	 * will be mapped at the same PMD. We need 2 pages, so find space for 3,

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

end of thread, other threads:[~2023-01-12 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 15:09 [PATCH] x86/mm: fix poking_init() for Xen PV guests Juergen Gross
2023-01-12  9:06 ` [tip: x86/urgent] " tip-bot2 for Juergen Gross
2023-01-12 10:34 ` tip-bot2 for Juergen Gross

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®