lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250325121624.523258-35-guoren@kernel.org>
Date: Tue, 25 Mar 2025 08:16:15 -0400
From: guoren@...nel.org
To: arnd@...db.de,
	gregkh@...uxfoundation.org,
	torvalds@...ux-foundation.org,
	paul.walmsley@...ive.com,
	palmer@...belt.com,
	anup@...infault.org,
	atishp@...shpatra.org,
	oleg@...hat.com,
	kees@...nel.org,
	tglx@...utronix.de,
	will@...nel.org,
	mark.rutland@....com,
	brauner@...nel.org,
	akpm@...ux-foundation.org,
	rostedt@...dmis.org,
	edumazet@...gle.com,
	unicorn_wang@...look.com,
	inochiama@...look.com,
	gaohan@...as.ac.cn,
	shihua@...as.ac.cn,
	jiawei@...as.ac.cn,
	wuwei2016@...as.ac.cn,
	drew@...7.com,
	prabhakar.mahadev-lad.rj@...renesas.com,
	ctsai390@...estech.com,
	wefu@...hat.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	josef@...icpanda.com,
	dsterba@...e.com,
	mingo@...hat.com,
	peterz@...radead.org,
	boqun.feng@...il.com,
	guoren@...nel.org,
	xiao.w.wang@...el.com,
	qingfang.deng@...lower.com.cn,
	leobras@...hat.com,
	jszhang@...nel.org,
	conor.dooley@...rochip.com,
	samuel.holland@...ive.com,
	yongxuan.wang@...ive.com,
	luxu.kernel@...edance.com,
	david@...hat.com,
	ruanjinjie@...wei.com,
	cuiyunhui@...edance.com,
	wangkefeng.wang@...wei.com,
	qiaozhe@...as.ac.cn
Cc: ardb@...nel.org,
	ast@...nel.org,
	linux-kernel@...r.kernel.org,
	linux-riscv@...ts.infradead.org,
	kvm@...r.kernel.org,
	kvm-riscv@...ts.infradead.org,
	linux-mm@...ck.org,
	linux-crypto@...r.kernel.org,
	bpf@...r.kernel.org,
	linux-input@...r.kernel.org,
	linux-perf-users@...r.kernel.org,
	linux-serial@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	linux-arch@...r.kernel.org,
	maple-tree@...ts.infradead.org,
	linux-trace-kernel@...r.kernel.org,
	netdev@...r.kernel.org,
	linux-atm-general@...ts.sourceforge.net,
	linux-btrfs@...r.kernel.org,
	netfilter-devel@...r.kernel.org,
	coreteam@...filter.org,
	linux-nfs@...r.kernel.org,
	linux-sctp@...r.kernel.org,
	linux-usb@...r.kernel.org,
	linux-media@...r.kernel.org
Subject: [RFC PATCH V3 34/43] rv64ilp32_abi: mm: Adapt vm_flags_t struct

From: "Guo Ren (Alibaba DAMO Academy)" <guoren@...nel.org>

RV64ILP32 ABI linux kernel is based on CONFIG_64BIT, so uses
unsigned long long as vm_flags struct type.

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@...nel.org>
---
 fs/proc/task_mmu.c       |  9 +++++++--
 include/linux/mm.h       | 10 +++++++---
 include/linux/mm_types.h |  4 ++++
 mm/debug.c               |  4 ++++
 mm/memory.c              |  4 ++++
 5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index f02cd362309a..6c4eaba794da 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -905,6 +905,11 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 	return 0;
 }
 
