Skip to content

Commit d9dc089

Browse files
committed
Merge tag 'xtensa-20170507' of git://github.com/jcmvbkbc/linux-xtensa
Pull Xtensa updates from Max Filippov: - clearly mark references to spilled register locations with SPILL_SLOT macros - clean up xtensa ptrace: use generic tracehooks, move internal kernel definitions from uapi/asm to asm, make locally-used functions static, fix code style and alignment - use command line parameters passed to ISS as kernel command line. * tag 'xtensa-20170507' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: clean up access to spilled registers locations xtensa: use generic tracehooks xtensa: move internal ptrace definitions from uapi/asm to asm xtensa: clean up xtensa/kernel/ptrace.c xtensa: drop unused fast_io_protect function xtensa: use ITLB_HIT_BIT instead of hardcoded number xtensa: ISS: update kernel command line in platform_setup xtensa: ISS: add argc/argv simcall definitions xtensa: ISS: cleanup setup.c
2 parents 70ef8f0 + 2a4e669 commit d9dc089

12 files changed

Lines changed: 197 additions & 219 deletions

File tree

‎arch/xtensa/include/asm/processor.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@
113113
*/
114114
#define MAKE_PC_FROM_RA(ra,sp) (((ra) & 0x3fffffff) | ((sp) & 0xc0000000))
115115

116+
/* Spill slot location for the register reg in the spill area under the stack
117+
* pointer sp. reg must be in the range [0..4).
118+
*/
119+
#define SPILL_SLOT(sp, reg) (*(((unsigned long *)(sp)) - 4 + (reg)))
120+
121+
/* Spill slot location for the register reg in the spill area under the stack
122+
* pointer sp for the call8. reg must be in the range [4..8).
123+
*/
124+
#define SPILL_SLOT_CALL8(sp, reg) (*(((unsigned long *)(sp)) - 12 + (reg)))
125+
126+
/* Spill slot location for the register reg in the spill area under the stack
127+
* pointer sp for the call12. reg must be in the range [4..12).
128+
*/
129+
#define SPILL_SLOT_CALL12(sp, reg) (*(((unsigned long *)(sp)) - 16 + (reg)))
130+
116131
typedef struct {
117132
unsigned long seg;
118133
} mm_segment_t;

‎arch/xtensa/include/asm/ptrace.h‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,45 @@
1212

1313
#include <uapi/asm/ptrace.h>
1414

15+
/*
16+
* Kernel stack
17+
*
18+
* +-----------------------+ -------- STACK_SIZE
19+
* | register file | |
20+
* +-----------------------+ |
21+
* | struct pt_regs | |
22+
* +-----------------------+ | ------ PT_REGS_OFFSET
23+
* double : 16 bytes spill area : | ^
24+
* excetion :- - - - - - - - - - - -: | |
25+
* frame : struct pt_regs : | |
26+
* :- - - - - - - - - - - -: | |
27+
* | | | |
28+
* | memory stack | | |
29+
* | | | |
30+
* ~ ~ ~ ~
31+
* ~ ~ ~ ~
32+
* | | | |
33+
* | | | |
34+
* +-----------------------+ | | --- STACK_BIAS
35+
* | struct task_struct | | | ^
36+
* current --> +-----------------------+ | | |
37+
* | struct thread_info | | | |
38+
* +-----------------------+ --------
39+
*/
40+
41+
#define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
42+
43+
/* Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
44+
45+
#define EXC_TABLE_KSTK 0x004 /* Kernel Stack */
46+
#define EXC_TABLE_DOUBLE_SAVE 0x008 /* Double exception save area for a0 */
47+
#define EXC_TABLE_FIXUP 0x00c /* Fixup handler */
48+
#define EXC_TABLE_PARAM 0x010 /* For passing a parameter to fixup */
49+
#define EXC_TABLE_SYSCALL_SAVE 0x014 /* For fast syscall handler */
50+
#define EXC_TABLE_FAST_USER 0x100 /* Fast user exception handler */
51+
#define EXC_TABLE_FAST_KERNEL 0x200 /* Fast kernel exception handler */
52+
#define EXC_TABLE_DEFAULT 0x300 /* Default C-Handler */
53+
#define EXC_TABLE_SIZE 0x400
1554

1655
#ifndef __ASSEMBLY__
1756

‎arch/xtensa/include/uapi/asm/ptrace.h‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,6 @@
1111
#ifndef _UAPI_XTENSA_PTRACE_H
1212
#define _UAPI_XTENSA_PTRACE_H
1313

