|
58 | 58 | #define _PAGE_ED (__IA64_UL(1) << 52) /* exception deferral */
|
59 | 59 | #define _PAGE_PROTNONE (__IA64_UL(1) << 63)
|
60 | 60 |
|
| 61 | +/* We borrow bit 7 to store the exclusive marker in swap PTEs. */ |
| 62 | +#define _PAGE_SWP_EXCLUSIVE (1 << 7) |
| 63 | + |
61 | 64 | #define _PFN_MASK _PAGE_PPN_MASK
|
62 | 65 | /* Mask of bits which may be changed by pte_modify(); the odd bits are there for _PAGE_PROTNONE */
|
63 | 66 | #define _PAGE_CHG_MASK (_PAGE_P | _PAGE_PROTNONE | _PAGE_PL_MASK | _PAGE_AR_MASK | _PAGE_ED)
|
@@ -399,23 +402,46 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
|
399 | 402 | extern void paging_init (void);
|
400 | 403 |
|
401 | 404 | /*
|
| 405 | + * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that |
| 406 | + * are !pte_none() && !pte_present(). |
| 407 | + * |
402 | 408 | * Note: The macros below rely on the fact that MAX_SWAPFILES_SHIFT <= number of
|
403 | 409 | * bits in the swap-type field of the swap pte. It would be nice to
|
404 | 410 | * enforce that, but we can't easily include <linux/swap.h> here.
|
405 | 411 | * (Of course, better still would be to define MAX_SWAPFILES_SHIFT here...).
|
406 | 412 | *
|
407 | 413 | * Format of swap pte:
|
408 | 414 | * bit 0 : present bit (must be zero)
|
409 |
| - * bits 1- 7: swap-type |
| 415 | + * bits 1- 6: swap type |
| 416 | + * bit 7 : exclusive marker |
410 | 417 | * bits 8-62: swap offset
|
411 | 418 | * bit 63 : _PAGE_PROTNONE bit
|
412 | 419 | */
|
413 |
| -#define __swp_type(entry) (((entry).val >> 1) & 0x7f) |
| 420 | +#define __swp_type(entry) (((entry).val >> 1) & 0x3f) |
414 | 421 | #define __swp_offset(entry) (((entry).val << 1) >> 9)
|
415 |
| -#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 1) | ((long) (offset) << 8) }) |
| 422 | +#define __swp_entry(type, offset) ((swp_entry_t) { ((type & 0x3f) << 1) | \ |
| 423 | + ((long) (offset) << 8) }) |
416 | 424 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
|
417 | 425 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
|
418 | 426 |
|
| 427 | +#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE |
| 428 | +static inline int pte_swp_exclusive(pte_t pte) |
| 429 | +{ |
| 430 | + return pte_val(pte) & _PAGE_SWP_EXCLUSIVE; |
| 431 | +} |
| 432 | + |
| 433 | +static inline pte_t pte_swp_mkexclusive(pte_t pte) |
| 434 | +{ |
| 435 | + pte_val(pte) |= _PAGE_SWP_EXCLUSIVE; |
| 436 | + return pte; |
| 437 | +} |
| 438 | + |
| 439 | +static inline pte_t pte_swp_clear_exclusive(pte_t pte) |
| 440 | +{ |
| 441 | + pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE; |
| 442 | + return pte; |
| 443 | +} |
| 444 | + |
419 | 445 | /*
|
420 | 446 | * ZERO_PAGE is a global shared page that is always zero: used
|
421 | 447 | * for zero-mapped memory areas etc..
|
|
0 commit comments