Skip to content

Commit 3be80aa

Browse files
committed
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT * PAGE_SIZE, PAGE_OFFSET * struct pt_regs, struct user_regs_struct * struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ... * struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ... * BUG() * ELF_* * Elf_* To disallow user-space visibility into some of the core kernel data-types such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Cc: Jonas Bonn <jonas.bonn@gmail.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Acked-by: Arnd Bergmann <arnd@arndb.de>
1 parent ca15c8e commit 3be80aa

12 files changed

Lines changed: 685 additions & 0 deletions

File tree

‎arch/arc/include/asm/bug.h‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef _ASM_ARC_BUG_H
10+
#define _ASM_ARC_BUG_H
11+
12+
#ifndef __ASSEMBLY__
13+
14+
#include <asm/ptrace.h>
15+
16+
struct task_struct;
17+
18+
void show_regs(struct pt_regs *regs);
19+
void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs);
20+
void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
21+
unsigned long address, unsigned long cause_reg);
22+
void die(const char *str, struct pt_regs *regs, unsigned long address,
23+
unsigned long cause_reg);
24+
25+
#define BUG() do { \
26+
dump_stack(); \
27+
pr_warn("Kernel BUG in %s: %s: %d!\n", \
28+
__FILE__, __func__, __LINE__); \
29+
} while (0)
30+
31+
#define HAVE_ARCH_BUG
32+
33+
#include <asm-generic/bug.h>
34+
35+
#endif /* !__ASSEMBLY__ */
36+
37+
#endif

‎arch/arc/include/asm/cache.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __ARC_ASM_CACHE_H
10+
#define __ARC_ASM_CACHE_H
11+
12+
/* In case $$ not config, setup a dummy number for rest of kernel */
13+
#ifndef CONFIG_ARC_CACHE_LINE_SHIFT
14+
#define L1_CACHE_SHIFT 6
15+
#else
16+
#define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT
17+
#endif
18+
19+
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
20+
21+
#endif /* _ASM_CACHE_H */

‎arch/arc/include/asm/elf.h‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __ASM_ARC_ELF_H
10+
#define __ASM_ARC_ELF_H
11+
12+
#include <asm/ptrace.h>
13+
14+
#define EM_ARCOMPACT 93
15+
16+
/* Machine specific ELF Hdr flags */
17+
#define EF_ARC_OSABI_MSK 0x00000f00
18+
#define EF_ARC_OSABI_ORIG 0x00000000 /* MUST be zero for back-compat */
19+
#define EF_ARC_OSABI_V2 0x00000200
20+
21+
/* ARC Relocations (kernel Modules only) */
22+
#define R_ARC_32 0x4
23+
#define R_ARC_32_ME 0x1B
24+
#define R_ARC_S25H_PCREL 0x10
25+
#define R_ARC_S25W_PCREL 0x11
26+
27+
typedef unsigned long elf_greg_t;
28+
typedef unsigned long elf_fpregset_t;
29+
30+
31+
/* core dump regs is in the order pt_regs, callee_regs, stop_pc (for gdb) */
32+
#define ELF_NGREG ((sizeof(struct pt_regs) + sizeof(struct callee_regs) \
33+
+ sizeof(unsigned long)) / sizeof(elf_greg_t))
34+
35+
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
36+
37+
/*
38+
* To ensure that
39+
* -we don't load something for the wrong architecture.
40+
* -The userspace is using the correct syscall ABI
41+
*/
42+
struct elf32_hdr;
43+
extern int elf_check_arch(const struct elf32_hdr *);
44+
#define elf_check_arch elf_check_arch
45+
46+
/*
47+
* These are used to set parameters in the core dumps.
48+
*/
49+
#define ELF_ARCH EM_ARCOMPACT
50+
#define ELF_CLASS ELFCLASS32
51+
52+
#ifdef CONFIG_CPU_BIG_ENDIAN
53+
#define ELF_DATA ELFDATA2MSB
54+
#else
55+
#define ELF_DATA ELFDATA2LSB
56+
#endif
57+
58+
#ifdef __KERNEL__
59+
60+
#define CORE_DUMP_USE_REGSET
61+
62+
#define ELF_EXEC_PAGESIZE PAGE_SIZE
63+
64+
/*
65+
* This is the location that an ET_DYN program is loaded if exec'ed. Typical
66+
* use of this is to invoke "./ld.so someprog" to test out a new version of
67+
* the loader. We need to make sure that it is out of the way of the program
68+
* that it will "exec", and that there is sufficient room for the brk.
69+
*/
70+
#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
71+
72+
/*
73+
* When the program starts, a1 contains a pointer to a function to be
74+
* registered with atexit, as per the SVR4 ABI. A value of 0 means we
75+
* have no such handler.
76+
*/
77+
#define ELF_PLAT_INIT(_r, load_addr) ((_r)->r0 = 0)
78+
79+
/*
80+
* This yields a mask that user programs can use to figure out what
81+
* instruction set this cpu supports.
82+
*/
83+
#define ELF_HWCAP (0)
84+
85+
/*
86+
* This yields a string that ld.so will use to load implementation
87+
* specific libraries for optimization. This is more specific in
88+
* intent than poking at uname or /proc/cpuinfo.
89+
*/
90+
#define ELF_PLATFORM (NULL)
91+
92+
#define SET_PERSONALITY(ex) \
93+
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
94+
95+
#endif /* __KERNEL__ */
96+
97+
#endif

‎arch/arc/include/asm/exec.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __ASM_ARC_EXEC_H
10+
#define __ASM_ARC_EXEC_H
11+
12+
/* Align to 16b */
13+
#define arch_align_stack(p) ((unsigned long)(p) & ~0xf)
14+
15+
#endif

‎arch/arc/include/asm/kdebug.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef _ASM_ARC_KDEBUG_H
10+
#define _ASM_ARC_KDEBUG_H
11+
12+
enum die_val {
13+
DIE_UNUSED,
14+
DIE_TRAP,
15+
DIE_IERR,
16+
DIE_OOPS
17+
};
18+
19+
#endif

‎arch/arc/include/asm/linkage.h‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __ASM_LINKAGE_H
10+
#define __ASM_LINKAGE_H
11+
12+
#ifdef __ASSEMBLY__
13+
14+
/* Can't use the ENTRY macro in linux/linkage.h
15+
* gas considers ';' as comment vs. newline
16+
*/
17+
.macro ARC_ENTRY name
18+
.global \name
19+
.align 4
20+
\name:
21+
.endm
22+
23+
.macro ARC_EXIT name
24+
#define ASM_PREV_SYM_ADDR(name) .-##name
25+
.size \ name, ASM_PREV_SYM_ADDR(\name)
26+
.endm
27+
28+
#endif /* __ASSEMBLY__ */
29+
30+
#endif

‎arch/arc/include/asm/module.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* Amit Bhor, Sameer Dhavale: Codito Technologies 2004
9+
10+
*/
11+
12+
#ifndef _ASM_ARC_MODULE_H
13+
#define _ASM_ARC_MODULE_H
14+
15+
#include <asm-generic/module.h>
16+
17+
#endif /* _ASM_ARC_MODULE_H */

‎arch/arc/include/asm/page.h‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __ASM_ARC_PAGE_H
10+
#define __ASM_ARC_PAGE_H
11+
12+
/* PAGE_SHIFT determines the page size */
13+
#if defined(CONFIG_ARC_PAGE_SIZE_16K)
14+
#define PAGE_SHIFT 14
15+
#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
16+
#define PAGE_SHIFT 12
17+
#else
18+
/*
19+
* Default 8k
20+
* done this way (instead of under CONFIG_ARC_PAGE_SIZE_8K) because adhoc
21+
* user code (busybox appletlib.h) expects PAGE_SHIFT to be defined w/o
22+
* using the correct uClibc header and in their build our autoconf.h is
23+
* not available
24+
*/
25+
#define PAGE_SHIFT 13
26+
#endif
27+
28+
#ifdef __ASSEMBLY__
29+
#define PAGE_SIZE (1 << PAGE_SHIFT)
30+
#define PAGE_OFFSET (0x80000000)
31+
#else
32+
#define PAGE_SIZE (1UL << PAGE_SHIFT) /* Default 8K */
33+
#define PAGE_OFFSET (0x80000000UL) /* Kernel starts at 2G onwards */
34+
#endif
35+
36+
#define PAGE_MASK (~(PAGE_SIZE-1))
37+
38+
#endif /* !__ASSEMBLY__ */
39+
40+
#endif /* __KERNEL__ */
41+
42+
#endif

0 commit comments

Comments
 (0)