* [PATCH v3 0/4] generic relative extable support
@ 2016-03-10 14:43 Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 1/4] alpha/extable: use generic search and sort routines Ard Biesheuvel
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-10 14:43 UTC (permalink / raw)
To: linux-alpha, linux-s390, linux-ia64, x86, akpm
Cc: tony.luck, rth, hpa, heiko.carstens, Ard Biesheuvel
This is basically a resend of the remaining relative extable rework patches
that were queued for v4.6 in Andrew's tree for a couple of weeks, and then
subsequently dropped due to conflicts with the arm64 and x86 subtrees in -next.
Since the core patch that these remaining patches depend on is now queued in
the arm64 tree for inclusion in v4.6, I have rebased this series onto
next-20160310 so that they may be requeued and hopefully merged late during the
next merge window. Alternatively, they could be picked up by each maintainer
separately since they are all independent. Queueing them for v4.7 is likely
to result in conflicts again, so I think that would be the least preferable
option.
Changes since v2:
- dropped core patch and arm64 patches since they are already en route
- fixed up a purely contextual conflict in the x86 patch, the functional
changes were completely independent
---- v2 blurb ----
There are currently four architectures (x86, ia64, alpha and s390) whose
user-access exception tables are relative to the table entry address rather
than absolute. Each of these architectures has its own search_extable() and
sort_extable() implementation, which are not only mostly identical to each
other, but also deviate very little from the generic absolute implementations
in lib/extable.c that they override.
So before making arm64 the fifth architecture that reimplements this, let's
refactor the existing code so that all of these architectures use common code
for searching and sorting the relative extables. Archs may set
ARCH_HAS_RELATIVE_EXTABLE to indicate that the table consists of a pair of
relative ints, and may define swap_ex_entry_fixup() if the fixup member needs
special treatment in the swapping step of the sorting routine (such as alpha).
Changes since v1:
- introduce the _ASM_EXTABLE() cpp macro for arm64, and replace all open coded
exception table entries with it, including an instance I missed in v1 in
asm/word-at-a-time.h (suggested by hpa)
- added acks to from arch maintainers
Ard Biesheuvel (4):
alpha/extable: use generic search and sort routines
s390/extable: use generic search and sort routines
x86/extable: use generic search and sort routines
ia64/extable: use generic search and sort routines
arch/alpha/include/asm/uaccess.h | 10 +-
arch/alpha/mm/Makefile | 2 +-
arch/alpha/mm/extable.c | 92 -----------------
arch/ia64/include/asm/uaccess.h | 8 +-
arch/ia64/mm/extable.c | 97 +-----------------
arch/s390/include/asm/uaccess.h | 8 +-
arch/s390/mm/Makefile | 2 +-
arch/s390/mm/extable.c | 85 ---------------
arch/x86/include/asm/uaccess.h | 5 +-
arch/x86/mm/extable.c | 108 --------------------
10 files changed, 17 insertions(+), 400 deletions(-)
delete mode 100644 arch/alpha/mm/extable.c
delete mode 100644 arch/s390/mm/extable.c
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/4] alpha/extable: use generic search and sort routines
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
@ 2016-03-10 14:43 ` Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 2/4] s390/extable: " Ard Biesheuvel
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-10 14:43 UTC (permalink / raw)
To: linux-alpha, linux-s390, linux-ia64, x86, akpm
Cc: tony.luck, rth, hpa, heiko.carstens, Ard Biesheuvel
Replace the arch specific versions of search_extable() and sort_extable()
with calls to the generic ones, which now support relative exception
tables as well.
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/alpha/include/asm/uaccess.h | 10 ++-
arch/alpha/mm/Makefile | 2 +-
arch/alpha/mm/extable.c | 92 --------------------
3 files changed, 9 insertions(+), 95 deletions(-)
diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
index 9b0d40093c9a..c419b43c461d 100644
--- a/arch/alpha/include/asm/uaccess.h
+++ b/arch/alpha/include/asm/uaccess.h
@@ -483,7 +483,13 @@ struct exception_table_entry
(pc) + (_fixup)->fixup.bits.nextinsn; \
})
-#define ARCH_HAS_SORT_EXTABLE
-#define ARCH_HAS_SEARCH_EXTABLE
+#define ARCH_HAS_RELATIVE_EXTABLE
+
+#define swap_ex_entry_fixup(a, b, tmp, delta) \
+ do { \
+ (a)->fixup.unit = (b)->fixup.unit; \
+ (b)->fixup.unit = (tmp).fixup.unit; \
+ } while (0)
+
#endif /* __ALPHA_UACCESS_H */
diff --git a/arch/alpha/mm/Makefile b/arch/alpha/mm/Makefile
index c993d3f93cf6..5a9807936411 100644
--- a/arch/alpha/mm/Makefile
+++ b/arch/alpha/mm/Makefile
@@ -4,6 +4,6 @@
ccflags-y := -Werror
-obj-y := init.o fault.o extable.o
+obj-y := init.o fault.o
obj-$(CONFIG_DISCONTIGMEM) += numa.o
diff --git a/arch/alpha/mm/extable.c b/arch/alpha/mm/extable.c
deleted file mode 100644
index 813c9b63c0e1..000000000000
--- a/arch/alpha/mm/extable.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * linux/arch/alpha/mm/extable.c
- */
-
-#include <linux/module.h>
-#include <linux/sort.h>
-#include <asm/uaccess.h>
-
-static inline unsigned long ex_to_addr(const struct exception_table_entry *x)
-{
- return (unsigned long)&x->insn + x->insn;
-}
-
-static void swap_ex(void *a, void *b, int size)
-{
- struct exception_table_entry *ex_a = a, *ex_b = b;
- unsigned long addr_a = ex_to_addr(ex_a), addr_b = ex_to_addr(ex_b);
- unsigned int t = ex_a->fixup.unit;
-
- ex_a->fixup.unit = ex_b->fixup.unit;
- ex_b->fixup.unit = t;
- ex_a->insn = (int)(addr_b - (unsigned long)&ex_a->insn);
- ex_b->insn = (int)(addr_a - (unsigned long)&ex_b->insn);
-}
-
-/*
- * The exception table needs to be sorted so that the binary
- * search that we use to find entries in it works properly.
- * This is used both for the kernel exception table and for
- * the exception tables of modules that get loaded.
- */
-static int cmp_ex(const void *a, const void *b)
-{
- const struct exception_table_entry *x = a, *y = b;
-
- /* avoid overflow */
- if (ex_to_addr(x) > ex_to_addr(y))
- return 1;
- if (ex_to_addr(x) < ex_to_addr(y))
- return -1;
- return 0;
-}
-
-void sort_extable(struct exception_table_entry *start,
- struct exception_table_entry *finish)
-{
- sort(start, finish - start, sizeof(struct exception_table_entry),
- cmp_ex, swap_ex);
-}
-
-#ifdef CONFIG_MODULES
-/*
- * Any entry referring to the module init will be at the beginning or
- * the end.
- */
-void trim_init_extable(struct module *m)
-{
- /*trim the beginning*/
- while (m->num_exentries &&
- within_module_init(ex_to_addr(&m->extable[0]), m)) {
- m->extable++;
- m->num_exentries--;
- }
- /*trim the end*/
- while (m->num_exentries &&
- within_module_init(ex_to_addr(&m->extable[m->num_exentries-1]),
- m))
- m->num_exentries--;
-}
-#endif /* CONFIG_MODULES */
-
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long value)
-{
- while (first <= last) {
- const struct exception_table_entry *mid;
- unsigned long mid_value;
-
- mid = (last - first) / 2 + first;
- mid_value = ex_to_addr(mid);
- if (mid_value == value)
- return mid;
- else if (mid_value < value)
- first = mid+1;
- else
- last = mid-1;
- }
-
- return NULL;
-}
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/4] s390/extable: use generic search and sort routines
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 1/4] alpha/extable: use generic search and sort routines Ard Biesheuvel
@ 2016-03-10 14:43 ` Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 3/4] x86/extable: " Ard Biesheuvel
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-10 14:43 UTC (permalink / raw)
To: linux-alpha, linux-s390, linux-ia64, x86, akpm
Cc: tony.luck, rth, hpa, heiko.carstens, Ard Biesheuvel
Replace the arch specific versions of search_extable() and sort_extable()
with calls to the generic ones, which now support relative exception
tables as well.
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/s390/include/asm/uaccess.h | 8 +-
arch/s390/mm/Makefile | 2 +-
arch/s390/mm/extable.c | 85 --------------------
3 files changed, 2 insertions(+), 93 deletions(-)
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 9dd4cc47ddc7..e0900ddf91dd 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -79,18 +79,12 @@ struct exception_table_entry
int insn, fixup;
};
-static inline unsigned long extable_insn(const struct exception_table_entry *x)
-{
- return (unsigned long)&x->insn + x->insn;
-}
-
static inline unsigned long extable_fixup(const struct exception_table_entry *x)
{
return (unsigned long)&x->fixup + x->fixup;
}
-#define ARCH_HAS_SORT_EXTABLE
-#define ARCH_HAS_SEARCH_EXTABLE
+#define ARCH_HAS_RELATIVE_EXTABLE
/**
* __copy_from_user: - Copy a block of data from user space, with less checking.
diff --git a/arch/s390/mm/Makefile b/arch/s390/mm/Makefile
index 2ae54cad2b6a..0aa0ad165d8b 100644
--- a/arch/s390/mm/Makefile
+++ b/arch/s390/mm/Makefile
@@ -3,7 +3,7 @@
#
obj-y := init.o fault.o extmem.o mmap.o vmem.o maccess.o
-obj-y += page-states.o gup.o extable.o pageattr.o mem_detect.o
+obj-y += page-states.o gup.o pageattr.o mem_detect.o
obj-y += pgtable.o pgalloc.o
obj-$(CONFIG_CMM) += cmm.o
diff --git a/arch/s390/mm/extable.c b/arch/s390/mm/extable.c
deleted file mode 100644
index 18c8b819b0aa..000000000000
--- a/arch/s390/mm/extable.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <linux/module.h>
-#include <linux/sort.h>
-#include <asm/uaccess.h>
-
-/*
- * Search one exception table for an entry corresponding to the
- * given instruction address, and return the address of the entry,
- * or NULL if none is found.
- * We use a binary search, and thus we assume that the table is
- * already sorted.
- */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long value)
-{
- const struct exception_table_entry *mid;
- unsigned long addr;
-
- while (first <= last) {
- mid = ((last - first) >> 1) + first;
- addr = extable_insn(mid);
- if (addr < value)
- first = mid + 1;
- else if (addr > value)
- last = mid - 1;
- else
- return mid;
- }
- return NULL;
-}
-
-/*
- * The exception table needs to be sorted so that the binary
- * search that we use to find entries in it works properly.
- * This is used both for the kernel exception table and for
- * the exception tables of modules that get loaded.
- *
- */
-static int cmp_ex(const void *a, const void *b)
-{
- const struct exception_table_entry *x = a, *y = b;
-
- /* This compare is only valid after normalization. */
- return x->insn - y->insn;
-}
-
-void sort_extable(struct exception_table_entry *start,
- struct exception_table_entry *finish)
-{
- struct exception_table_entry *p;
- int i;
-
- /* Normalize entries to being relative to the start of the section */
- for (p = start, i = 0; p < finish; p++, i += 8) {
- p->insn += i;
- p->fixup += i + 4;
- }
- sort(start, finish - start, sizeof(*start), cmp_ex, NULL);
- /* Denormalize all entries */
- for (p = start, i = 0; p < finish; p++, i += 8) {
- p->insn -= i;
- p->fixup -= i + 4;
- }
-}
-
-#ifdef CONFIG_MODULES
-/*
- * If the exception table is sorted, any referring to the module init
- * will be at the beginning or the end.
- */
-void trim_init_extable(struct module *m)
-{
- /* Trim the beginning */
- while (m->num_exentries &&
- within_module_init(extable_insn(&m->extable[0]), m)) {
- m->extable++;
- m->num_exentries--;
- }
- /* Trim the end */
- while (m->num_exentries &&
- within_module_init(extable_insn(&m->extable[m->num_exentries-1]), m))
- m->num_exentries--;
-}
-#endif /* CONFIG_MODULES */
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/4] x86/extable: use generic search and sort routines
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 1/4] alpha/extable: use generic search and sort routines Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 2/4] s390/extable: " Ard Biesheuvel
@ 2016-03-10 14:43 ` Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 4/4] ia64/extable: " Ard Biesheuvel
2016-03-10 22:07 ` [PATCH v3 0/4] generic relative extable support Andrew Morton
4 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-10 14:43 UTC (permalink / raw)
To: linux-alpha, linux-s390, linux-ia64, x86, akpm
Cc: tony.luck, rth, hpa, heiko.carstens, Ard Biesheuvel
Replace the arch specific versions of search_extable() and sort_extable()
with calls to the generic ones, which now support relative exception
tables as well.
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/x86/include/asm/uaccess.h | 5 +-
arch/x86/mm/extable.c | 108 --------------------
2 files changed, 2 insertions(+), 111 deletions(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 88bff6dd23ad..a969ae607be8 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -105,9 +105,8 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
struct exception_table_entry {
int insn, fixup, handler;
};
-/* This is not the generic standard exception_table_entry format */
-#define ARCH_HAS_SORT_EXTABLE
-#define ARCH_HAS_SEARCH_EXTABLE
+
+#define ARCH_HAS_RELATIVE_EXTABLE
extern int fixup_exception(struct pt_regs *regs, int trapnr);
extern bool ex_has_fault_handler(unsigned long ip);
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 9dd7e4b7fcde..82447b3fba38 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -1,17 +1,10 @@
#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/sort.h>
#include <asm/uaccess.h>
typedef bool (*ex_handler_t)(const struct exception_table_entry *,
struct pt_regs *, int);
static inline unsigned long
-ex_insn_addr(const struct exception_table_entry *x)
-{
- return (unsigned long)&x->insn + x->insn;
-}
-static inline unsigned long
ex_fixup_addr(const struct exception_table_entry *x)
{
return (unsigned long)&x->fixup + x->fixup;
@@ -110,104 +103,3 @@ int __init early_fixup_exception(unsigned long *ip)
*ip = new_ip;
return 1;
}
-
-/*
- * Search one exception table for an entry corresponding to the
- * given instruction address, and return the address of the entry,
- * or NULL if none is found.
- * We use a binary search, and thus we assume that the table is
- * already sorted.
- */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long value)
-{
- while (first <= last) {
- const struct exception_table_entry *mid;
- unsigned long addr;
-
- mid = ((last - first) >> 1) + first;
- addr = ex_insn_addr(mid);
- if (addr < value)
- first = mid + 1;
- else if (addr > value)
- last = mid - 1;
- else
- return mid;
- }
- return NULL;
-}
-
-/*
- * The exception table needs to be sorted so that the binary
- * search that we use to find entries in it works properly.
- * This is used both for the kernel exception table and for
- * the exception tables of modules that get loaded.
- *
- */
-static int cmp_ex(const void *a, const void *b)
-{
- const struct exception_table_entry *x = a, *y = b;
-
- /*
- * This value will always end up fittin in an int, because on
- * both i386 and x86-64 the kernel symbol-reachable address
- * space is < 2 GiB.
- *
- * This compare is only valid after normalization.
- */
- return x->insn - y->insn;
-}
-
-void sort_extable(struct exception_table_entry *start,
- struct exception_table_entry *finish)
-{
- struct exception_table_entry *p;
- int i;
-
- /* Convert all entries to being relative to the start of the section */
- i = 0;
- for (p = start; p < finish; p++) {
- p->insn += i;
- i += 4;
- p->fixup += i;
- i += 4;
- p->handler += i;
- i += 4;
- }
-
- sort(start, finish - start, sizeof(struct exception_table_entry),
- cmp_ex, NULL);
-
- /* Denormalize all entries */
- i = 0;
- for (p = start; p < finish; p++) {
- p->insn -= i;
- i += 4;
- p->fixup -= i;
- i += 4;
- p->handler -= i;
- i += 4;
- }
-}
-
-#ifdef CONFIG_MODULES
-/*
- * If the exception table is sorted, any referring to the module init
- * will be at the beginning or the end.
- */
-void trim_init_extable(struct module *m)
-{
- /*trim the beginning*/
- while (m->num_exentries &&
- within_module_init(ex_insn_addr(&m->extable[0]), m)) {
- m->extable++;
- m->num_exentries--;
- }
- /*trim the end*/
- while (m->num_exentries &&
- within_module_init(ex_insn_addr(&m->extable[m->num_exentries-1]), m))
- m->num_exentries--;
-}
-#endif /* CONFIG_MODULES */
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/4] ia64/extable: use generic search and sort routines
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
` (2 preceding siblings ...)
2016-03-10 14:43 ` [PATCH v3 3/4] x86/extable: " Ard Biesheuvel
@ 2016-03-10 14:43 ` Ard Biesheuvel
2016-03-10 22:07 ` [PATCH v3 0/4] generic relative extable support Andrew Morton
4 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-10 14:43 UTC (permalink / raw)
To: linux-alpha, linux-s390, linux-ia64, x86, akpm
Cc: tony.luck, rth, hpa, heiko.carstens, Ard Biesheuvel
Replace the arch specific versions of search_extable() and sort_extable()
with calls to the generic ones, which now support relative exception
tables as well.
Acked-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/ia64/include/asm/uaccess.h | 8 +-
arch/ia64/mm/extable.c | 97 +-------------------
2 files changed, 4 insertions(+), 101 deletions(-)
diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 4f3fb6ccbf21..2189d5ddc1ee 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -341,13 +341,11 @@ extern unsigned long __strnlen_user (const char __user *, long);
__su_ret; \
})
-/* Generic code can't deal with the location-relative format that we use for compactness. */
-#define ARCH_HAS_SORT_EXTABLE
-#define ARCH_HAS_SEARCH_EXTABLE
+#define ARCH_HAS_RELATIVE_EXTABLE
struct exception_table_entry {
- int addr; /* location-relative address of insn this fixup is for */
- int cont; /* location-relative continuation addr.; if bit 2 is set, r9 is set to 0 */
+ int insn; /* location-relative address of insn this fixup is for */
+ int fixup; /* location-relative continuation addr.; if bit 2 is set, r9 is set to 0 */
};
extern void ia64_handle_exception (struct pt_regs *regs, const struct exception_table_entry *e);
diff --git a/arch/ia64/mm/extable.c b/arch/ia64/mm/extable.c
index c99a41e29fe8..8f70bb2d0c37 100644
--- a/arch/ia64/mm/extable.c
+++ b/arch/ia64/mm/extable.c
@@ -5,107 +5,12 @@
* David Mosberger-Tang <davidm@hpl.hp.com>
*/
-#include <linux/sort.h>
-
#include <asm/uaccess.h>
-#include <linux/module.h>
-
-static int cmp_ex(const void *a, const void *b)
-{
- const struct exception_table_entry *l = a, *r = b;
- u64 lip = (u64) &l->addr + l->addr;
- u64 rip = (u64) &r->addr + r->addr;
-
- /* avoid overflow */
- if (lip > rip)
- return 1;
- if (lip < rip)
- return -1;
- return 0;
-}
-
-static void swap_ex(void *a, void *b, int size)
-{
- struct exception_table_entry *l = a, *r = b, tmp;
- u64 delta = (u64) r - (u64) l;
-
- tmp = *l;
- l->addr = r->addr + delta;
- l->cont = r->cont + delta;
- r->addr = tmp.addr - delta;
- r->cont = tmp.cont - delta;
-}
-
-/*
- * Sort the exception table. It's usually already sorted, but there
- * may be unordered entries due to multiple text sections (such as the
- * .init text section). Note that the exception-table-entries contain
- * location-relative addresses, which requires a bit of care during
- * sorting to avoid overflows in the offset members (e.g., it would
- * not be safe to make a temporary copy of an exception-table entry on
- * the stack, because the stack may be more than 2GB away from the
- * exception-table).
- */
-void sort_extable (struct exception_table_entry *start,
- struct exception_table_entry *finish)
-{
- sort(start, finish - start, sizeof(struct exception_table_entry),
- cmp_ex, swap_ex);
-}
-
-static inline unsigned long ex_to_addr(const struct exception_table_entry *x)
-{
- return (unsigned long)&x->addr + x->addr;
-}
-
-#ifdef CONFIG_MODULES
-/*
- * Any entry referring to the module init will be at the beginning or
- * the end.
- */
-void trim_init_extable(struct module *m)
-{
- /*trim the beginning*/
- while (m->num_exentries &&
- within_module_init(ex_to_addr(&m->extable[0]), m)) {
- m->extable++;
- m->num_exentries--;
- }
- /*trim the end*/
- while (m->num_exentries &&
- within_module_init(ex_to_addr(&m->extable[m->num_exentries-1]),
- m))
- m->num_exentries--;
-}
-#endif /* CONFIG_MODULES */
-
-const struct exception_table_entry *
-search_extable (const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long ip)
-{
- const struct exception_table_entry *mid;
- unsigned long mid_ip;
- long diff;
-
- while (first <= last) {
- mid = &first[(last - first)/2];
- mid_ip = (u64) &mid->addr + mid->addr;
- diff = mid_ip - ip;
- if (diff == 0)
- return mid;
- else if (diff < 0)
- first = mid + 1;
- else
- last = mid - 1;
- }
- return NULL;
-}
void
ia64_handle_exception (struct pt_regs *regs, const struct exception_table_entry *e)
{
- long fix = (u64) &e->cont + e->cont;
+ long fix = (u64) &e->fixup + e->fixup;
regs->r8 = -EFAULT;
if (fix & 4)
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] generic relative extable support
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
` (3 preceding siblings ...)
2016-03-10 14:43 ` [PATCH v3 4/4] ia64/extable: " Ard Biesheuvel
@ 2016-03-10 22:07 ` Andrew Morton
2016-03-11 0:41 ` Ard Biesheuvel
4 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2016-03-10 22:07 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-alpha, linux-s390, linux-ia64, x86, tony.luck, rth, hpa,
heiko.carstens
On Thu, 10 Mar 2016 21:43:12 +0700 Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> This is basically a resend of the remaining relative extable rework patches
> that were queued for v4.6 in Andrew's tree for a couple of weeks, and then
> subsequently dropped due to conflicts with the arm64 and x86 subtrees in -next.
>
> Since the core patch that these remaining patches depend on is now queued in
> the arm64 tree for inclusion in v4.6, I have rebased this series onto
> next-20160310 so that they may be requeued and hopefully merged late during the
> next merge window. Alternatively, they could be picked up by each maintainer
> separately since they are all independent. Queueing them for v4.7 is likely
> to result in conflicts again, so I think that would be the least preferable
> option.
Yup, these all look good to merge.
> ---- v2 blurb ----
> There are currently four architectures (x86, ia64, alpha and s390) whose
> user-access exception tables are relative to the table entry address rather
> than absolute. Each of these architectures has its own search_extable() and
> sort_extable() implementation, which are not only mostly identical to each
> other, but also deviate very little from the generic absolute implementations
> in lib/extable.c that they override.
>
> So before making arm64 the fifth architecture that reimplements this, let's
> refactor the existing code so that all of these architectures use common code
> for searching and sorting the relative extables. Archs may set
> ARCH_HAS_RELATIVE_EXTABLE to indicate that the table consists of a pair of
> relative ints, and may define swap_ex_entry_fixup() if the fixup member needs
> special treatment in the swapping step of the sorting routine (such as alpha).
>
I'll want to manually verify that the required patches are upstreamed.
I assume we're referring to a272858a3c1ecd4a ("extable: add support for
relative extables to search and sort routines") and related patches?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] generic relative extable support
2016-03-10 22:07 ` [PATCH v3 0/4] generic relative extable support Andrew Morton
@ 2016-03-11 0:41 ` Ard Biesheuvel
0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2016-03-11 0:41 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-alpha, linux-s390, linux-ia64@vger.kernel.org,
x86@kernel.org, Tony Luck, Richard Henderson, hpa@zytor.com,
Heiko Carstens
On 11 March 2016 at 05:07, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 10 Mar 2016 21:43:12 +0700 Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
[...]
>> ---- v2 blurb ----
>> There are currently four architectures (x86, ia64, alpha and s390) whose
>> user-access exception tables are relative to the table entry address rather
>> than absolute. Each of these architectures has its own search_extable() and
>> sort_extable() implementation, which are not only mostly identical to each
>> other, but also deviate very little from the generic absolute implementations
>> in lib/extable.c that they override.
>>
>> So before making arm64 the fifth architecture that reimplements this, let's
>> refactor the existing code so that all of these architectures use common code
>> for searching and sorting the relative extables. Archs may set
>> ARCH_HAS_RELATIVE_EXTABLE to indicate that the table consists of a pair of
>> relative ints, and may define swap_ex_entry_fixup() if the fixup member needs
>> special treatment in the swapping step of the sorting routine (such as alpha).
>>
>
> I'll want to manually verify that the required patches are upstreamed.
> I assume we're referring to a272858a3c1ecd4a ("extable: add support for
> relative extables to search and sort routines") and related patches?
>
Correct. As long as that single patch is in, these are good to go.
Thanks,
Ard.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-03-11 0:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-10 14:43 [PATCH v3 0/4] generic relative extable support Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 1/4] alpha/extable: use generic search and sort routines Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 2/4] s390/extable: " Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 3/4] x86/extable: " Ard Biesheuvel
2016-03-10 14:43 ` [PATCH v3 4/4] ia64/extable: " Ard Biesheuvel
2016-03-10 22:07 ` [PATCH v3 0/4] generic relative extable support Andrew Morton
2016-03-11 0:41 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).