diff options
author | David S. Miller <davem@davemloft.net> | 2013-09-18 18:39:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-12 18:22:34 -0500 |
commit | bb7b435388b9f035ecfb16f42b5c6bf428359c63 (patch) | |
tree | 5e64fe2772da7d787f88a6e7854db642c2dc2bb1 /arch/sparc | |
parent | e0a45e3580a033669b24b04c3535515d69bb9702 (diff) |
sparc64: Document the shift counts used to validate linear kernel addresses.
This way we can see exactly what they are derived from, and in particular
how they would change if we were to use a different PAGE_OFFSET value.
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Bob Picco <bob.picco@oracle.com>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/page_64.h | 16 | ||||
-rw-r--r-- | arch/sparc/kernel/ktlb.S | 10 | ||||
-rw-r--r-- | arch/sparc/mm/init_64.h | 4 |
3 files changed, 24 insertions, 6 deletions
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h index 9dd0f7360822..978ea6d022e9 100644 --- a/arch/sparc/include/asm/page_64.h +++ b/arch/sparc/include/asm/page_64.h | |||
@@ -121,6 +121,22 @@ typedef pte_t *pgtable_t; | |||
121 | #define PAGE_OFFSET_BY_BITS(X) (-(_AC(1,UL) << (X))) | 121 | #define PAGE_OFFSET_BY_BITS(X) (-(_AC(1,UL) << (X))) |
122 | #define PAGE_OFFSET PAGE_OFFSET_BY_BITS(MAX_SUPPORTED_PA_BITS) | 122 | #define PAGE_OFFSET PAGE_OFFSET_BY_BITS(MAX_SUPPORTED_PA_BITS) |
123 | 123 | ||
124 | /* The "virtual" portion of PAGE_OFFSET, used to clip off the non-physical | ||
125 | * bits of a linear kernel address. | ||
126 | */ | ||
127 | #define PAGE_OFFSET_VA_BITS (64 - MAX_SUPPORTED_PA_BITS) | ||
128 | |||
129 | /* The actual number of physical memory address bits we support, this is | ||
130 | * used to size various tables used to manage kernel TLB misses. | ||
131 | */ | ||
132 | #define MAX_PHYS_ADDRESS_BITS 41 | ||
133 | |||
134 | /* These two shift counts are used when indexing sparc64_valid_addr_bitmap | ||
135 | * and kpte_linear_bitmap. | ||
136 | */ | ||
137 | #define ILOG2_4MB 22 | ||
138 | #define ILOG2_256MB 28 | ||
139 | |||
124 | #ifndef __ASSEMBLY__ | 140 | #ifndef __ASSEMBLY__ |
125 | 141 | ||
126 | #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) | 142 | #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) |
diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S index fde5a419cf27..7ad46bc0c698 100644 --- a/arch/sparc/kernel/ktlb.S +++ b/arch/sparc/kernel/ktlb.S | |||
@@ -153,12 +153,12 @@ kvmap_dtlb_tsb4m_miss: | |||
153 | /* Clear the PAGE_OFFSET top virtual bits, shift | 153 | /* Clear the PAGE_OFFSET top virtual bits, shift |
154 | * down to get PFN, and make sure PFN is in range. | 154 | * down to get PFN, and make sure PFN is in range. |
155 | */ | 155 | */ |
156 | sllx %g4, 21, %g5 | 156 | sllx %g4, PAGE_OFFSET_VA_BITS, %g5 |
157 | 157 | ||
158 | /* Check to see if we know about valid memory at the 4MB | 158 | /* Check to see if we know about valid memory at the 4MB |
159 | * chunk this physical address will reside within. | 159 | * chunk this physical address will reside within. |
160 | */ | 160 | */ |
161 | srlx %g5, 21 + 41, %g2 | 161 | srlx %g5, PAGE_OFFSET_VA_BITS + MAX_PHYS_ADDRESS_BITS, %g2 |
162 | brnz,pn %g2, kvmap_dtlb_longpath | 162 | brnz,pn %g2, kvmap_dtlb_longpath |
163 | nop | 163 | nop |
164 | 164 | ||
@@ -176,7 +176,7 @@ valid_addr_bitmap_patch: | |||
176 | or %g7, %lo(sparc64_valid_addr_bitmap), %g7 | 176 | or %g7, %lo(sparc64_valid_addr_bitmap), %g7 |
177 | .previous | 177 | .previous |
178 | 178 | ||
179 | srlx %g5, 21 + 22, %g2 | 179 | srlx %g5, PAGE_OFFSET_VA_BITS + ILOG2_4MB, %g2 |
180 | srlx %g2, 6, %g5 | 180 | srlx %g2, 6, %g5 |
181 | and %g2, 63, %g2 | 181 | and %g2, 63, %g2 |
182 | sllx %g5, 3, %g5 | 182 | sllx %g5, 3, %g5 |
@@ -189,9 +189,9 @@ valid_addr_bitmap_patch: | |||
189 | 2: sethi %hi(kpte_linear_bitmap), %g2 | 189 | 2: sethi %hi(kpte_linear_bitmap), %g2 |
190 | 190 | ||
191 | /* Get the 256MB physical address index. */ | 191 | /* Get the 256MB physical address index. */ |
192 | sllx %g4, 21, %g5 | 192 | sllx %g4, PAGE_OFFSET_VA_BITS, %g5 |
193 | or %g2, %lo(kpte_linear_bitmap), %g2 | 193 | or %g2, %lo(kpte_linear_bitmap), %g2 |
194 | srlx %g5, 21 + 28, %g5 | 194 | srlx %g5, PAGE_OFFSET_VA_BITS + ILOG2_256MB, %g5 |
195 | and %g5, (32 - 1), %g7 | 195 | and %g5, (32 - 1), %g7 |
196 | 196 | ||
197 | /* Divide by 32 to get the offset into the bitmask. */ | 197 | /* Divide by 32 to get the offset into the bitmask. */ |
diff --git a/arch/sparc/mm/init_64.h b/arch/sparc/mm/init_64.h index 0661aa606dec..5d3782deb403 100644 --- a/arch/sparc/mm/init_64.h +++ b/arch/sparc/mm/init_64.h | |||
@@ -1,11 +1,13 @@ | |||
1 | #ifndef _SPARC64_MM_INIT_H | 1 | #ifndef _SPARC64_MM_INIT_H |
2 | #define _SPARC64_MM_INIT_H | 2 | #define _SPARC64_MM_INIT_H |
3 | 3 | ||
4 | #include <asm/page.h> | ||
5 | |||
4 | /* Most of the symbols in this file are defined in init.c and | 6 | /* Most of the symbols in this file are defined in init.c and |
5 | * marked non-static so that assembler code can get at them. | 7 | * marked non-static so that assembler code can get at them. |
6 | */ | 8 | */ |
7 | 9 | ||
8 | #define MAX_PHYS_ADDRESS (1UL << 41UL) | 10 | #define MAX_PHYS_ADDRESS (1UL << MAX_PHYS_ADDRESS_BITS) |
9 | #define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) | 11 | #define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) |
10 | #define KPTE_BITMAP_BYTES \ | 12 | #define KPTE_BITMAP_BYTES \ |
11 | ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 4) | 13 | ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 4) |