summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2016-04-12 22:20:02 -0400
committerMax Filippov <jcmvbkbc@gmail.com>2016-07-23 23:33:58 -0400
commita9f2fc628e3a26a829fd79aff74eb49839d1e74b (patch)
tree7dad4e57c917757d39bb3470720392ac2b92b335
parentd39af90265feb40ec198c4ca8268724645b4b50e (diff)
xtensa: cleanup MMU setup and kernel layout macros
Make kernel load address explicit, independent of the selected MMU configuration and configurable from Kconfig. Do not restrict it to the first 512MB of the physical address space. Cleanup kernel memory layout macros: - rename VECBASE_RESET_VADDR to VECBASE_VADDR, XC_VADDR to VECTOR_VADDR; - drop VIRTUAL_MEMORY_ADDRESS and LOAD_MEMORY_ADDRESS; - introduce PHYS_OFFSET and use it in __va and __pa definitions; - synchronize MMU/noMMU vectors, drop unused NMI vector; - replace hardcoded vectors offset of 0x3000 with Kconfig symbol. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r--Documentation/xtensa/mmu.txt49
-rw-r--r--arch/xtensa/Kconfig26
-rw-r--r--arch/xtensa/boot/boot-elf/boot.lds.S2
-rw-r--r--arch/xtensa/boot/boot-elf/bootstrap.S7
-rw-r--r--arch/xtensa/boot/boot-uboot/Makefile10
-rw-r--r--arch/xtensa/include/asm/initialize_mmu.h21
-rw-r--r--arch/xtensa/include/asm/kmem_layout.h3
-rw-r--r--arch/xtensa/include/asm/page.h8
-rw-r--r--arch/xtensa/include/asm/vectors.h66
-rw-r--r--arch/xtensa/kernel/entry.S5
-rw-r--r--arch/xtensa/kernel/head.S2
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S4
12 files changed, 98 insertions, 105 deletions
diff --git a/Documentation/xtensa/mmu.txt b/Documentation/xtensa/mmu.txt
index 867c0f837e28..222a2c6748e6 100644
--- a/Documentation/xtensa/mmu.txt
+++ b/Documentation/xtensa/mmu.txt
@@ -3,15 +3,8 @@ MMUv3 initialization sequence.
3The code in the initialize_mmu macro sets up MMUv3 memory mapping 3The code in the initialize_mmu macro sets up MMUv3 memory mapping
4identically to MMUv2 fixed memory mapping. Depending on 4identically to MMUv2 fixed memory mapping. Depending on
5CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is 5CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is
6located in one of the following address ranges: 6located in addresses it was linked for (symbol undefined), or not
7 7(symbol defined), so it needs to be position-independent.
8 0xF0000000..0xFFFFFFFF (will keep same address in MMU v2 layout;
9 typically ROM)
10 0x00000000..0x07FFFFFF (system RAM; this code is actually linked
11 at 0xD0000000..0xD7FFFFFF [cached]
12 or 0xD8000000..0xDFFFFFFF [uncached];
13 in any case, initially runs elsewhere
14 than linked, so have to be careful)
15 8
16The code has the following assumptions: 9The code has the following assumptions:
17 This code fragment is run only on an MMU v3. 10 This code fragment is run only on an MMU v3.
@@ -28,24 +21,26 @@ TLB setup proceeds along the following steps.
28 PA = physical address (two upper nibbles of it); 21 PA = physical address (two upper nibbles of it);
29 pc = physical range that contains this code; 22 pc = physical range that contains this code;
30 23
31After step 2, we jump to virtual address in 0x40000000..0x5fffffff 24After step 2, we jump to virtual address in the range 0x40000000..0x5fffffff
32that corresponds to next instruction to execute in this code. 25or 0x00000000..0x1fffffff, depending on whether the kernel was loaded below
33After step 4, we jump to intended (linked) address of this code. 260x40000000 or above. That address corresponds to next instruction to execute
34 27in this code. After step 4, we jump to intended (linked) address of this code.
35 Step 0 Step1 Step 2 Step3 Step 4 Step5 28The scheme below assumes that the kernel is loaded below 0x40000000.
36 ============ ===== ============ ===== ============ ===== 29
37 VA PA PA VA PA PA VA PA PA 30 Step0 Step1 Step2 Step3 Step4 Step5
38 ------ -- -- ------ -- -- ------ -- -- 31 ===== ===== ===== ===== ===== =====
39 E0..FF -> E0 -> E0 E0..FF -> E0 F0..FF -> F0 -> F0 32 VA PA PA PA PA VA PA PA
40 C0..DF -> C0 -> C0 C0..DF -> C0 E0..EF -> F0 -> F0 33 ------ -- -- -- -- ------ -- --
41 A0..BF -> A0 -> A0 A0..BF -> A0 D8..DF -> 00 -> 00 34 E0..FF -> E0 -> E0 -> E0 F0..FF -> F0 -> F0
42 80..9F -> 80 -> 80 80..9F -> 80 D0..D7 -> 00 -> 00 35 C0..DF -> C0 -> C0 -> C0 E0..EF -> F0 -> F0
43 60..7F -> 60 -> 60 60..7F -> 60 36 A0..BF -> A0 -> A0 -> A0 D8..DF -> 00 -> 00
44 40..5F -> 40 40..5F -> pc -> pc 40..5F -> pc 37 80..9F -> 80 -> 80 -> 80 D0..D7 -> 00 -> 00
45 20..3F -> 20 -> 20 20..3F -> 20 38 60..7F -> 60 -> 60 -> 60
46 00..1F -> 00 -> 00 00..1F -> 00 39 40..5F -> 40 -> pc -> pc 40..5F -> pc
47 40 20..3F -> 20 -> 20 -> 20
48The default location of IO peripherals is above 0xf0000000. This may change 41 00..1F -> 00 -> 00 -> 00
42
43The default location of IO peripherals is above 0xf0000000. This may be changed
49using a "ranges" property in a device tree simple-bus node. See ePAPR 1.1, §6.5 44using a "ranges" property in a device tree simple-bus node. See ePAPR 1.1, §6.5
50for details on the syntax and semantic of simple-bus nodes. The following 45for details on the syntax and semantic of simple-bus nodes. The following
51limitations apply: 46limitations apply:
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index c17496bc37f0..9b1f8c3c8cba 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -249,6 +249,25 @@ config KSEG_PADDR
249 249
250 If unsure, leave the default value here. 250 If unsure, leave the default value here.
251 251
252config KERNEL_LOAD_ADDRESS
253 hex "Kernel load address"
254 default 0x00003000
255 help
256 This is the address where the kernel is loaded.
257 It is virtual address for MMUv2 configurations and physical address
258 for all other configurations.
259
260 If unsure, leave the default value here.
261
262config VECTORS_OFFSET
263 hex "Kernel vectors offset"
264 default 0x00003000
265 help
266 This is the offset of the kernel image from the relocatable vectors
267 base.
268
269 If unsure, leave the default value here.
270
252choice 271choice
253 prompt "KSEG layout" 272 prompt "KSEG layout"
254 depends on MMU 273 depends on MMU
@@ -487,12 +506,7 @@ config DEFAULT_MEM_START
487 used when no physical memory size is passed through DTB or through 506 used when no physical memory size is passed through DTB or through
488 boot parameter from bootloader. 507 boot parameter from bootloader.
489 508
490 In noMMU configuration the following parameters are derived from it: 509 It's also used for TASK_SIZE calculation in noMMU configuration.
491 - kernel load address;
492 - kernel entry point address;
493 - relocatable vectors base address;
494 - uBoot load address;
495 - TASK_SIZE.
496 510
497 If unsure, leave the default value here. 511 If unsure, leave the default value here.
498 512
diff --git a/arch/xtensa/boot/boot-elf/boot.lds.S b/arch/xtensa/boot/boot-elf/boot.lds.S
index e54f2c9df63a..a30993054e9c 100644
--- a/arch/xtensa/boot/boot-elf/boot.lds.S
+++ b/arch/xtensa/boot/boot-elf/boot.lds.S
@@ -23,7 +23,7 @@ SECTIONS
23 *(.ResetVector.text) 23 *(.ResetVector.text)
24 } 24 }
25 25
26 .image KERNELOFFSET: AT (LOAD_MEMORY_ADDRESS) 26 .image KERNELOFFSET: AT (CONFIG_KERNEL_LOAD_ADDRESS)
27 { 27 {
28 _image_start = .; 28 _image_start = .;
29 *(image) 29 *(image)
diff --git a/arch/xtensa/boot/boot-elf/bootstrap.S b/arch/xtensa/boot/boot-elf/bootstrap.S
index e6bf313613cf..b6aa85328ac0 100644
--- a/arch/xtensa/boot/boot-elf/bootstrap.S
+++ b/arch/xtensa/boot/boot-elf/bootstrap.S
@@ -35,7 +35,12 @@ _ResetVector:
35 35
36 .align 4 36 .align 4
37RomInitAddr: 37RomInitAddr:
38 .word LOAD_MEMORY_ADDRESS 38#if defined(CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX) && \
39 XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
40 .word CONFIG_KERNEL_LOAD_ADDRESS
41#else
42 .word KERNELOFFSET
43#endif
39RomBootParam: 44RomBootParam:
40 .word _bootparam 45 .word _bootparam
41_bootparam: 46_bootparam:
diff --git a/arch/xtensa/boot/boot-uboot/Makefile b/arch/xtensa/boot/boot-uboot/Makefile
index 403fcf23405c..0f4c417b4196 100644
--- a/arch/xtensa/boot/boot-uboot/Makefile
+++ b/arch/xtensa/boot/boot-uboot/Makefile
@@ -4,15 +4,7 @@
4# for more details. 4# for more details.
5# 5#
6 6
7ifdef CONFIG_MMU 7UIMAGE_LOADADDR = $(CONFIG_KERNEL_LOAD_ADDRESS)
8ifdef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
9UIMAGE_LOADADDR = 0x00003000
10else
11UIMAGE_LOADADDR = 0xd0003000
12endif
13else
14UIMAGE_LOADADDR = $(shell printf "0x%x" $$(( ${CONFIG_DEFAULT_MEM_START} + 0x3000 )) )
15endif
16UIMAGE_COMPRESSION = gzip 8UIMAGE_COMPRESSION = gzip
17 9
18$(obj)/../uImage: vmlinux.bin.gz FORCE 10$(obj)/../uImage: vmlinux.bin.gz FORCE
diff --git a/arch/xtensa/include/asm/initialize_mmu.h b/arch/xtensa/include/asm/initialize_mmu.h
index 46d4bef61655..42410f253597 100644
--- a/arch/xtensa/include/asm/initialize_mmu.h
+++ b/arch/xtensa/include/asm/initialize_mmu.h
@@ -77,13 +77,16 @@
77 77
78 .align 4 78 .align 4
791: movi a2, 0x10000000 791: movi a2, 0x10000000
80 movi a3, 0x18000000 80
81 add a2, a2, a0 81#if CONFIG_KERNEL_LOAD_ADDRESS < 0x40000000ul
829: bgeu a2, a3, 9b /* PC is out of the expected range */ 82#define TEMP_MAPPING_VADDR 0x40000000
83#else
84#define TEMP_MAPPING_VADDR 0x00000000
85#endif
83 86
84 /* Step 1: invalidate mapping at 0x40000000..0x5FFFFFFF. */ 87 /* Step 1: invalidate mapping at 0x40000000..0x5FFFFFFF. */
85 88
86 movi a2, 0x40000000 | XCHAL_SPANNING_WAY 89 movi a2, TEMP_MAPPING_VADDR | XCHAL_SPANNING_WAY
87 idtlb a2 90 idtlb a2
88 iitlb a2 91 iitlb a2
89 isync 92 isync
@@ -95,14 +98,14 @@
95 srli a3, a0, 27 98 srli a3, a0, 27
96 slli a3, a3, 27 99 slli a3, a3, 27
97 addi a3, a3, CA_BYPASS 100 addi a3, a3, CA_BYPASS
98 addi a7, a2, -1 101 addi a7, a2, 5 - XCHAL_SPANNING_WAY
99 wdtlb a3, a7 102 wdtlb a3, a7
100 witlb a3, a7 103 witlb a3, a7
101 isync 104 isync
102 105
103 slli a4, a0, 5 106 slli a4, a0, 5
104 srli a4, a4, 5 107 srli a4, a4, 5
105 addi a5, a2, -6 108 addi a5, a2, -XCHAL_SPANNING_WAY
106 add a4, a4, a5 109 add a4, a4, a5
107 jx a4 110 jx a4
108 111
@@ -145,19 +148,19 @@
145 witlb a4, a5 148 witlb a4, a5
146#endif 149#endif
147 150
148 movi a5, XCHAL_KIO_CACHED_VADDR + 6 151 movi a5, XCHAL_KIO_CACHED_VADDR + XCHAL_KIO_TLB_WAY
149 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_WRITEBACK 152 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_WRITEBACK
150 wdtlb a4, a5 153 wdtlb a4, a5
151 witlb a4, a5 154 witlb a4, a5
152 155
153 movi a5, XCHAL_KIO_BYPASS_VADDR + 6 156 movi a5, XCHAL_KIO_BYPASS_VADDR + XCHAL_KIO_TLB_WAY
154 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_BYPASS 157 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_BYPASS
155 wdtlb a4, a5 158 wdtlb a4, a5
156 witlb a4, a5 159 witlb a4, a5
157 160
158 isync 161 isync
159 162
160 /* Jump to self, using MMU v2 mappings. */ 163 /* Jump to self, using final mappings. */
161 movi a4, 1f 164 movi a4, 1f
162 jx a4 165 jx a4
163 166
diff --git a/arch/xtensa/include/asm/kmem_layout.h b/arch/xtensa/include/asm/kmem_layout.h
index bfce7ee8efd8..561f8729bcde 100644
--- a/arch/xtensa/include/asm/kmem_layout.h
+++ b/arch/xtensa/include/asm/kmem_layout.h
@@ -29,6 +29,7 @@
29#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x08000000) 29#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x08000000)
30#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x08000000) 30#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x08000000)
31#define XCHAL_KSEG_TLB_WAY 5 31#define XCHAL_KSEG_TLB_WAY 5
32#define XCHAL_KIO_TLB_WAY 6
32 33
33#elif defined(CONFIG_XTENSA_KSEG_256M) 34#elif defined(CONFIG_XTENSA_KSEG_256M)
34 35
@@ -37,6 +38,7 @@
37#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x10000000) 38#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x10000000)
38#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x10000000) 39#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x10000000)
39#define XCHAL_KSEG_TLB_WAY 6 40#define XCHAL_KSEG_TLB_WAY 6
41#define XCHAL_KIO_TLB_WAY 6
40 42
41#elif defined(CONFIG_XTENSA_KSEG_512M) 43#elif defined(CONFIG_XTENSA_KSEG_512M)
42 44
@@ -45,6 +47,7 @@
45#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x20000000) 47#define XCHAL_KSEG_SIZE __XTENSA_UL_CONST(0x20000000)
46#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x10000000) 48#define XCHAL_KSEG_ALIGNMENT __XTENSA_UL_CONST(0x10000000)
47#define XCHAL_KSEG_TLB_WAY 6 49#define XCHAL_KSEG_TLB_WAY 6
50#define XCHAL_KIO_TLB_WAY 6
48 51
49#else 52#else
50#error Unsupported KSEG configuration 53#error Unsupported KSEG configuration
diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h
index 8a02438232c4..3b5a49dbf8b2 100644
--- a/arch/xtensa/include/asm/page.h
+++ b/arch/xtensa/include/asm/page.h
@@ -27,10 +27,12 @@
27 27
28#ifdef CONFIG_MMU 28#ifdef CONFIG_MMU
29#define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR 29#define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
30#define PHYS_OFFSET XCHAL_KSEG_PADDR
30#define MAX_LOW_PFN (PHYS_PFN(XCHAL_KSEG_PADDR) + \ 31#define MAX_LOW_PFN (PHYS_PFN(XCHAL_KSEG_PADDR) + \
31 PHYS_PFN(XCHAL_KSEG_SIZE)) 32 PHYS_PFN(XCHAL_KSEG_SIZE))
32#else 33#else
33#define PAGE_OFFSET __XTENSA_UL_CONST(0) 34#define PAGE_OFFSET __XTENSA_UL_CONST(0)
35#define PHYS_OFFSET __XTENSA_UL_CONST(0)
34#define MAX_LOW_PFN (PHYS_PFN(PLATFORM_DEFAULT_MEM_START) + \ 36#define MAX_LOW_PFN (PHYS_PFN(PLATFORM_DEFAULT_MEM_START) + \
35 PHYS_PFN(PLATFORM_DEFAULT_MEM_SIZE)) 37 PHYS_PFN(PLATFORM_DEFAULT_MEM_SIZE))
36#endif 38#endif
@@ -163,8 +165,10 @@ void copy_user_highpage(struct page *to, struct page *from,
163 165
164#define ARCH_PFN_OFFSET (PLATFORM_DEFAULT_MEM_START >> PAGE_SHIFT) 166#define ARCH_PFN_OFFSET (PLATFORM_DEFAULT_MEM_START >> PAGE_SHIFT)
165 167
166#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) 168#define __pa(x) \
167#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) 169 ((unsigned long) (x) - PAGE_OFFSET + PHYS_OFFSET)
170#define __va(x) \
171 ((void *)((unsigned long) (x) - PHYS_OFFSET + PAGE_OFFSET))
168#define pfn_valid(pfn) \ 172#define pfn_valid(pfn) \
169 ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr) 173 ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
170 174
diff --git a/arch/xtensa/include/asm/vectors.h b/arch/xtensa/include/asm/vectors.h
index 482171051ff0..77d41cc7a688 100644
--- a/arch/xtensa/include/asm/vectors.h
+++ b/arch/xtensa/include/asm/vectors.h
@@ -48,61 +48,42 @@ static inline unsigned long xtensa_get_kio_paddr(void)
48 48
49#if defined(CONFIG_MMU) 49#if defined(CONFIG_MMU)
50 50
51/* Will Become VECBASE */ 51#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
52#define VIRTUAL_MEMORY_ADDRESS XCHAL_KSEG_CACHED_VADDR
53
54/* Image Virtual Start Address */ 52/* Image Virtual Start Address */
55#define KERNELOFFSET (XCHAL_KSEG_CACHED_VADDR + 0x3000) 53#define KERNELOFFSET (XCHAL_KSEG_CACHED_VADDR + \
56 54 CONFIG_KERNEL_LOAD_ADDRESS - \
57#if defined(XCHAL_HAVE_PTP_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY 55 XCHAL_KSEG_PADDR)
58 /* MMU v3 - XCHAL_HAVE_PTP_MMU == 1 */
59 #define LOAD_MEMORY_ADDRESS 0x00003000
60#else 56#else
61 /* MMU V2 - XCHAL_HAVE_PTP_MMU == 0 */ 57#define KERNELOFFSET CONFIG_KERNEL_LOAD_ADDRESS
62 #define LOAD_MEMORY_ADDRESS 0xD0003000
63#endif 58#endif
64 59
65#define RESET_VECTOR1_VADDR (VIRTUAL_MEMORY_ADDRESS + \
66 XCHAL_RESET_VECTOR1_PADDR)
67
68#else /* !defined(CONFIG_MMU) */ 60#else /* !defined(CONFIG_MMU) */
69 /* MMU Not being used - Virtual == Physical */ 61 /* MMU Not being used - Virtual == Physical */
70 62
71 /* VECBASE */ 63/* Location of the start of the kernel text, _start */
72 #define VIRTUAL_MEMORY_ADDRESS (PLATFORM_DEFAULT_MEM_START + 0x2000) 64#define KERNELOFFSET CONFIG_KERNEL_LOAD_ADDRESS
73 65
74 /* Location of the start of the kernel text, _start */
75 #define KERNELOFFSET (PLATFORM_DEFAULT_MEM_START + 0x3000)
76
77 /* Loaded just above possibly live vectors */
78 #define LOAD_MEMORY_ADDRESS (PLATFORM_DEFAULT_MEM_START + 0x3000)
79
80#define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR)
81 66
82#endif /* CONFIG_MMU */ 67#endif /* CONFIG_MMU */
83 68
84#define XC_VADDR(offset) (VIRTUAL_MEMORY_ADDRESS + offset) 69#define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR)
85 70#define VECBASE_VADDR (KERNELOFFSET - CONFIG_VECTORS_OFFSET)
86/* Used to set VECBASE register */
87#define VECBASE_RESET_VADDR VIRTUAL_MEMORY_ADDRESS
88 71
89#if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE 72#if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE
90 73
91#define USER_VECTOR_VADDR XC_VADDR(XCHAL_USER_VECOFS) 74#define VECTOR_VADDR(offset) (VECBASE_VADDR + offset)
92#define KERNEL_VECTOR_VADDR XC_VADDR(XCHAL_KERNEL_VECOFS)
93#define DOUBLEEXC_VECTOR_VADDR XC_VADDR(XCHAL_DOUBLEEXC_VECOFS)
94#define WINDOW_VECTORS_VADDR XC_VADDR(XCHAL_WINDOW_OF4_VECOFS)
95#define INTLEVEL2_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL2_VECOFS)
96#define INTLEVEL3_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL3_VECOFS)
97#define INTLEVEL4_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL4_VECOFS)
98#define INTLEVEL5_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL5_VECOFS)
99#define INTLEVEL6_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL6_VECOFS)
100
101#define DEBUG_VECTOR_VADDR XC_VADDR(XCHAL_DEBUG_VECOFS)
102 75
103#define NMI_VECTOR_VADDR XC_VADDR(XCHAL_NMI_VECOFS) 76#define USER_VECTOR_VADDR VECTOR_VADDR(XCHAL_USER_VECOFS)
104 77#define KERNEL_VECTOR_VADDR VECTOR_VADDR(XCHAL_KERNEL_VECOFS)
105#define INTLEVEL7_VECTOR_VADDR XC_VADDR(XCHAL_INTLEVEL7_VECOFS) 78#define DOUBLEEXC_VECTOR_VADDR VECTOR_VADDR(XCHAL_DOUBLEEXC_VECOFS)
79#define WINDOW_VECTORS_VADDR VECTOR_VADDR(XCHAL_WINDOW_OF4_VECOFS)
80#define INTLEVEL2_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL2_VECOFS)
81#define INTLEVEL3_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL3_VECOFS)
82#define INTLEVEL4_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL4_VECOFS)
83#define INTLEVEL5_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL5_VECOFS)
84#define INTLEVEL6_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL6_VECOFS)
85#define INTLEVEL7_VECTOR_VADDR VECTOR_VADDR(XCHAL_INTLEVEL7_VECOFS)
86#define DEBUG_VECTOR_VADDR VECTOR_VADDR(XCHAL_DEBUG_VECOFS)
106 87
107/* 88/*
108 * These XCHAL_* #defines from varian/core.h 89 * These XCHAL_* #defines from varian/core.h
@@ -110,7 +91,6 @@ static inline unsigned long xtensa_get_kio_paddr(void)
110 * constants are defined above and should be used. 91 * constants are defined above and should be used.
111 */ 92 */
112#undef XCHAL_VECBASE_RESET_VADDR 93#undef XCHAL_VECBASE_RESET_VADDR
113#undef XCHAL_RESET_VECTOR0_VADDR
114#undef XCHAL_USER_VECTOR_VADDR 94#undef XCHAL_USER_VECTOR_VADDR
115#undef XCHAL_KERNEL_VECTOR_VADDR 95#undef XCHAL_KERNEL_VECTOR_VADDR
116#undef XCHAL_DOUBLEEXC_VECTOR_VADDR 96#undef XCHAL_DOUBLEEXC_VECTOR_VADDR
@@ -120,9 +100,8 @@ static inline unsigned long xtensa_get_kio_paddr(void)
120#undef XCHAL_INTLEVEL4_VECTOR_VADDR 100#undef XCHAL_INTLEVEL4_VECTOR_VADDR
121#undef XCHAL_INTLEVEL5_VECTOR_VADDR 101#undef XCHAL_INTLEVEL5_VECTOR_VADDR
122#undef XCHAL_INTLEVEL6_VECTOR_VADDR 102#undef XCHAL_INTLEVEL6_VECTOR_VADDR
123#undef XCHAL_DEBUG_VECTOR_VADDR
124#undef XCHAL_NMI_VECTOR_VADDR
125#undef XCHAL_INTLEVEL7_VECTOR_VADDR 103#undef XCHAL_INTLEVEL7_VECTOR_VADDR
104#undef XCHAL_DEBUG_VECTOR_VADDR
126 105
127#else 106#else
128 107
@@ -135,6 +114,7 @@ static inline unsigned long xtensa_get_kio_paddr(void)
135#define INTLEVEL4_VECTOR_VADDR XCHAL_INTLEVEL4_VECTOR_VADDR 114#define INTLEVEL4_VECTOR_VADDR XCHAL_INTLEVEL4_VECTOR_VADDR
136#define INTLEVEL5_VECTOR_VADDR XCHAL_INTLEVEL5_VECTOR_VADDR 115#define INTLEVEL5_VECTOR_VADDR XCHAL_INTLEVEL5_VECTOR_VADDR
137#define INTLEVEL6_VECTOR_VADDR XCHAL_INTLEVEL6_VECTOR_VADDR 116#define INTLEVEL6_VECTOR_VADDR XCHAL_INTLEVEL6_VECTOR_VADDR
117#define INTLEVEL7_VECTOR_VADDR XCHAL_INTLEVEL6_VECTOR_VADDR
138#define DEBUG_VECTOR_VADDR XCHAL_DEBUG_VECTOR_VADDR 118#define DEBUG_VECTOR_VADDR XCHAL_DEBUG_VECTOR_VADDR
139 119
140#endif 120#endif
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index fe8f7e7efb9d..fa04d9d368a7 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1632,10 +1632,11 @@ ENTRY(fast_second_level_miss)
1632 * The messy computation for 'pteval' above really simplifies 1632 * The messy computation for 'pteval' above really simplifies
1633 * into the following: 1633 * into the following:
1634 * 1634 *
1635 * pteval = ((pmdval - PAGE_OFFSET) & PAGE_MASK) | PAGE_DIRECTORY 1635 * pteval = ((pmdval - PAGE_OFFSET + PHYS_OFFSET) & PAGE_MASK)
1636 * | PAGE_DIRECTORY
1636 */ 1637 */
1637 1638
1638 movi a1, (-PAGE_OFFSET) & 0xffffffff 1639 movi a1, (PHYS_OFFSET - PAGE_OFFSET) & 0xffffffff
1639 add a0, a0, a1 # pmdval - PAGE_OFFSET 1640 add a0, a0, a1 # pmdval - PAGE_OFFSET
1640 extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK 1641 extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK
1641 xor a0, a0, a1 1642 xor a0, a0, a1
diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S
index bc4f4bf05099..23ce62e60435 100644
--- a/arch/xtensa/kernel/head.S
+++ b/arch/xtensa/kernel/head.S
@@ -113,7 +113,7 @@ ENTRY(_startup)
113 movi a0, 0 113 movi a0, 0
114 114
115#if XCHAL_HAVE_VECBASE 115#if XCHAL_HAVE_VECBASE
116 movi a2, VECBASE_RESET_VADDR 116 movi a2, VECBASE_VADDR
117 wsr a2, vecbase 117 wsr a2, vecbase
118#endif 118#endif
119 119
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index c417cbe4ec87..72cfe3587dd8 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -30,10 +30,6 @@ jiffies = jiffies_64 + 4;
30jiffies = jiffies_64; 30jiffies = jiffies_64;
31#endif 31#endif
32 32
33#ifndef KERNELOFFSET
34#define KERNELOFFSET 0xd0003000
35#endif
36
37/* Note: In the following macros, it would be nice to specify only the 33/* Note: In the following macros, it would be nice to specify only the
38 vector name and section kind and construct "sym" and "section" using 34 vector name and section kind and construct "sym" and "section" using
39 CPP concatenation, but that does not work reliably. Concatenating a 35 CPP concatenation, but that does not work reliably. Concatenating a