Skip to content

Commit ed41540

Browse files
davidhildenbrandakpm00
authored andcommitted
m68k/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE
Let's support __HAVE_ARCH_PTE_SWP_EXCLUSIVE by stealing one bit from the type. Generic MM currently only uses 5 bits for the type (MAX_SWAPFILES_SHIFT), so the stolen bit is effectively unused. While at it, make sure for sun3 that the valid bit never gets set by properly masking it off and mask the type in __swp_entry(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greg Ungerer <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ad464ff commit ed41540

File tree

3 files changed

+104
-9
lines changed

3 files changed

+104
-9
lines changed

arch/m68k/include/asm/mcf_pgtable.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#define _CACHEMASK040 (~0x060)
4747
#define _PAGE_GLOBAL040 0x400 /* 68040 global bit, used for kva descs */
4848

49+
/* We borrow bit 7 to store the exclusive marker in swap PTEs. */
50+
#define _PAGE_SWP_EXCLUSIVE 0x080
51+
4952
/*
5053
* Externally used page protection values.
5154
*/
@@ -254,15 +257,42 @@ static inline pte_t pte_mkcache(pte_t pte)
254257
extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
255258

256259
/*
257-
* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e))
260+
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
261+
* are !pte_none() && !pte_present().
262+
*
263+
* Format of swap PTEs:
264+
*
265+
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
266+
* 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
267+
* <------------------ offset -------------> 0 0 0 E <-- type --->
268+
*
269+
* E is the exclusive marker that is not stored in swap entries.
258270
*/
259-
#define __swp_type(x) ((x).val & 0xFF)
271+
#define __swp_type(x) ((x).val & 0x7f)
260272
#define __swp_offset(x) ((x).val >> 11)
261-
#define __swp_entry(typ, off) ((swp_entry_t) { (typ) | \
273+
#define __swp_entry(typ, off) ((swp_entry_t) { ((typ) & 0x7f) | \
262274
(off << 11) })
263275
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
264276
#define __swp_entry_to_pte(x) (__pte((x).val))
265277

278+
#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE
279+
static inline int pte_swp_exclusive(pte_t pte)
280+
{
281+
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
282+
}
283+
284+
static inline pte_t pte_swp_mkexclusive(pte_t pte)
285+
{
286+
pte_val(pte) |= _PAGE_SWP_EXCLUSIVE;
287+
return pte;
288+
}
289+
290+
static inline pte_t pte_swp_clear_exclusive(pte_t pte)
291+
{
292+
pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE;
293+
return pte;
294+
}
295+
266296
#define pmd_pfn(pmd) (pmd_val(pmd) >> PAGE_SHIFT)
267297
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
268298

arch/m68k/include/asm/motorola_pgtable.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
#define _PAGE_PROTNONE 0x004
4343

44+
/* We borrow bit 11 to store the exclusive marker in swap PTEs. */
45+
#define _PAGE_SWP_EXCLUSIVE 0x800
46+
4447
#ifndef __ASSEMBLY__
4548

4649
/* This is the cache mode to be used for pages containing page descriptors for
@@ -169,12 +172,41 @@ static inline pte_t pte_mkcache(pte_t pte)
169172
#define swapper_pg_dir kernel_pg_dir
170173
extern pgd_t kernel_pg_dir[128];
171174

172-
/* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) */
173-
#define __swp_type(x) (((x).val >> 4) & 0xff)
175+
/*
176+
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
177+
* are !pte_none() && !pte_present().
178+
*
179+
* Format of swap PTEs:
180+
*
181+
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
182+
* 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
183+
* <----------------- offset ------------> E <-- type ---> 0 0 0 0
184+
*
185+
* E is the exclusive marker that is not stored in swap entries.
186+
*/
187+
#define __swp_type(x) (((x).val >> 4) & 0x7f)
174188
#define __swp_offset(x) ((x).val >> 12)
175-
#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 4) | ((offset) << 12) })
189+
#define __swp_entry(type, offset) ((swp_entry_t) { (((type) & 0x7f) << 4) | ((offset) << 12) })
176190
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
177191
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
178192

193+
#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE
194+
static inline int pte_swp_exclusive(pte_t pte)
195+
{
196+
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
197+
}
198+
199+
static inline pte_t pte_swp_mkexclusive(pte_t pte)
200+
{
201+
pte_val(pte) |= _PAGE_SWP_EXCLUSIVE;
202+
return pte;
203+
}
204+
205+
static inline pte_t pte_swp_clear_exclusive(pte_t pte)
206+
{
207+
pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE;
208+
return pte;
209+
}
210+
179211
#endif /* !__ASSEMBLY__ */
180212
#endif /* _MOTOROLA_PGTABLE_H */

arch/m68k/include/asm/sun3_pgtable.h

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
#define SUN3_PMD_MASK (0x0000003F)
7272
#define SUN3_PMD_MAGIC (0x0000002B)
7373

74+
/* We borrow bit 6 to store the exclusive marker in swap PTEs. */
75+
#define _PAGE_SWP_EXCLUSIVE 0x040
76+
7477
#ifndef __ASSEMBLY__
7578

7679
/*
@@ -152,12 +155,42 @@ static inline pte_t pte_mkcache(pte_t pte) { return pte; }
152155
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
153156
extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
154157

155-
/* Macros to (de)construct the fake PTEs representing swap pages. */
156-
#define __swp_type(x) ((x).val & 0x7F)
158+
/*
159+
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
160+
* are !pte_none() && !pte_present().
161+
*
162+
* Format of swap PTEs:
163+
*
164+
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
165+
* 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
166+
* 0 <--------------------- offset ----------------> E <- type -->
167+
*
168+
* E is the exclusive marker that is not stored in swap entries.
169+
*/
170+
#define __swp_type(x) ((x).val & 0x3f)
157171
#define __swp_offset(x) (((x).val) >> 7)
158-
#define __swp_entry(type,offset) ((swp_entry_t) { ((type) | ((offset) << 7)) })
172+
#define __swp_entry(type, offset) ((swp_entry_t) { (((type) & 0x3f) | \
173+
(((offset) << 7) & ~SUN3_PAGE_VALID)) })
159174
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
160175
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
161176

177+
#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE
178+
static inline int pte_swp_exclusive(pte_t pte)
179+
{
180+
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
181+
}
182+
183+
static inline pte_t pte_swp_mkexclusive(pte_t pte)
184+
{
185+
pte_val(pte) |= _PAGE_SWP_EXCLUSIVE;
186+
return pte;
187+
}
188+
189+
static inline pte_t pte_swp_clear_exclusive(pte_t pte)
190+
{
191+
pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE;
192+
return pte;
193+
}
194+
162195
#endif /* !__ASSEMBLY__ */
163196
#endif /* !_SUN3_PGTABLE_H */

0 commit comments

Comments
 (0)