ARM: mm: fix reporting of read-only PMD bits
PATCH v3 1/1 ARM: mm: fix reporting of read-only PMD bits
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "PMD_SECT_APX | PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.
---
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.
--- arch/arm/mm/dump.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
arch/arm/mm/dump.c +25 -6
@@ -121,23 +121,42 @@ static const struct prot_bits pte_bits[] = {static const struct prot_bits section_bits[] = { #ifndef CONFIG_ARM_LPAE -/* These are approximate */ +# if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7) { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , - .val =0 , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_APX |PMD_SECT_AP_WRITE , .set =" ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_WRITE , .set =" RW" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ , .set ="USR ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .set ="USR RW" , +# else +/* These are approximate */ + { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =0 , + .set =" ro" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_WRITE , + .set =" RW" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ , + .set ="USR ro" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .set ="USR RW" , +# endif #else { .mask =PMD_SECT_USER ,
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security
Quoted 19 lines · Kees Cook
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "
PMD_SECT_APX|PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.Signed-off-by Kees Cook <[email protected]>---
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.--- arch/arm/mm/dump.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)arch/arm/mm/dump.c +0
-0
arch/arm/mm/dump.c static const struct prot_bits pte_bits[] = { · line 124
Quoted 5 lines
arch/arm/mm/dump.c +1
-1@@ -121,23 +121,42 @@ static const struct prot_bits pte_bits[] = {static const struct prot_bits section_bits[] = { #ifndef CONFIG_ARM_LPAE - /* These are approximate */ +# if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
You can simplify the ifdef logic like this:
#ifdef CONFIG_ARM_LPAE /* Implies v7 */
#elif __LINUX_ARM_ARCH__ >= 6
#else
/* v4/v5 */
#endif
Quoted 28 lines · Rob Herring
Quoted 19 lines · Kees Cook
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "
PMD_SECT_APX|PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.Signed-off-by Kees Cook <[email protected]>---
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.--- arch/arm/mm/dump.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)arch/arm/mm/dump.c +0
-0arch/arm/mm/dump.c static const struct prot_bits pte_bits[] = { · line 124
Quoted 5 lines
arch/arm/mm/dump.c +1
-1@@ -121,23 +121,42 @@ static const struct prot_bits pte_bits[] = {static const struct prot_bits section_bits[] = { #ifndef CONFIG_ARM_LPAE - /* These are approximate */ +# if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)You can simplify the ifdef logic like this:
Quoted 7 lines
#ifdef
CONFIG_ARM_LPAE/* Implies v7 */#elif
__LINUX_ARM_ARCH__>= 6#else
/* v4/v5 */
#endif
Ah! Perfect, thanks! I'll resend it this way.
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security