Skip to content

Commit c61c48d

Browse files
committed
Merge tag 'xtensa-next-20130508' of git://github.com/czankel/xtensa-linux
Pull xtensa updates from Chris Zankel: "Support for the latest MMU architecture that allows for a larger accessible memory region, and various bug-fixes" * tag 'xtensa-next-20130508' of git://github.com/czankel/xtensa-linux: xtensa: Switch to asm-generic/linkage.h xtensa: fix redboot load address xtensa: ISS: fix timer_lock usage in rs_open xtensa: disable IRQs while IRQ handler is running xtensa: enable lockdep support xtensa: fix arch_irqs_disabled_flags implementation xtensa: add irq flags trace support xtensa: provide custom CALLER_ADDR* implementations xtensa: add stacktrace support xtensa: clean up stpill_registers xtensa: don't use a7 in simcalls xtensa: don't attempt to use unconfigured timers xtensa: provide default platform_pcibios_init implementation xtensa: remove KCORE_ELF again xtensa: document MMUv3 setup sequence xtensa: add MMU v3 support xtensa: fix ibreakenable register update xtensa: fix oprofile building as module
2 parents e30f419 + b341d84 commit c61c48d

33 files changed

Lines changed: 819 additions & 254 deletions

File tree

‎Documentation/xtensa/mmu.txt‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
MMUv3 initialization sequence.
2+
3+
The code in the initialize_mmu macro sets up MMUv3 memory mapping
4+
identically to MMUv2 fixed memory mapping. Depending on
5+
CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is
6+
located in one of the following address ranges:
7+
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+
16+
The code has the following assumptions:
17+
This code fragment is run only on an MMU v3.
18+
TLBs are in their reset state.
19+
ITLBCFG and DTLBCFG are zero (reset state).
20+
RASID is 0x04030201 (reset state).
21+
PS.RING is zero (reset state).
22+
LITBASE is zero (reset state, PC-relative literals); required to be PIC.
23+
24+
TLB setup proceeds along the following steps.
25+
26+
Legend:
27+
VA = virtual address (two upper nibbles of it);
28+
PA = physical address (two upper nibbles of it);
29+
pc = physical range that contains this code;
30+
31+
After step 2, we jump to virtual address in 0x40000000..0x5fffffff
32+
that corresponds to next instruction to execute in this code.
33+
After step 4, we jump to intended (linked) address of this code.
34+
35+
Step 0 Step1 Step 2 Step3 Step 4 Step5
36+
============ ===== ============ ===== ============ =====
37+
VA PA PA VA PA PA VA PA PA
38+
------ -- -- ------ -- -- ------ -- --
39+
E0..FF -> E0 -> E0 E0..FF -> E0 F0..FF -> F0 -> F0
40+
C0..DF -> C0 -> C0 C0..DF -> C0 E0..EF -> F0 -> F0
41+
A0..BF -> A0 -> A0 A0..BF -> A0 D8..DF -> 00 -> 00
42+
80..9F -> 80 -> 80 80..9F -> 80 D0..D7 -> 00 -> 00
43+
60..7F -> 60 -> 60 60..7F -> 60
44+
40..5F -> 40 40..5F -> pc -> pc 40..5F -> pc
45+
20..3F -> 20 -> 20 20..3F -> 20
46+
00..1F -> 00 -> 00 00..1F -> 00

‎arch/xtensa/Kconfig‎

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
config FRAME_POINTER
2-
def_bool n
3-
41
config ZONE_DMA
52
def_bool y
63

74
config XTENSA
85
def_bool y
6+
select ARCH_WANT_FRAME_POINTERS
97
select HAVE_IDE
108
select GENERIC_ATOMIC64
119
select HAVE_GENERIC_HARDIRQS
@@ -49,6 +47,15 @@ config HZ
4947
source "init/Kconfig"
5048
source "kernel/Kconfig.freezer"
5149

50+
config LOCKDEP_SUPPORT
51+
def_bool y
52+
53+
config STACKTRACE_SUPPORT
54+
def_bool y
55+
56+
config TRACE_IRQFLAGS_SUPPORT
57+
def_bool y
58+
5259
config MMU
5360
def_bool n
5461

@@ -100,6 +107,35 @@ config MATH_EMULATION
100107
help
101108
Can we use information of configuration file?
102109

