]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/mm: add set_pte_bit()/clear_pte_bit() helper functions
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 21 Feb 2022 20:18:29 +0000 (21:18 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 1 Mar 2022 20:05:10 +0000 (21:05 +0100)
Add set_pte_bit()/clear_pte_bit() and set_pXd_bit()/clear_pXd_bit
helper functions which are supposed to be used if bits within
ptes/pXds are set/cleared.
The only point of these helper functions is to get more readable
code. This is quite similar to what arm64 has.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/pgtable.h

index 2aa8057c7ef88855d1bc6cf3f31929f5c2548a5c..4bbb6d38365fea19595df71aa7e3f7f0c9c18583 100644 (file)
@@ -538,6 +538,36 @@ static inline int mm_alloc_pgste(struct mm_struct *mm)
        return 0;
 }
 
+static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
+{
+       return __pte(pte_val(pte) & ~pgprot_val(prot));
+}
+
+static inline pte_t set_pte_bit(pte_t pte, pgprot_t prot)
+{
+       return __pte(pte_val(pte) | pgprot_val(prot));
+}
+
+static inline pmd_t clear_pmd_bit(pmd_t pmd, pgprot_t prot)
+{
+       return __pmd(pmd_val(pmd) & ~pgprot_val(prot));
+}
+
+static inline pmd_t set_pmd_bit(pmd_t pmd, pgprot_t prot)
+{
+       return __pmd(pmd_val(pmd) | pgprot_val(prot));
+}
+
+static inline pud_t clear_pud_bit(pud_t pud, pgprot_t prot)
+{
+       return __pud(pud_val(pud) & ~pgprot_val(prot));
+}
+
+static inline pud_t set_pud_bit(pud_t pud, pgprot_t prot)
+{
+       return __pud(pud_val(pud) | pgprot_val(prot));
+}
+
 /*
  * In the case that a guest uses storage keys
  * faults should no longer be backed by zero pages