Skip to content

Commit b4edf06

Browse files
author
Al Viro
committed
sparc32: switch to generic extables
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c4da8e0 commit b4edf06

File tree

10 files changed

+22
-170
lines changed

10 files changed

+22
-170
lines changed

arch/sparc/include/asm/elf_64.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <asm/ptrace.h>
1010
#include <asm/processor.h>
11-
#include <asm/extable_64.h>
1211
#include <asm/spitfire.h>
1312
#include <asm/adi.h>
1413

arch/sparc/include/asm/extable_64.h renamed to arch/sparc/include/asm/extable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2-
#ifndef __ASM_EXTABLE64_H
3-
#define __ASM_EXTABLE64_H
2+
#ifndef __ASM_EXTABLE_H
3+
#define __ASM_EXTABLE_H
44
/*
55
* The exception table consists of pairs of addresses: the first is the
66
* address of an instruction that is allowed to fault, and the second is

arch/sparc/include/asm/uaccess.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#ifndef ___ASM_SPARC_UACCESS_H
33
#define ___ASM_SPARC_UACCESS_H
4+
5+
#include <asm/extable.h>
6+
47
#if defined(__sparc__) && defined(__arch64__)
58
#include <asm/uaccess_64.h>
69
#else

arch/sparc/include/asm/uaccess_32.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
#include <asm/processor.h>
1515

16-
#define ARCH_HAS_SORT_EXTABLE
17-
#define ARCH_HAS_SEARCH_EXTABLE
18-
1916
/* Sparc is not segmented, however we need to be able to fool access_ok()
2017
* when doing system calls from kernel mode legitimately.
2118
*
@@ -40,36 +37,6 @@
4037
#define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
4138
#define access_ok(addr, size) __access_ok((unsigned long)(addr), size)
4239

43-
/*
44-
* The exception table consists of pairs of addresses: the first is the
45-
* address of an instruction that is allowed to fault, and the second is
46-
* the address at which the program should continue. No registers are
47-
* modified, so it is entirely up to the continuation code to figure out
48-
* what to do.
49-
*
50-
* All the routines below use bits of fixup code that are out of line
51-
* with the main instruction path. This means when everything is well,
52-
* we don't even have to jump over them. Further, they do not intrude
53-
* on our cache or tlb entries.
54-
*
55-
* There is a special way how to put a range of potentially faulting
56-
* insns (like twenty ldd/std's with now intervening other instructions)
57-
* You specify address of first in insn and 0 in fixup and in the next
58-
* exception_table_entry you specify last potentially faulting insn + 1
59-
* and in fixup the routine which should handle the fault.
60-
* That fixup code will get
61-
* (faulting_insn_address - first_insn_in_the_range_address)/4
62-
* in %g2 (ie. index of the faulting instruction in the range).
63-
*/
64-
65-
struct exception_table_entry
66-
{
67-
unsigned long insn, fixup;
68-
};
69-
70-
/* Returns 0 if exception not found and fixup otherwise. */
71-
unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
72-
7340
/* Uh, these should become the main single-value transfer routines..
7441
* They automatically use the right size if we just have the right
7542
* pointer type..

arch/sparc/include/asm/uaccess_64.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/string.h>
1111
#include <asm/asi.h>
1212
#include <asm/spitfire.h>
13-
#include <asm/extable_64.h>
1413

1514
#include <asm/processor.h>
1615

arch/sparc/kernel/unaligned_32.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/uaccess.h>
1717
#include <linux/smp.h>
1818
#include <linux/perf_event.h>
19+
#include <linux/extable.h>
1920

2021
#include <asm/setup.h>
2122

@@ -213,10 +214,10 @@ static inline int ok_for_kernel(unsigned int insn)
213214

214215
static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
215216
{
216-
unsigned long g2 = regs->u_regs [UREG_G2];
217-
unsigned long fixup = search_extables_range(regs->pc, &g2);
217+
const struct exception_table_entry *entry;
218218

219-
if (!fixup) {
219+
entry = search_exception_tables(regs->pc);
220+
if (!entry) {
220221
unsigned long address = compute_effective_address(regs, insn);
221222
if(address < PAGE_SIZE) {
222223
printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference in mna handler");
@@ -232,9 +233,8 @@ static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
232233
die_if_kernel("Oops", regs);
233234
/* Not reached */
234235
}
235-
regs->pc = fixup;
236+
regs->pc = entry->fixup;
236237
regs->npc = regs->pc + 4;
237-
regs->u_regs [UREG_G2] = g2;
238238
}
239239