110+
config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
111+
bool "Initialize Xtensa MMU inside the Linux kernel code"
112+
default y
113+
help
114+
Earlier version initialized the MMU in the exception vector
115+
before jumping to _startup in head.S and had an advantage that
116+
it was possible to place a software breakpoint at 'reset' and
117+
then enter your normal kernel breakpoints once the MMU was mapped
118+
to the kernel mappings (0XC0000000).
119+
120+
This unfortunately doesn't work for U-Boot and likley also wont
121+
work for using KEXEC to have a hot kernel ready for doing a
122+
KDUMP.
123+
124+
So now the MMU is initialized in head.S but it's necessary to
125+
use hardware breakpoints (gdb 'hbreak' cmd) to break at _startup.
126+
xt-gdb can't place a Software Breakpoint in the 0XD region prior
127+
to mapping the MMU and after mapping even if the area of low memory
128+
was mapped gdb wouldn't remove the breakpoint on hitting it as the
129+
PC wouldn't match. Since Hardware Breakpoints are recommended for
130+
Linux configurations it seems reasonable to just assume they exist
131+
and leave this older mechanism for unfortunate souls that choose
132+
not to follow Tensilica's recommendation.
133+
134+
Selecting this will cause U-Boot to set the KERNEL Load and Entry
135+
address at 0x00003000 instead of the mapped std of 0xD0003000.
136+
137+
If in doubt, say Y.
138+
103139
endmenu
104140

105141
config XTENSA_CALIBRATE_CCOUNT
@@ -249,21 +285,6 @@ endmenu
249285

250286
menu "Executable file formats"
251287

252-
# only elf supported
253-
config KCORE_ELF
254-
def_bool y
255-
depends on PROC_FS
256-
help
257-
If you enabled support for /proc file system then the file
258-
/proc/kcore will contain the kernel core image in ELF format. This
259-
can be used in gdb:
260-
261-
$ cd /usr/src/linux ; gdb vmlinux /proc/kcore
262-
263-
This is especially useful if you have compiled the kernel with the
264-
"-g" option to preserve debugging information. It is mainly used
265-
for examining kernel data structures on the live kernel.
266-
267288
source "fs/Kconfig.binfmt"
268289

269290
endmenu

‎arch/xtensa/boot/boot-elf/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ endif
1212

1313
export OBJCOPY_ARGS
1414
export CPPFLAGS_boot.lds += -P -C
15+
export KBUILD_AFLAGS += -mtext-section-literals
1516

1617
boot-y := bootstrap.o
1718

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1-
#include <variant/core.h>
1+
/*
2+
* linux/arch/xtensa/boot/boot-elf/boot.lds.S
3+
*
4+
* Copyright (C) 2008 - 2013 by Tensilica Inc.
5+
*
6+
* Chris Zankel <chris@zankel.net>
7+
* Marc Gauthier <marc@tensilica.com
8+
* Pete Delaney <piet@tensilica.com>
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 2 as
12+
* published by the Free Software Foundation.
13+
*/
14+
15+
#include <asm/vectors.h>
216
OUTPUT_ARCH(xtensa)
317
ENTRY(_ResetVector)
418

519
SECTIONS
620
{
7-
.start 0xD0000000 : { *(.start) }
8-
9-
.text 0xD0000000:
10-
{
11-
__reloc_start = . ;
12-
_text_start = . ;
13-
*(.literal .text.literal .text)
14-
_text_end = . ;
15-
}
16-
17-
.rodata ALIGN(0x04):
18-
{
19-
*(.rodata)
20-
*(.rodata1)
21-
}
22-
23-
.data ALIGN(0x04):
21+
.ResetVector.text XCHAL_RESET_VECTOR_VADDR :
2422
{
25-
*(.data)
26-
*(.data1)
27-
*(.sdata)
28-
*(.sdata2)
29-
*(.got.plt)
30-
*(.got)
31-
*(.dynamic)
23+
*(.ResetVector.text)
3224
}
3325

34-
__reloc_end = . ;
35-
36-
. = ALIGN(0x10);
37-
__image_load = . ;
38-
.image 0xd0001000:
26+
.image KERNELOFFSET: AT (LOAD_MEMORY_ADDRESS)
3927
{
4028
_image_start = .;
4129
*(image)
4230
. = (. + 3) & ~ 3;
4331
_image_end = . ;
4432
}
4533

46-
4734
.bss ((LOADADDR(.image) + SIZEOF(.image) + 3) & ~ 3):
4835
{
4936
__bss_start = .;
@@ -53,14 +40,15 @@ SECTIONS
5340
*(.bss)
5441
__bss_end = .;
5542
}
56-
_end = .;
57-
_param_start = .;
5843

59-
.ResetVector.text XCHAL_RESET_VECTOR_VADDR :
44+
/*
45+
* This is a remapped copy of the Reset Vector Code.
46+
* It keeps gdb in sync with the PC after switching
47+
* to the temporary mapping used while setting up
48+
* the V2 MMU mappings for Linux.
49+
*/
50+
.ResetVector.remapped_text 0x46000000 (INFO):
6051
{
61-
*(.ResetVector.text)
52+
*(.ResetVector.remapped_text)
6253
}
63-
64-
65-
PROVIDE (end = .);
6654
}
Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,77 @@
1+
/*
2+
* arch/xtensa/boot/boot-elf/bootstrap.S
3+
*
4+
* Low-level exception handling
5+
*
6+
* This file is subject to the terms and conditions of the GNU General Public
7+
* License. See the file "COPYING" in the main directory of this archive
8+
* for more details.
9+
*
10+
* Copyright (C) 2004 - 2013 by Tensilica Inc.
11+
*
12+
* Chris Zankel <chris@zankel.net>
13+
* Marc Gauthier <marc@tensilica.com>
14+
* Piet Delaney <piet@tensilica.com>
15+
*/
116

