Skip to content

Commit dbf62d5

Browse files
committed
ARM: mm: introduce L_PTE_VALID for page table entries
For long-descriptor translation table formats, the ARMv7 architecture defines the last two bits of the second- and third-level descriptors to be: x0b - Invalid 01b - Block (second-level), Reserved (third-level) 11b - Table (second-level), Page (third-level) This allows us to define L_PTE_PRESENT as (3 << 0) and use this value to create ptes directly. However, when determining whether a given pte value is present in the low-level page table accessors, we only need to check the least significant bit of the descriptor, allowing us to write faulting, present entries which are required for PROT_NONE mappings. This patch introduces L_PTE_VALID, which can be used to test whether a pte should fault, and updates the low-level page table accessors accordingly. Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 0cbbbad commit dbf62d5

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

arch/arm/include/asm/pgtable-2level.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
* The PTE table pointer refers to the hardware entries; the "Linux"
116116
* entries are stored 1024 bytes below.
117117
*/
118+
#define L_PTE_VALID (_AT(pteval_t, 1) << 0) /* Valid */
118119
#define L_PTE_PRESENT (_AT(pteval_t, 1) << 0)
119120
#define L_PTE_YOUNG (_AT(pteval_t, 1) << 1)
120121
#define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */

arch/arm/include/asm/pgtable-3level.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
* These bits overlap with the hardware bits but the naming is preserved for
6868
* consistency with the classic page table format.
6969
*/
70-
#define L_PTE_PRESENT (_AT(pteval_t, 3) << 0) /* Valid */
70+
#define L_PTE_VALID (_AT(pteval_t, 1) << 0) /* Valid */
71+
#define L_PTE_PRESENT (_AT(pteval_t, 3) << 0) /* Present */
7172
#define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */
7273
#define L_PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */
7374
#define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */

arch/arm/include/asm/pgtable.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
203203
#define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN))
204204
#define pte_special(pte) (0)
205205

206-
#define pte_present_user(pte) \
207-
((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
208-
(L_PTE_PRESENT | L_PTE_USER))
206+
#define pte_present_user(pte) (pte_present(pte) && (pte_val(pte) & L_PTE_USER))
209207

210208
#if __LINUX_ARM_ARCH__ < 6
211209
static inline void __sync_icache_dcache(pte_t pteval)

arch/arm/mm/proc-v7-2level.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ENTRY(cpu_v7_set_pte_ext)
100100
orrne r3, r3, #PTE_EXT_XN
101101

102102
tst r1, #L_PTE_YOUNG
103-
tstne r1, #L_PTE_PRESENT
103+
tstne r1, #L_PTE_VALID
104104
moveq r3, #0
105105

106106
ARM( str r3, [r0, #2048]! )

arch/arm/mm/proc-v7-3level.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ENDPROC(cpu_v7_switch_mm)
6565
*/
6666
ENTRY(cpu_v7_set_pte_ext)
6767
#ifdef CONFIG_MMU
68-
tst r2, #L_PTE_PRESENT
68+
tst r2, #L_PTE_VALID
6969
beq 1f
7070
tst r3, #1 << (55 - 32) @ L_PTE_DIRTY
7171
orreq r2, #L_PTE_RDONLY

0 commit comments

Comments
 (0)