Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Apr 2026 21:08:32 +0000
From:      Bjoern A. Zeeb <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org>
Subject:   git: 16c33bddb6f7 - stable/15 - linuxkpi: Define `PMD_SHIFT`
Message-ID:  <69e938d0.26dcf.7935f352@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=16c33bddb6f7a7238e033fc09a3f2403ba113df5

commit 16c33bddb6f7a7238e033fc09a3f2403ba113df5
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-03-04 20:36:20 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-04-22 20:57:01 +0000

    linuxkpi: Define `PMD_SHIFT`
    
    For now, only define it for x86 architectures.
    
    The DRM generic code started to use it in Linux 6.11.
    
    Reviewed by:    bz, emaste
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D55734
    
    (cherry picked from commit be92ad6b12a5046cecf25477e7a3e88f70e5daee)
---
 sys/compat/linuxkpi/common/include/asm/pgtable.h | 34 ++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/asm/pgtable.h b/sys/compat/linuxkpi/common/include/asm/pgtable.h
index 865662d587db..166d6142d51c 100644
--- a/sys/compat/linuxkpi/common/include/asm/pgtable.h
+++ b/sys/compat/linuxkpi/common/include/asm/pgtable.h
@@ -53,6 +53,40 @@ typedef struct page *pgtable_t;
 #define	_PAGE_PWT	(((pteval_t) 1) << _PAGE_BIT_PWT)
 #define	_PAGE_PCD	(((pteval_t) 1) << _PAGE_BIT_PCD)
 #define	_PAGE_PAT	(((pteval_t) 1) << _PAGE_BIT_PAT)
+
+/*
+ * On Linux, the value of `PMD_SHIFT` is hard-coded to 21. This corresponds to
+ * the FreeBSD `PDRSHIFT` constant.
+ */
+#define	PMD_SHIFT	PDRSHIFT
+
+#elif defined(__aarch64__)
+
+/*
+ * On Linux, the value of `PMD_SHIFT` is computed from `CONFIG_PGTABLE_LEVELS`.
+ * The result corresponds to one of the FreeBSD `L*_SHIFT` constants. Here, we
+ * take the value 21 computed from `CONFIG_PGTABLE_LEVELS = 4`, the default on
+ * aarch64, which equals to `L2_SHIFT`.
+ */
+#define	PMD_SHIFT	L2_SHIFT
+
+#elif defined(__powerpc__)
+
+/*
+ * On Linux, the value of `PMD_SHIFT` is the addition of `PAGE_SHIFT` and
+ * `PTE_INDEX_SIZE` (hard-coded to 9). The result corresponds to the FreeBSD
+ * `L3_PAGE_SIZE_SHIFT` constant.
+ */
+#define	PMD_SHIFT	L3_PAGE_SIZE_SHIFT
+
+#elif defined(__riscv)
+
+/*
+ * On Linux, the value of `PMD_SHIFT` is hard-coded to 21. This corresponds to
+ * the FreeBSD `L2_SHIFT` constant.
+ */
+#define	PMD_SHIFT	L2_SHIFT
+
 #endif
 
 #endif	/* _LINUXKPI_ASM_PGTABLE_H_ */


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e938d0.26dcf.7935f352>