217
#include <asm/bootparam.h>
18+
#include <asm/processor.h>
19+
#include <asm/pgtable.h>
20+
#include <asm/page.h>
21+
#include <asm/cacheasm.h>
22+
#include <asm/initialize_mmu.h>
23+
#include <linux/linkage.h>
324

4-
5-
/* ResetVector
6-
*/
7-
.section .ResetVector.text, "ax"
25+
.section .ResetVector.text, "ax"
826
.global _ResetVector
27+
.global reset
28+
929
_ResetVector:
10-
_j reset
30+
_j _SetupMMU
31+
32+
.begin no-absolute-literals
33+
.literal_position
34+
1135
.align 4
1236
RomInitAddr:
13-
.word 0xd0001000
37+
#if defined(CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX) && \
38+
XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
39+
.word 0x00003000
40+
#else
41+
.word 0xd0003000
42+
#endif
1443
RomBootParam:
1544
.word _bootparam
45+
_bootparam:
46+
.short BP_TAG_FIRST
47+
.short 4
48+
.long BP_VERSION
49+
.short BP_TAG_LAST
50+
.short 0
51+
.long 0
52+
53+
.align 4
54+
_SetupMMU:
55+
movi a0, 0
56+
wsr a0, windowbase
57+
rsync
58+
movi a0, 1
59+
wsr a0, windowstart
60+
rsync
61+
movi a0, 0x1F
62+
wsr a0, ps
63+
rsync
64+
65+
Offset = _SetupMMU - _ResetVector
66+
67+
#ifndef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
68+
initialize_mmu
69+
#endif
70+
71+
.end no-absolute-literals
72+
73+
rsil a0, XCHAL_DEBUGLEVEL-1
74+
rsync
1675
reset:
1776
l32r a0, RomInitAddr
1877
l32r a2, RomBootParam
@@ -21,13 +80,25 @@ reset:
2180
jx a0
2281

2382
.align 4
24-
.section .bootstrap.data, "aw"
2583

26-
.globl _bootparam
27-
_bootparam:
28-
.short BP_TAG_FIRST
29-
.short 4
30-
.long BP_VERSION
31-
.short BP_TAG_LAST
32-
.short 0
33-
.long 0
84+
.section .ResetVector.remapped_text, "x"
85+
.global _RemappedResetVector
86+
87+
/* Do org before literals */
88+
.org 0
89+
90+
_RemappedResetVector:
91+
.begin no-absolute-literals
92+
.literal_position
93+
94+
_j _RemappedSetupMMU
95+
96+
/* Position Remapped code at the same location as the original code */
97+
. = _RemappedResetVector + Offset
98+
99+
_RemappedSetupMMU:
100+
#ifndef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
101+
initialize_mmu
102+
#endif
103+
104+
.end no-absolute-literals

‎arch/xtensa/boot/boot-redboot/boot.ld‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SECTIONS
3333

3434
. = ALIGN(0x10);
3535
__image_load = . ;
36-
.image 0xd0001000: AT(__image_load)
36+
.image 0xd0003000: AT(__image_load)
3737
{
3838
_image_start = .;
3939
*(image)

‎arch/xtensa/boot/boot-uboot/Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
# for more details.
55
#
66

7-
UIMAGE_LOADADDR = 0xd0001000
7+
ifdef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
8+
UIMAGE_LOADADDR = 0x00003000
9+
else
10+
UIMAGE_LOADADDR = 0xd0003000
11+
endif
812
UIMAGE_COMPRESSION = gzip
913

1014
$(obj)/../uImage: vmlinux.bin.gz FORCE

‎arch/xtensa/include/asm/Kbuild‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ generic-y += irq_regs.h
1515
generic-y += kdebug.h
1616
generic-y += kmap_types.h
1717
generic-y += kvm_para.h
18+
generic-y += linkage.h
1819
generic-y += local.h
1920
generic-y += local64.h
2021
generic-y += percpu.h

0 commit comments

Comments
 (0)