14-
/*
15-
* Kernel stack
16-
*
17-
* +-----------------------+ -------- STACK_SIZE
18-
* | register file | |
19-
* +-----------------------+ |
20-
* | struct pt_regs | |
21-
* +-----------------------+ | ------ PT_REGS_OFFSET
22-
* double : 16 bytes spill area : | ^
23-
* excetion :- - - - - - - - - - - -: | |
24-
* frame : struct pt_regs : | |
25-
* :- - - - - - - - - - - -: | |
26-
* | | | |
27-
* | memory stack | | |
28-
* | | | |
29-
* ~ ~ ~ ~
30-
* ~ ~ ~ ~
31-
* | | | |
32-
* | | | |
33-
* +-----------------------+ | | --- STACK_BIAS
34-
* | struct task_struct | | | ^
35-
* current --> +-----------------------+ | | |
36-
* | struct thread_info | | | |
37-
* +-----------------------+ --------
38-
*/
39-
40-
#define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
41-
42-
/* Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
43-
44-
#define EXC_TABLE_KSTK 0x004 /* Kernel Stack */
45-
#define EXC_TABLE_DOUBLE_SAVE 0x008 /* Double exception save area for a0 */
46-
#define EXC_TABLE_FIXUP 0x00c /* Fixup handler */
47-
#define EXC_TABLE_PARAM 0x010 /* For passing a parameter to fixup */
48-
#define EXC_TABLE_SYSCALL_SAVE 0x014 /* For fast syscall handler */
49-
#define EXC_TABLE_FAST_USER 0x100 /* Fast user exception handler */
50-
#define EXC_TABLE_FAST_KERNEL 0x200 /* Fast kernel exception handler */
51-
#define EXC_TABLE_DEFAULT 0x300 /* Default C-Handler */
52-
#define EXC_TABLE_SIZE 0x400
53-
5414
/* Registers used by strace */
5515

5616
#define REG_A_BASE 0x0000

‎arch/xtensa/kernel/coprocessor.S‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,6 @@
2626
#include <asm/signal.h>
2727
#include <asm/tlbflush.h>
2828

29-
/*
30-
* Entry condition:
31-
*
32-
* a0: trashed, original value saved on stack (PT_AREG0)
33-
* a1: a1
34-
* a2: new stack pointer, original in DEPC
35-
* a3: a3
36-
* depc: a2, original value saved on stack (PT_DEPC)
37-
* excsave_1: dispatch table
38-
*
39-
* PT_DEPC >= VALID_DOUBLE_EXCEPTION_ADDRESS: double exception, DEPC
40-
* < VALID_DOUBLE_EXCEPTION_ADDRESS: regular exception
41-
*/
42-
43-
/* IO protection is currently unsupported. */
44-
45-
ENTRY(fast_io_protect)
46-
47-
wsr a0, excsave1
48-
movi a0, unrecoverable_exception
49-
callx0 a0
50-
51-
ENDPROC(fast_io_protect)
52-
5329
#if XTENSA_HAVE_COPROCESSORS
5430

5531
/*

‎arch/xtensa/kernel/entry.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,10 +1899,11 @@ ENTRY(system_call)
18991899
movi a4, do_syscall_trace_enter
19001900
s32i a3, a2, PT_SYSCALL
19011901
callx4 a4
1902+
mov a3, a6
19021903

19031904
/* syscall = sys_call_table[syscall_nr] */
19041905

1905-
movi a4, sys_call_table;
1906+
movi a4, sys_call_table
19061907
movi a5, __NR_syscall_count
19071908
movi a6, -ENOSYS
19081909
bgeu a3, a5, 1f

‎arch/xtensa/kernel/process.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
204204
#endif
205205

206206
/* Create a call4 dummy-frame: a0 = 0, a1 = childregs. */
207-
*((int*)childregs - 3) = (unsigned long)childregs;
208-
*((int*)childregs - 4) = 0;
207+
SPILL_SLOT(childregs, 1) = (unsigned long)childregs;
208+
SPILL_SLOT(childregs, 0) = 0;
209209

210210
p->thread.sp = (unsigned long)childregs;
211211

@@ -266,8 +266,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
266266
/* pass parameters to ret_from_kernel_thread:
267267
* a2 = thread_fn, a3 = thread_fn arg
268268
*/
269-
*((int *)childregs - 1) = thread_fn_arg;
270-
*((int *)childregs - 2) = usp_thread_fn;
269+
SPILL_SLOT(childregs, 3) = thread_fn_arg;
270+
SPILL_SLOT(childregs, 2) = usp_thread_fn;
271271

272272
/* Childregs are only used when we're going to userspace
273273
* in which case start_thread will set them up.

0 commit comments

Comments
 (0)