debuggers.hg

view xen/include/asm-x86/x86_32/page.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 46f8fc57b1a4
line source
2 #ifndef __X86_32_PAGE_H__
3 #define __X86_32_PAGE_H__
5 #define L1_PAGETABLE_SHIFT 12
6 #define L2_PAGETABLE_SHIFT 21
7 #define L3_PAGETABLE_SHIFT 30
8 #define PAGE_SHIFT L1_PAGETABLE_SHIFT
9 #define ROOT_PAGETABLE_SHIFT L3_PAGETABLE_SHIFT
11 #define PAGETABLE_ORDER 9
12 #define L1_PAGETABLE_ENTRIES (1<<PAGETABLE_ORDER)
13 #define L2_PAGETABLE_ENTRIES (1<<PAGETABLE_ORDER)
14 #define L3_PAGETABLE_ENTRIES 4
15 #define ROOT_PAGETABLE_ENTRIES L3_PAGETABLE_ENTRIES
17 /*
18 * Architecturally, physical addresses may be up to 52 bits. However, the
19 * page-frame number (pfn) of a 52-bit address will not fit into a 32-bit
20 * word. Instead we treat bits 44-51 of a pte as flag bits which are never
21 * allowed to be set by a guest kernel. This 'limits' us to addressing 16TB
22 * of physical memory on a 32-bit PAE system.
23 */
24 #define PADDR_BITS 44
25 #define PADDR_MASK ((1ULL << PADDR_BITS)-1)
27 #define __PAGE_OFFSET (0xFF000000)
28 #define __XEN_VIRT_START __PAGE_OFFSET
30 #define virt_to_maddr(va) ((unsigned long)(va)-DIRECTMAP_VIRT_START)
31 #define maddr_to_virt(ma) ((void *)((unsigned long)(ma)+DIRECTMAP_VIRT_START))
33 #define VADDR_BITS 32
34 #define VADDR_MASK (~0UL)
36 #define is_canonical_address(x) 1
38 /* Given a virtual address, get an entry offset into a linear page table. */
39 #define l1_linear_offset(_a) ((_a) >> L1_PAGETABLE_SHIFT)
40 #define l2_linear_offset(_a) ((_a) >> L2_PAGETABLE_SHIFT)
42 #ifndef __ASSEMBLY__
44 #include <xen/config.h>
45 #include <asm/types.h>
47 /* read access (should only be used for debug printk's) */
48 typedef u64 intpte_t;
49 #define PRIpte "016llx"
51 typedef struct { intpte_t l1; } l1_pgentry_t;
52 typedef struct { intpte_t l2; } l2_pgentry_t;
53 typedef struct { intpte_t l3; } l3_pgentry_t;
54 typedef l3_pgentry_t root_pgentry_t;
56 extern unsigned int PAGE_HYPERVISOR;
57 extern unsigned int PAGE_HYPERVISOR_NOCACHE;
59 #endif
61 #define pte_read_atomic(ptep) ({ \
62 intpte_t __pte = *(ptep), __npte; \
63 while ( (__npte = cmpxchg(ptep, __pte, __pte)) != __pte ) \
64 __pte = __npte; \
65 __pte; })
66 #define pte_write_atomic(ptep, pte) do { \
67 intpte_t __pte = *(ptep), __npte; \
68 while ( (__npte = cmpxchg(ptep, __pte, (pte))) != __pte ) \
69 __pte = __npte; \
70 } while ( 0 )
71 #define pte_write(ptep, pte) do { \
72 u32 *__ptep_words = (u32 *)(ptep); \
73 __ptep_words[0] = 0; \
74 wmb(); \
75 __ptep_words[1] = (pte) >> 32; \
76 wmb(); \
77 __ptep_words[0] = (pte) >> 0; \
78 } while ( 0 )
80 /* root table */
81 #define root_get_pfn l3e_get_pfn
82 #define root_get_flags l3e_get_flags
83 #define root_get_intpte l3e_get_intpte
84 #define root_empty l3e_empty
85 #define root_from_paddr l3e_from_paddr
86 #define PGT_root_page_table PGT_l3_page_table
88 /* misc */
89 #define is_guest_l1_slot(s) (1)
90 #define is_guest_l2_slot(d,t,s) \
91 ( !((t) & PGT_pae_xen_l2) || \
92 ((s) < (L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES - 1))) )
93 #define is_guest_l3_slot(s) (1)
95 /*
96 * PTE pfn and flags:
97 * 32-bit pfn = (pte[43:12])
98 * 32-bit flags = (pte[63:44],pte[11:0])
99 */
101 #define _PAGE_NX_BIT (1U<<31)
102 #define _PAGE_NX (cpu_has_nx ? _PAGE_NX_BIT : 0)
104 /* Extract flags into 32-bit integer, or turn 32-bit flags into a pte mask. */
105 #define get_pte_flags(x) (((int)((x) >> 32) & ~0xFFF) | ((int)(x) & 0xFFF))
106 #define put_pte_flags(x) (((intpte_t)((x) & ~0xFFF) << 32) | ((x) & 0xFFF))
108 #define GRANT_PTE_FLAGS \
109 (_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_GNTTAB)
111 /*
112 * Disallow unused flag bits plus PAT/PSE, PCD, PWT and GLOBAL.
113 * Permit the NX bit if the hardware supports it.
114 */
115 #define BASE_DISALLOW_MASK (0xFFFFF198U & ~_PAGE_NX)
117 #define L1_DISALLOW_MASK (BASE_DISALLOW_MASK | _PAGE_GNTTAB)
118 #define L2_DISALLOW_MASK (BASE_DISALLOW_MASK)
119 #define L3_DISALLOW_MASK 0xFFFFF1FEU /* must-be-zero */
121 #endif /* __X86_32_PAGE_H__ */
123 /*
124 * Local variables:
125 * mode: C
126 * c-set-style: "BSD"
127 * c-basic-offset: 4
128 * tab-width: 4
129 * indent-tabs-mode: nil
130 * End:
131 */