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

Configure Feed

Select the types of activity you want to include in your feed.

csky: Fixup swapon

Current csky's swappon is broken by wrong swap PTE entry format.
Now redesign the new format for abiv1 & abiv2 and make swappon +
zram work properly on csky machines.

C-SKY PTE has VALID, DIRTY to emulate PRESENT, READ, WRITE, EXEC
attributes. GLOBAL bit is shared by two pages in the same tlb
entry. So we need to keep GLOBAL, VALID, PRESENT zero in swp_pte.

To distinguish PAGE_NONE and swp_pte, we need to use an additional
bit (abiv1 is _PAGE_READ, abiv2 is _PAGE_WRITE).

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Arnd Bergmann <arnd@arndb.de>

Guo Ren af94002b a8fac05a

+52 -9
+22
arch/csky/abiv1/inc/abi/pgtable-bits.h
··· 24 24 #define _CACHE_CACHED _PAGE_CACHE 25 25 #define _CACHE_UNCACHED _PAGE_UNCACHE 26 26 27 + #define _PAGE_PROT_NONE _PAGE_READ 28 + 29 + /* 30 + * Encode and decode a swap entry 31 + * 32 + * Format of swap PTE: 33 + * bit 0: _PAGE_PRESENT (zero) 34 + * bit 1: _PAGE_READ (zero) 35 + * bit 2 - 5: swap type[0 - 3] 36 + * bit 6: _PAGE_GLOBAL (zero) 37 + * bit 7: _PAGE_VALID (zero) 38 + * bit 8: swap type[4] 39 + * bit 9 - 31: swap offset 40 + */ 41 + #define __swp_type(x) ((((x).val >> 2) & 0xf) | \ 42 + (((x).val >> 4) & 0x10)) 43 + #define __swp_offset(x) ((x).val >> 9) 44 + #define __swp_entry(type, offset) ((swp_entry_t) { \ 45 + ((type & 0xf) << 2) | \ 46 + ((type & 0x10) << 4) | \ 47 + ((offset) << 9)}) 48 + 27 49 #define HAVE_ARCH_UNMAPPED_AREA 28 50 29 51 #endif /* __ASM_CSKY_PGTABLE_BITS_H */
+22
arch/csky/abiv2/inc/abi/pgtable-bits.h
··· 24 24 #define _CACHE_CACHED (_PAGE_CACHE | _PAGE_BUF) 25 25 #define _CACHE_UNCACHED (0) 26 26 27 + #define _PAGE_PROT_NONE _PAGE_WRITE 28 + 29 + /* 30 + * Encode and decode a swap entry 31 + * 32 + * Format of swap PTE: 33 + * bit 0: _PAGE_GLOBAL (zero) 34 + * bit 1: _PAGE_VALID (zero) 35 + * bit 2 - 6: swap type 36 + * bit 7 - 8: swap offset[0 - 1] 37 + * bit 9: _PAGE_WRITE (zero) 38 + * bit 10: _PAGE_PRESENT (zero) 39 + * bit 11 - 31: swap offset[2 - 22] 40 + */ 41 + #define __swp_type(x) (((x).val >> 2) & 0x1f) 42 + #define __swp_offset(x) ((((x).val >> 7) & 0x3) | \ 43 + (((x).val >> 9) & 0x7ffffc)) 44 + #define __swp_entry(type, offset) ((swp_entry_t) { \ 45 + ((type & 0x1f) << 2) | \ 46 + ((offset & 0x3) << 7) | \ 47 + ((offset & 0x7ffffc) << 9)}) 48 + 27 49 #endif /* __ASM_CSKY_PGTABLE_BITS_H */
+8 -9
arch/csky/include/asm/pgtable.h
··· 41 41 #define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) \ 42 42 | pgprot_val(prot)) 43 43 44 - #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | \ 45 - _CACHE_MASK) 46 - 47 - #define __swp_type(x) (((x).val >> 4) & 0xff) 48 - #define __swp_offset(x) ((x).val >> 12) 49 - #define __swp_entry(type, offset) ((swp_entry_t) {((type) << 4) | \ 50 - ((offset) << 12) }) 51 44 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 52 45 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 53 46 ··· 54 61 */ 55 62 #define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED) 56 63 57 - #define PAGE_NONE __pgprot(_PAGE_BASE | \ 58 - _CACHE_CACHED) 64 + #define PAGE_NONE __pgprot(_PAGE_PROT_NONE) 59 65 #define PAGE_READ __pgprot(_PAGE_BASE | _PAGE_READ | \ 60 66 _CACHE_CACHED) 61 67 #define PAGE_WRITE __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_WRITE | \ ··· 70 78 _PAGE_WRITE | _PAGE_DIRTY | _PAGE_MODIFIED | \ 71 79 _PAGE_GLOBAL | \ 72 80 _CACHE_UNCACHED | _PAGE_SO) 81 + 82 + #define _PAGE_CHG_MASK (~(unsigned long) \ 83 + (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ 84 + _CACHE_MASK | _PAGE_GLOBAL)) 85 + 86 + #define MAX_SWAPFILES_CHECK() \ 87 + BUILD_BUG_ON(MAX_SWAPFILES_SHIFT != 5) 73 88 74 89 #define __P000 PAGE_NONE 75 90 #define __P001 PAGE_READ