240240
asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)

arch/sparc/mm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ccflags-y := -Werror
88
obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o
99
obj-y += fault_$(BITS).o
1010
obj-y += init_$(BITS).o
11-
obj-$(CONFIG_SPARC32) += extable.o srmmu.o iommu.o io-unit.o
11+
obj-$(CONFIG_SPARC32) += srmmu.o iommu.o io-unit.o
1212
obj-$(CONFIG_SPARC32) += srmmu_access.o
1313
obj-$(CONFIG_SPARC32) += hypersparc.o viking.o tsunami.o swift.o
1414
obj-$(CONFIG_SPARC32) += leon_mm.o

arch/sparc/mm/extable.c

Lines changed: 0 additions & 107 deletions
This file was deleted.

arch/sparc/mm/fault_32.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/interrupt.h>
2424
#include <linux/kdebug.h>
2525
#include <linux/uaccess.h>
26+
#include <linux/extable.h>
2627

2728
#include <asm/page.h>
2829
#include <asm/openprom.h>
@@ -114,8 +115,6 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
114115
struct vm_area_struct *vma;
115116
struct task_struct *tsk = current;
116117
struct mm_struct *mm = tsk->mm;
117-
unsigned int fixup;
118-
unsigned long g2;
119118
int from_user = !(regs->psr & PSR_PS);
120119
int code;
121120
vm_fault_t fault;
@@ -233,22 +232,19 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
233232

234233
/* Is this in ex_table? */
235234
no_context:
236-
g2 = regs->u_regs[UREG_G2];
237235
if (!from_user) {
238-
fixup = search_extables_range(regs->pc, &g2);
239-
/* Values below 10 are reserved for other things */
240-
if (fixup > 10) {
236+
const struct exception_table_entry *entry;
237+
238+
entry = search_exception_tables(regs->pc);
241239
#ifdef DEBUG_EXCEPTIONS
242-
printk("Exception: PC<%08lx> faddr<%08lx>\n",
243-
regs->pc, address);
244-
printk("EX_TABLE: insn<%08lx> fixup<%08x> g2<%08lx>\n",
245-
regs->pc, fixup, g2);
240+
printk("Exception: PC<%08lx> faddr<%08lx>\n",
241+
regs->pc, address);
242+
printk("EX_TABLE: insn<%08lx> fixup<%08x>\n",
243+
regs->pc, entry->fixup);
246244
#endif
247-
regs->u_regs[UREG_G2] = g2;
248-
regs->pc = fixup;
249-
regs->npc = regs->pc + 4;
250-
return;
251-
}
245+
regs->pc = entry->fixup;
246+
regs->npc = regs->pc + 4;
247+
return;
252248
}
253249

254250
unhandled_fault(address, tsk, regs);

lib/extable.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ static inline unsigned long ex_to_insn(const struct exception_table_entry *x)
2121
}
2222
#endif
2323

24-
#ifndef ARCH_HAS_SORT_EXTABLE
2524
#ifndef ARCH_HAS_RELATIVE_EXTABLE
2625
#define swap_ex NULL
2726
#else
@@ -88,9 +87,6 @@ void trim_init_extable(struct module *m)
8887
m->num_exentries--;
8988
}
9089
#endif /* CONFIG_MODULES */
91-
#endif /* !ARCH_HAS_SORT_EXTABLE */
92-
93-
#ifndef ARCH_HAS_SEARCH_EXTABLE
9490

9591
static int cmp_ex_search(const void *key, const void *elt)
9692
{
@@ -120,4 +116,3 @@ search_extable(const struct exception_table_entry *base,
120116
return bsearch(&value, base, num,
121117
sizeof(struct exception_table_entry), cmp_ex_search);
122118
}
123-
#endif

0 commit comments

Comments
 (0)