Skip to contentSkip to conversation

mm: debug_vm_pgtable: Don't use __P000 directly

PATCH Applied [email protected] 2 participants 3 messages Sep 24, 2021 – Sep 27, 2021 Memory management

v2 of 3 Applied 1/1 Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm: debug_vm_pgtable: Don't use __P000 directly

From: Guo Ren <[email protected]>

The __Pxxx/__Sxxx macros are only for protection_map[] init. All usage of them in linux should come from protection_map array.

Because a lot of architectures would re-initilize protection_map[] array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.

Using __P000 is not rigorous.

---

Changes since V2:
- s/init protection_map[]/protection_map[] init/
- s/Becasue/Because/
- Remove unclear part
- Replace __P000 and __S000 with protection_map[0] and protection_map[8]

---
 mm/debug_vm_pgtable.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
mm/debug_vm_pgtable.c +4 -3
index 1403639302e4..228e3954b90c 100644
@@ -1104,13 +1104,14 @@ static int __init init_args(struct pgtable_debug_args *args)
 	/*
 	 * Initialize the debugging data.
 	 *
-	 * __P000 (or even __S000) will help create page table entries with
-	 * PROT_NONE permission as required for pxx_protnone_tests().
+	 * protection_map[0] (or even protection_map[8]) will help create
+	 * page table entries with PROT_NONE permission as required for
+	 * pxx_protnone_tests().
 	 */
 	memset(args, 0, sizeof(*args));
 	args->vaddr              = get_random_vaddr();
 	args->page_prot          = vm_get_page_prot(VMFLAGS);
-	args->page_prot_none     = __P000;
+	args->page_prot_none     = protection_map[0];
 	args->is_contiguous_page = false;
 	args->pud_pfn            = ULONG_MAX;
 	args->pmd_pfn            = ULONG_MAX;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · On 9/24/21 11:38 AM, [email protected] wrote:

From: Guo Ren <[email protected]>

The __Pxxx/__Sxxx macros are only for protection_map[] init. All usage of them in linux should come from protection_map array.

Quoted 7 lines

Because a lot of architectures would re-initilize protection_map[] array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.

Using __P000 is not rigorous.

Quoted 36 lines

---

Changes since V2:
- s/init protection_map[]/protection_map[] init/
- s/Becasue/Because/
- Remove unclear part
- Replace __P000 and __S000 with protection_map[0] and protection_map[8]

---
 mm/debug_vm_pgtable.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
mm/debug_vm_pgtable.c +4 -3
index 1403639302e4..228e3954b90c 100644
@@ -1104,13 +1104,14 @@ static int __init init_args(struct pgtable_debug_args *args)
 	/*
 	 * Initialize the debugging data.
 	 *
-	 * __P000 (or even __S000) will help create page table entries with
-	 * PROT_NONE permission as required for pxx_protnone_tests().
+	 * protection_map[0] (or even protection_map[8]) will help create
+	 * page table entries with PROT_NONE permission as required for
+	 * pxx_protnone_tests().
 	 */
 	memset(args, 0, sizeof(*args));
 	args->vaddr              = get_random_vaddr();
 	args->page_prot          = vm_get_page_prot(VMFLAGS);
-	args->page_prot_none     = __P000;
+	args->page_prot_none     = protection_map[0];
 	args->is_contiguous_page = false;
 	args->pud_pfn            = ULONG_MAX;
 	args->pmd_pfn            = ULONG_MAX;
author
#2 lore raw

Got it, thanks!

Quoted 56 lines · Anshuman Khandual
Quoted 5 lines · On 9/24/21 11:38 AM, [email protected] wrote:

From: Guo Ren <[email protected]>

The __Pxxx/__Sxxx macros are only for protection_map[] init. All usage of them in linux should come from protection_map array.

Quoted 7 lines

Because a lot of architectures would re-initilize protection_map[] array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.

Using __P000 is not rigorous.

Quoted 36 lines

---

Changes since V2:
- s/init protection_map[]/protection_map[] init/
- s/Becasue/Because/
- Remove unclear part
- Replace __P000 and __S000 with protection_map[0] and protection_map[8]

---
 mm/debug_vm_pgtable.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
mm/debug_vm_pgtable.c +4 -3
index 1403639302e4..228e3954b90c 100644
@@ -1104,13 +1104,14 @@ static int __init init_args(struct pgtable_debug_args *args)
      /*
       * Initialize the debugging data.
       *
-      * __P000 (or even __S000) will help create page table entries with
-      * PROT_NONE permission as required for pxx_protnone_tests().
+      * protection_map[0] (or even protection_map[8]) will help create
+      * page table entries with PROT_NONE permission as required for
+      * pxx_protnone_tests().
       */
      memset(args, 0, sizeof(*args));
      args->vaddr              = get_random_vaddr();
      args->page_prot          = vm_get_page_prot(VMFLAGS);
-     args->page_prot_none     = __P000;
+     args->page_prot_none     = protection_map[0];
      args->is_contiguous_page = false;
      args->pud_pfn            = ULONG_MAX;
      args->pmd_pfn            = ULONG_MAX;
Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/