linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparc64: fix hugetlb for sun4u
@ 2025-07-16  1:24 Anthony Yznaga
  2025-07-16  6:18 ` John Paul Adrian Glaubitz
                   ` (4 more replies)
  0 siblings, 5 replies; 27+ messages in thread
From: Anthony Yznaga @ 2025-07-16  1:24 UTC (permalink / raw)
  To: sparclinux, davem, andreas
  Cc: linux-kernel, agordeev, will, ryan.roberts, david, osalvador

An attempt to exercise sparc hugetlb code in a sun4u-based guest
running under qemu results in the guest hanging due to being stuck
in a trap loop. This is due to invalid hugetlb TTEs being installed
that do not have the expected _PAGE_PMD_HUGE and page size bits set.
Although the breakage has gone apparently unnoticed for several years,
fix it now so there is the option to exercise sparc hugetlb code under
qemu. This can be useful because sun4v support in qemu does not support
linux guests currently and sun4v-based hardware resources may not be
readily available.

Fix tested with a 6.15.2 and 6.16-rc6 kernels by running libhugetlbfs
tests on a qemu guest running Debian 13.

Fixes: c7d9f77d33a7 ("sparc64: Multi-page size support")
Cc: stable@vger.kernel.org
Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
---
 arch/sparc/mm/hugetlbpage.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
index 80504148d8a5..2048b5c42ca8 100644
--- a/arch/sparc/mm/hugetlbpage.c
+++ b/arch/sparc/mm/hugetlbpage.c
@@ -22,6 +22,26 @@
 
 static pte_t sun4u_hugepage_shift_to_tte(pte_t entry, unsigned int shift)
 {
+	unsigned long hugepage_size = _PAGE_SZ4MB_4U;
+
+	pte_val(entry) = pte_val(entry) & ~_PAGE_SZALL_4U;
+
+	switch (shift) {
+	case HPAGE_256MB_SHIFT:
+		hugepage_size = _PAGE_SZ256MB_4U;
+		pte_val(entry) |= _PAGE_PMD_HUGE;
+		break;
+	case HPAGE_SHIFT:
+		pte_val(entry) |= _PAGE_PMD_HUGE;
+		break;
+	case HPAGE_64K_SHIFT:
+		hugepage_size = _PAGE_SZ64K_4U;
+		break;
+	default:
+		WARN_ONCE(1, "unsupported hugepage shift=%u\n", shift);
+	}
+
+	pte_val(entry) = pte_val(entry) | hugepage_size;
 	return entry;
 }
 
-- 
2.47.1


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

end of thread, other threads:[~2025-09-19 18:01 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  1:24 [PATCH] sparc64: fix hugetlb for sun4u Anthony Yznaga
2025-07-16  6:18 ` John Paul Adrian Glaubitz
2025-07-16  8:41   ` John Paul Adrian Glaubitz
2025-07-16 16:47     ` Anthony Yznaga
2025-07-24 10:52     ` John Paul Adrian Glaubitz
2025-07-25  5:59 ` John Paul Adrian Glaubitz
2025-07-25 20:46 ` John Paul Adrian Glaubitz
2025-07-25 21:09   ` John Paul Adrian Glaubitz
2025-08-08 21:31 ` John Paul Adrian Glaubitz
2025-08-08 22:15   ` Anthony Yznaga
2025-08-08 22:37     ` John Paul Adrian Glaubitz
2025-08-09  6:23       ` John Paul Adrian Glaubitz
2025-08-09  6:26         ` John Paul Adrian Glaubitz
2025-08-09  6:42           ` John Paul Adrian Glaubitz
2025-08-10  9:52             ` John Paul Adrian Glaubitz
2025-08-10 22:20               ` John Paul Adrian Glaubitz
2025-08-11  8:25                 ` David Hildenbrand
2025-08-11 10:44                 ` John Paul Adrian Glaubitz
2025-08-11 11:06                   ` John Paul Adrian Glaubitz
2025-08-12 12:32                   ` Found it - was: " John Paul Adrian Glaubitz
2025-08-12 12:34                     ` John Paul Adrian Glaubitz
2025-08-21 12:52                     ` David Hildenbrand
2025-08-21 15:03                       ` Edgecombe, Rick P
2025-08-21 16:42                         ` John Paul Adrian Glaubitz
2025-08-11  8:20         ` David Hildenbrand
2025-08-11  8:28           ` John Paul Adrian Glaubitz
2025-09-19 18:01 ` Andreas Larsson

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).