Commit b6d4f280 authored by Laura Abbott's avatar Laura Abbott Committed by Will Deacon

arm64: Introduce {set,clear}_pte_bit

It's useful to be able to change individual bits in ptes at times.
Introduce functions for this and update existing pte_mk* functions
to use these primatives.
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
[will: added missing inline keyword for new header functions]
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 5e051531
...@@ -149,46 +149,51 @@ extern struct page *empty_zero_page; ...@@ -149,46 +149,51 @@ extern struct page *empty_zero_page;
#define pte_valid_not_user(pte) \ #define pte_valid_not_user(pte) \
((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
static inline pte_t pte_wrprotect(pte_t pte) static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
{ {
pte_val(pte) &= ~PTE_WRITE; pte_val(pte) &= ~pgprot_val(prot);
return pte; return pte;
} }
static inline pte_t pte_mkwrite(pte_t pte) static inline pte_t set_pte_bit(pte_t pte, pgprot_t prot)
{ {
pte_val(pte) |= PTE_WRITE; pte_val(pte) |= pgprot_val(prot);
return pte; return pte;
} }
static inline pte_t pte_wrprotect(pte_t pte)
{
return clear_pte_bit(pte, __pgprot(PTE_WRITE));
}
static inline pte_t pte_mkwrite(pte_t pte)
{
return set_pte_bit(pte, __pgprot(PTE_WRITE));
}
static inline pte_t pte_mkclean(pte_t pte) static inline pte_t pte_mkclean(pte_t pte)
{ {
pte_val(pte) &= ~PTE_DIRTY; return clear_pte_bit(pte, __pgprot(PTE_DIRTY));
return pte;
} }
static inline pte_t pte_mkdirty(pte_t pte) static inline pte_t pte_mkdirty(pte_t pte)
{ {
pte_val(pte) |= PTE_DIRTY; return set_pte_bit(pte, __pgprot(PTE_DIRTY));
return pte;
} }
static inline pte_t pte_mkold(pte_t pte) static inline pte_t pte_mkold(pte_t pte)
{ {
pte_val(pte) &= ~PTE_AF; return clear_pte_bit(pte, __pgprot(PTE_AF));
return pte;
} }
static inline pte_t pte_mkyoung(pte_t pte) static inline pte_t pte_mkyoung(pte_t pte)
{ {
pte_val(pte) |= PTE_AF; return set_pte_bit(pte, __pgprot(PTE_AF));
return pte;
} }
static inline pte_t pte_mkspecial(pte_t pte) static inline pte_t pte_mkspecial(pte_t pte)
{ {
pte_val(pte) |= PTE_SPECIAL; return set_pte_bit(pte, __pgprot(PTE_SPECIAL));
return pte;
} }
static inline void set_pte(pte_t *ptep, pte_t pte) static inline void set_pte(pte_t *ptep, pte_t pte)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment