Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nios2/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE

Let's support __HAVE_ARCH_PTE_SWP_EXCLUSIVE by using the yet-unused bit
31.

Link: https://lkml.kernel.org/r/20230113171026.582290-15-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
4d1d955f 0a9ad827

+24 -1
+3
arch/nios2/include/asm/pgtable-bits.h
··· 31 31 #define _PAGE_ACCESSED (1<<26) /* page referenced */ 32 32 #define _PAGE_DIRTY (1<<27) /* dirty page */ 33 33 34 + /* We borrow bit 31 to store the exclusive marker in swap PTEs. */ 35 + #define _PAGE_SWP_EXCLUSIVE (1<<31) 36 + 34 37 #endif /* _ASM_NIOS2_PGTABLE_BITS_H */
+21 -1
arch/nios2/include/asm/pgtable.h
··· 239 239 * 240 240 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 241 241 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 242 - * 0 < type -> 0 0 0 0 0 0 <-------------- offset ---------------> 242 + * E < type -> 0 0 0 0 0 0 <-------------- offset ---------------> 243 + * 244 + * E is the exclusive marker that is not stored in swap entries. 243 245 * 244 246 * Note that the offset field is always non-zero if the swap type is 0, thus 245 247 * !pte_none() is always true. ··· 252 250 | ((off) & 0xfffff) }) 253 251 #define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) 254 252 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 253 + 254 + #define __HAVE_ARCH_PTE_SWP_EXCLUSIVE 255 + static inline int pte_swp_exclusive(pte_t pte) 256 + { 257 + return pte_val(pte) & _PAGE_SWP_EXCLUSIVE; 258 + } 259 + 260 + static inline pte_t pte_swp_mkexclusive(pte_t pte) 261 + { 262 + pte_val(pte) |= _PAGE_SWP_EXCLUSIVE; 263 + return pte; 264 + } 265 + 266 + static inline pte_t pte_swp_clear_exclusive(pte_t pte) 267 + { 268 + pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE; 269 + return pte; 270 + } 255 271 256 272 extern void __init paging_init(void); 257 273 extern void __init mmu_init(void);