mm: debug_vm_pgtable: Don't use __P000 directly
PATCH 1/1 mm: debug_vm_pgtable: Don't use __P000 directly
From: Guo Ren <[email protected]>
The __Pxxx/__Sxxx macros are only for init protection_map[]. All usage of them in linux should come from protection_map array.
Becasue a lot of architectures would re-initilize protection_map[] array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.
Using __P000 maybe won't cause bug because hw would deny access with PROT_NONE permission, but it's not rigorous.
--- mm/debug_vm_pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/debug_vm_pgtable.c +2 -2
@@ -1104,13 +1104,13 @@ 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 +* __P000 (protection_map[0]) 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
Hello Guo,
Quoted 3 lines · On 9/22/21 1:48 AM, [email protected] wrote:
From: Guo Ren <[email protected]>
The __Pxxx/__Sxxx macros are only for init protection_map[]. All
s/init protection_map[]/protection_map[] int/
Or rephrase with something similar.
Quoted 1 line
usage of them in linux should come from
protection_maparray.
Agreed.
Quoted 2 lines
Becasue a lot of architectures would re-initilize protection_map[]
s/Becasue/Because/
./scripts/checkpatch.pl ./0001-mm-debug_vm_pgtable-Don-t-use-__P000-directly.patch
WARNING: 'Becasue' may be misspelled - perhaps 'Because'?
#9:
Becasue a lot of architectures would re-initilize protection_map[] ^^^^^^^
total: 0 errors, 1 warnings, 15 lines checked
Quoted 3 lines
array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.
Using
__P000maybe won't cause bug because hw would deny access
Not very clear. Could you please rephrase.
Quoted 1 line
with
PROT_NONEpermission, but it's not rigorous.
Agreed.
Quoted 12 lines
Signed-off-by Guo Ren <[email protected]>Cc Andrew Morton <[email protected]>--- mm/debug_vm_pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/debug_vm_pgtable.c +0
-0
mm/debug_vm_pgtable.c static int __init init_args(struct pgtable_debug_args *args) · line 1107
Quoted 5 lines
mm/debug_vm_pgtable.c +1
-1@@ -1104,13 +1104,13 @@ 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 +* __P000 (protection_map[0]) will help create page table entries with
Please just replace __P000 and __S000 with protection_map[0] and protection_map[8] respectively. Also reformat this comment section if required.
mm/debug_vm_pgtable.c static int __init init_args(struct pgtable_debug_args *args) · line 1116
Quoted 11 lines
mm/debug_vm_pgtable.c +1
-1* 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 ;
With the above changes in place.
Quoted 9 lines · Anshuman Khandual
Hello Guo,
Quoted 3 lines · On 9/22/21 1:48 AM, [email protected] wrote:
From: Guo Ren <[email protected]>
The __Pxxx/__Sxxx macros are only for init protection_map[]. All
s/init protection_map[]/protection_map[] int/
^^^
Okay, protection_map[] init
Quoted 12 lines
Or rephrase with something similar.
Quoted 1 line
usage of them in linux should come from
protection_maparray.Agreed.
Quoted 2 lines
Becasue a lot of architectures would re-initilize protection_map[]
s/Becasue/Because/
Quoted 7 lines
./scripts/checkpatch.pl./0001-mm-debug_vm_pgtable-Don-t-use-__P000-directly.patch
WARNING: 'Becasue' may be misspelled - perhaps 'Because'?
#9:
Becasue a lot of architectures would re-initilize protection_map[] ^^^^^^^total: 0 errors, 1 warnings, 15 lines checked
I would use checkpatch.pl next time, thx.
Quoted 6 lines
Quoted 4 lines
array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc.
Using
__P000maybe won't cause bug because hw would deny accessNot very clear. Could you please rephrase.
Using __P000 directly wouldn't equal protection_map[0] in many arches, but the reason why it didn't cause the problem is the hardware ignores the other bits when prot-attribute is denied.
Quoted 42 lines
Quoted 2 lines
with
PROT_NONEpermission, but it's not rigorous.Agreed.
Quoted 12 lines
Signed-off-by Guo Ren <[email protected]>Cc Andrew Morton <[email protected]>--- mm/debug_vm_pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/debug_vm_pgtable.c +0
-0mm/debug_vm_pgtable.c static int __init init_args(struct pgtable_debug_args *args) · line 1107
Quoted 5 lines
mm/debug_vm_pgtable.c +1
-1@@ -1104,13 +1104,13 @@ 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 +* __P000 (protection_map[0]) will help create page table entries with Please just replace
__P000and__S000with protection_map[0] and protection_map[8] respectively. Also reformat this comment section if required.mm/debug_vm_pgtable.c static int __init init_args(struct pgtable_debug_args *args) · line 1116
Quoted 11 lines
mm/debug_vm_pgtable.c +1
-1* 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 ;With the above changes in place.
Reviewed-by Anshuman Khandual <[email protected]>
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/