+#ifdef CONFIG_64BIT
+#define MNEMONICS_SZ 64
+#else
+#define MNEMONICS_SZ 32
+#endif
 static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 {
 	/*
@@ -917,11 +922,11 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 	 * -Werror=unterminated-string-initialization warning
 	 *  with GCC 15
 	 */
-	static const char mnemonics[BITS_PER_LONG][3] = {
+	static const char mnemonics[MNEMONICS_SZ][3] = {
 		/*
 		 * In case if we meet a flag we don't know about.
 		 */
-		[0 ... (BITS_PER_LONG-1)] = "??",
+		[0 ... (MNEMONICS_SZ-1)] = "??",
 
 		[ilog2(VM_READ)]	= "rd",
 		[ilog2(VM_WRITE)]	= "wr",
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 454fb8ca724c..d9735cd7efe9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -412,7 +412,11 @@ extern unsigned int kobjsize(const void *objp);
 
 #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
 # define VM_UFFD_MINOR_BIT	38
+#ifdef CONFIG_64BIT
+# define VM_UFFD_MINOR		BIT_ULL(VM_UFFD_MINOR_BIT)	/* UFFD minor faults */
+#else
 # define VM_UFFD_MINOR		BIT(VM_UFFD_MINOR_BIT)	/* UFFD minor faults */
+#endif
 #else /* !CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
 # define VM_UFFD_MINOR		VM_NONE
 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
@@ -426,14 +430,14 @@ extern unsigned int kobjsize(const void *objp);
  */
 #ifdef CONFIG_64BIT
 #define VM_ALLOW_ANY_UNCACHED_BIT	39
-#define VM_ALLOW_ANY_UNCACHED		BIT(VM_ALLOW_ANY_UNCACHED_BIT)
+#define VM_ALLOW_ANY_UNCACHED		BIT_ULL(VM_ALLOW_ANY_UNCACHED_BIT)
 #else
 #define VM_ALLOW_ANY_UNCACHED		VM_NONE
 #endif
 
 #ifdef CONFIG_64BIT
 #define VM_DROPPABLE_BIT	40
-#define VM_DROPPABLE		BIT(VM_DROPPABLE_BIT)
+#define VM_DROPPABLE		BIT_ULL(VM_DROPPABLE_BIT)
 #elif defined(CONFIG_PPC32)
 #define VM_DROPPABLE		VM_ARCH_1
 #else
@@ -442,7 +446,7 @@ extern unsigned int kobjsize(const void *objp);
 
 #ifdef CONFIG_64BIT
 /* VM is sealed, in vm_flags */
-#define VM_SEALED	_BITUL(63)
+#define VM_SEALED	_BITULL(63)
 #endif
 
 /* Bits set in the VMA until the stack is in its final location */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 0d436b0217fd..900665c5eca8 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -571,7 +571,11 @@ static inline void *folio_get_private(struct folio *folio)
 	return folio->private;
 }
 
+#ifdef CONFIG_64BIT
+typedef unsigned long long vm_flags_t;
+#else
 typedef unsigned long vm_flags_t;
+#endif
 
 /*
  * A region containing a mapping of a non-memory backed file under NOMMU
diff --git a/mm/debug.c b/mm/debug.c
index 8d2acf432385..0fcb85e6efea 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -181,7 +181,11 @@ void dump_vma(const struct vm_area_struct *vma)
 	pr_emerg("vma %px start %px end %px mm %px\n"
 		"prot %lx anon_vma %px vm_ops %px\n"
 		"pgoff %lx file %px private_data %px\n"
+#ifdef CONFIG_64BIT
+		"flags: %#llx(%pGv)\n",
+#else
 		"flags: %#lx(%pGv)\n",
+#endif
 		vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_mm,
 		(unsigned long)pgprot_val(vma->vm_page_prot),
 		vma->anon_vma, vma->vm_ops, vma->vm_pgoff,
diff --git a/mm/memory.c b/mm/memory.c
index 539c0f7c6d54..3c4a9663c094 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -533,7 +533,11 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
 		 (long long)pte_val(pte), (long long)pmd_val(*pmd));
 	if (page)
 		dump_page(page, "bad pte");
+#ifdef CONFIG_64BIT
+	pr_alert("addr:%px vm_flags:%08llx anon_vma:%px mapping:%px index:%lx\n",
+#else
 	pr_alert("addr:%px vm_flags:%08lx anon_vma:%px mapping:%px index:%lx\n",
+#endif
 		 (void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);
 	pr_alert("file:%pD fault:%ps mmap:%ps read_folio:%ps\n",
 		 vma->vm_file,
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