Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300324 > unrolled thread

[PATCH 0/6] generic relative extable support

Started byArd Biesheuvel <ard.biesheuvel@linaro.org>
First post2016-01-03 17:10 +0100
Last post2016-01-04 19:20 +0100
Articles 15 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/6] generic relative extable support Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-03 17:10 +0100
    [PATCH 1/6] extable: add support for relative extables to search and sort routines Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-03 17:10 +0100
      Re: [PATCH 1/6] extable: add support for relative extables to search  and sort routines Helge Deller <deller@gmx.de> - 2016-01-04 22:10 +0100
    [PATCH 5/6] ia64/extable: use generic search and sort routines Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-03 17:10 +0100
    [PATCH 4/6] x86/extable: use generic search and sort routines Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-03 17:10 +0100
    [PATCH 6/6] arm64: switch to relative exception tables Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-03 17:10 +0100
      Re: [PATCH 6/6] arm64: switch to relative exception tables Will Deacon <will.deacon@arm.com> - 2016-01-04 15:50 +0100
        Re: [PATCH 6/6] arm64: switch to relative exception tables "H. Peter Anvin" <hpa@zytor.com> - 2016-01-04 19:20 +0100
          RE: [PATCH 6/6] arm64: switch to relative exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-04 19:30 +0100
            Re: [PATCH 6/6] arm64: switch to relative exception tables "H. Peter Anvin" <hpa@zytor.com> - 2016-01-04 19:50 +0100
            Re: [PATCH 6/6] arm64: switch to relative exception tables Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-01-04 20:30 +0100
              Re: [PATCH 6/6] arm64: switch to relative exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-04 20:50 +0100
            Re: [PATCH 6/6] arm64: switch to relative exception tables "H. Peter Anvin" <hpa@zytor.com> - 2016-01-04 20:30 +0100
    Re: [PATCH 0/6] generic relative extable support Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-04 12:30 +0100
      Re: [PATCH 0/6] generic relative extable support "H. Peter Anvin" <hpa@zytor.com> - 2016-01-04 19:20 +0100

#1300324 — [PATCH 0/6] generic relative extable support

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-03 17:10 +0100
Subject[PATCH 0/6] generic relative extable support
Message-ID<qMTod-7DP-3@gated-at.bofh.it>
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).

Note that the s390 patch applies on top of the following patch:

  http://article.gmane.org/gmane.linux.kernel/2117036

which fixes a bug I spotted while working on this code. Since that probably
needs to go to -stable, I broke it out and posted it separately.

Ard Biesheuvel (6):
  extable: add support for relative extables to search and sort routines
  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
  arm64: switch to relative exception tables

 arch/alpha/include/asm/uaccess.h     |  10 +-
 arch/alpha/mm/Makefile               |   2 +-
 arch/alpha/mm/extable.c              |  92 -----------------
 arch/arm64/include/asm/assembler.h   |   2 +-
 arch/arm64/include/asm/futex.h       |   4 +-
 arch/arm64/include/asm/uaccess.h     |  18 ++--
 arch/arm64/kernel/armv8_deprecated.c |   4 +-
 arch/arm64/mm/extable.c              |   2 +-
 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                | 106 +-------------------
 lib/extable.c                        |  50 +++++++--
 scripts/sortextable.c                |   2 +-
 17 files changed, 77 insertions(+), 420 deletions(-)
 delete mode 100644 arch/alpha/mm/extable.c
 delete mode 100644 arch/s390/mm/extable.c

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1300325 — [PATCH 1/6] extable: add support for relative extables to search and sort routines

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-03 17:10 +0100
Subject[PATCH 1/6] extable: add support for relative extables to search and sort routines
Message-ID<qMToe-7DP-19@gated-at.bofh.it>
In reply to#1300324
This adds support to the generic search_extable() and sort_extable()
implementations for dealing with exception table entries whose fields
contain relative offsets rather than absolute addresses.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 lib/extable.c | 50 ++++++++++++++++----
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/lib/extable.c b/lib/extable.c
index 4cac81ec225e..0be02ad561e9 100644
--- a/lib/extable.c
+++ b/lib/extable.c
@@ -14,7 +14,37 @@
 #include <linux/sort.h>
 #include <asm/uaccess.h>
 
+#ifndef ARCH_HAS_RELATIVE_EXTABLE
+#define ex_to_insn(x)	((x)->insn)
+#else
+static inline unsigned long ex_to_insn(const struct exception_table_entry *x)
+{
+	return (unsigned long)&x->insn + x->insn;
+}
+#endif
+
 #ifndef ARCH_HAS_SORT_EXTABLE
+#ifndef ARCH_HAS_RELATIVE_EXTABLE
+#define swap_ex		NULL
+#else
+static void swap_ex(void *a, void *b, int size)
+{
+	struct exception_table_entry *x = a, *y = b, tmp;
+	int delta = b - a;
+
+	tmp = *x;
+	x->insn = y->insn + delta;
+	y->insn = tmp.insn - delta;
+
+#ifdef swap_ex_entry_fixup
+	swap_ex_entry_fixup(x, y, tmp, delta);
+#else
+	x->fixup = y->fixup + delta;
+	y->fixup = tmp.fixup - delta;
+#endif
+}
+#endif /* ARCH_HAS_RELATIVE_EXTABLE */
+
 /*
  * The exception table needs to be sorted so that the binary
  * search that we use to find entries in it works properly.
@@ -26,9 +56,9 @@ static int cmp_ex(const void *a, const void *b)
 	const struct exception_table_entry *x = a, *y = b;
 
 	/* avoid overflow */
-	if (x->insn > y->insn)
+	if (ex_to_insn(x) > ex_to_insn(y))
 		return 1;
-	if (x->insn < y->insn)
+	if (ex_to_insn(x) < ex_to_insn(y))
 		return -1;
 	return 0;
 }
@@ -37,7 +67,7 @@ void sort_extable(struct exception_table_entry *start,
 		  struct exception_table_entry *finish)
 {
 	sort(start, finish - start, sizeof(struct exception_table_entry),
-	     cmp_ex, NULL);
+	     cmp_ex, swap_ex);
 }
 
 #ifdef CONFIG_MODULES
@@ -48,13 +78,15 @@ void sort_extable(struct exception_table_entry *start,
 void trim_init_extable(struct module *m)
 {
 	/*trim the beginning*/
-	while (m->num_exentries && within_module_init(m->extable[0].insn, m)) {
+	while (m->num_exentries &&
+	       within_module_init(ex_to_insn(&m->extable[0]), m)) {
 		m->extable++;
 		m->num_exentries--;
 	}
 	/*trim the end*/
 	while (m->num_exentries &&
-		within_module_init(m->extable[m->num_exentries-1].insn, m))
+	       within_module_init(ex_to_insn(&m->extable[m->num_exentries - 1]),
+				  m))
 		m->num_exentries--;
 }
 #endif /* CONFIG_MODULES */
@@ -81,13 +113,13 @@ search_extable(const struct exception_table_entry *first,
 		 * careful, the distance between value and insn
 		 * can be larger than MAX_LONG:
 		 */
-		if (mid->insn < value)
+		if (ex_to_insn(mid) < value)
 			first = mid + 1;
-		else if (mid->insn > value)
+		else if (ex_to_insn(mid) > value)
 			last = mid - 1;
 		else
 			return mid;
-        }
-        return NULL;
+	}
+	return NULL;
 }
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1301090 — Re: [PATCH 1/6] extable: add support for relative extables to search and sort routines

FromHelge Deller <deller@gmx.de>
Date2016-01-04 22:10 +0100
SubjectRe: [PATCH 1/6] extable: add support for relative extables to search and sort routines
Message-ID<qNky6-oU-7@gated-at.bofh.it>
In reply to#1300325
On 03.01.2016 17:05, Ard Biesheuvel wrote:
> This adds support to the generic search_extable() and sort_extable()
> implementations for dealing with exception table entries whose fields
> contain relative offsets rather than absolute addresses.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

I tested the generic parts with an upcoming patch which handles relative
exception tables on the parisc platform.
Everything worked as expected.
So for the non arch-relevant changes:
Acked-by: Helge Deller <deller@gmx.de>


Helge

> ---
>  lib/extable.c | 50 ++++++++++++++++----
>  1 file changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/extable.c b/lib/extable.c
> index 4cac81ec225e..0be02ad561e9 100644
> --- a/lib/extable.c
> +++ b/lib/extable.c
> @@ -14,7 +14,37 @@
>  #include <linux/sort.h>
>  #include <asm/uaccess.h>
>  
> +#ifndef ARCH_HAS_RELATIVE_EXTABLE
> +#define ex_to_insn(x)	((x)->insn)
> +#else
> +static inline unsigned long ex_to_insn(const struct exception_table_entry *x)
> +{
> +	return (unsigned long)&x->insn + x->insn;
> +}
> +#endif
> +
>  #ifndef ARCH_HAS_SORT_EXTABLE
> +#ifndef ARCH_HAS_RELATIVE_EXTABLE
> +#define swap_ex		NULL
> +#else
> +static void swap_ex(void *a, void *b, int size)
> +{
> +	struct exception_table_entry *x = a, *y = b, tmp;
> +	int delta = b - a;
> +
> +	tmp = *x;
> +	x->insn = y->insn + delta;
> +	y->insn = tmp.insn - delta;
> +
> +#ifdef swap_ex_entry_fixup
> +	swap_ex_entry_fixup(x, y, tmp, delta);
> +#else
> +	x->fixup = y->fixup + delta;
> +	y->fixup = tmp.fixup - delta;
> +#endif
> +}
> +#endif /* ARCH_HAS_RELATIVE_EXTABLE */
> +
>  /*
>   * The exception table needs to be sorted so that the binary
>   * search that we use to find entries in it works properly.
> @@ -26,9 +56,9 @@ static int cmp_ex(const void *a, const void *b)
>  	const struct exception_table_entry *x = a, *y = b;
>  
>  	/* avoid overflow */
> -	if (x->insn > y->insn)
> +	if (ex_to_insn(x) > ex_to_insn(y))
>  		return 1;
> -	if (x->insn < y->insn)
> +	if (ex_to_insn(x) < ex_to_insn(y))
>  		return -1;
>  	return 0;
>  }
> @@ -37,7 +67,7 @@ void sort_extable(struct exception_table_entry *start,
>  		  struct exception_table_entry *finish)
>  {
>  	sort(start, finish - start, sizeof(struct exception_table_entry),
> -	     cmp_ex, NULL);
> +	     cmp_ex, swap_ex);
>  }
>  
>  #ifdef CONFIG_MODULES
> @@ -48,13 +78,15 @@ void sort_extable(struct exception_table_entry *start,
>  void trim_init_extable(struct module *m)
>  {
>  	/*trim the beginning*/
> -	while (m->num_exentries && within_module_init(m->extable[0].insn, m)) {
> +	while (m->num_exentries &&
> +	       within_module_init(ex_to_insn(&m->extable[0]), m)) {
>  		m->extable++;
>  		m->num_exentries--;
>  	}
>  	/*trim the end*/
>  	while (m->num_exentries &&
> -		within_module_init(m->extable[m->num_exentries-1].insn, m))
> +	       within_module_init(ex_to_insn(&m->extable[m->num_exentries - 1]),
> +				  m))
>  		m->num_exentries--;
>  }
>  #endif /* CONFIG_MODULES */
> @@ -81,13 +113,13 @@ search_extable(const struct exception_table_entry *first,
>  		 * careful, the distance between value and insn
>  		 * can be larger than MAX_LONG:
>  		 */
> -		if (mid->insn < value)
> +		if (ex_to_insn(mid) < value)
>  			first = mid + 1;
> -		else if (mid->insn > value)
> +		else if (ex_to_insn(mid) > value)
>  			last = mid - 1;
>  		else
>  			return mid;
> -        }
> -        return NULL;
> +	}
> +	return NULL;
>  }
>  #endif
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300326 — [PATCH 5/6] ia64/extable: use generic search and sort routines

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-03 17:10 +0100
Subject[PATCH 5/6] ia64/extable: use generic search and sort routines
Message-ID<qMToe-7DP-23@gated-at.bofh.it>
In reply to#1300324
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.

Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300327 — [PATCH 4/6] x86/extable: use generic search and sort routines

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-03 17:10 +0100
Subject[PATCH 4/6] x86/extable: use generic search and sort routines
Message-ID<qMToe-7DP-25@gated-at.bofh.it>
In reply to#1300324
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.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/x86/include/asm/uaccess.h |   5 +-
 arch/x86/mm/extable.c          | 106 +-------------------
 2 files changed, 4 insertions(+), 107 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 09b1b0ab94b7..6d130c4cb7de 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -106,9 +106,8 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
 struct exception_table_entry {
 	int insn, fixup;
 };
-/* 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);
 extern int early_fixup_exception(unsigned long *ip);
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 903ec1e9c326..0b172b656f43 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -1,14 +1,9 @@
+
 #include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/sort.h>
+
 #include <asm/uaccess.h>
 
 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;
@@ -70,100 +65,3 @@ int __init early_fixup_exception(unsigned long *ip)
 
 	return 0;
 }
-
-/*
- * 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;
-	}
-
-	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;
-	}
-}
-
-#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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300329 — [PATCH 6/6] arm64: switch to relative exception tables

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-03 17:10 +0100
Subject[PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qMToe-7DP-27@gated-at.bofh.it>
In reply to#1300324
Instead of using absolute addresses for both the exception location
and the fixup, use offsets relative to the exception table entry values.
Not only does this cut the size of the exception table in half, it is
also a prerequisite for KASLR, since absolute exception table entries
are subject to dynamic relocation, which is incompatible with the sorting
of the exception table that occurs at build time.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---

Note that this patch supersedes the version I sent as part of the series that
implements KASLR for arm64: http://thread.gmane.org/gmane.linux.kernel/2116531

 arch/arm64/include/asm/assembler.h   |  2 +-
 arch/arm64/include/asm/futex.h       |  4 ++--
 arch/arm64/include/asm/uaccess.h     | 18 ++++++++++--------
 arch/arm64/kernel/armv8_deprecated.c |  4 ++--
 arch/arm64/mm/extable.c              |  2 +-
 scripts/sortextable.c                |  2 +-
 6 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 12eff928ef8b..8094d50f05bc 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -98,7 +98,7 @@
 9999:	x;					\
 	.section __ex_table,"a";		\
 	.align	3;				\
-	.quad	9999b,l;			\
+	.long	(9999b - .), (l - .);		\
 	.previous
 
 /*
diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
index 007a69fc4f40..35e73e255ad3 100644
--- a/arch/arm64/include/asm/futex.h
+++ b/arch/arm64/include/asm/futex.h
@@ -44,7 +44,7 @@
 "	.popsection\n"							\
 "	.pushsection __ex_table,\"a\"\n"				\
 "	.align	3\n"							\
-"	.quad	1b, 4b, 2b, 4b\n"					\
+"	.long	(1b - .), (4b - .), (2b - .), (4b - .)\n"		\
 "	.popsection\n"							\
 	ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,		\
 		    CONFIG_ARM64_PAN)					\
@@ -135,7 +135,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 "	.popsection\n"
 "	.pushsection __ex_table,\"a\"\n"
 "	.align	3\n"
-"	.quad	1b, 4b, 2b, 4b\n"
+"	.long	(1b - .), (4b - .), (2b - .), (4b - .)\n"
 "	.popsection\n"
 	: "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp)
 	: "r" (oldval), "r" (newval), "Ir" (-EFAULT)
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index b2ede967fe7d..ab627e6c06c9 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -36,11 +36,11 @@
 #define VERIFY_WRITE 1
 
 /*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue.  No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
+ * The exception table consists of pairs of relative offsets: the first
+ * is the relative offset to an instruction that is allowed to fault,
+ * and the second is the relative offset at which the program should
+ * continue. No registers are modified, so it is entirely up to the
+ * continuation code to figure out what to do.
  *
  * All the routines below use bits of fixup code that are out of line
  * with the main instruction path.  This means when everything is well,
@@ -50,9 +50,11 @@
 
 struct exception_table_entry
 {
-	unsigned long insn, fixup;
+	int insn, fixup;
 };
 
+#define ARCH_HAS_RELATIVE_EXTABLE
+
 extern int fixup_exception(struct pt_regs *regs);
 
 #define KERNEL_DS	(-1UL)
@@ -125,7 +127,7 @@ static inline void set_fs(mm_segment_t fs)
 	"	.previous\n"						\
 	"	.section __ex_table,\"a\"\n"				\
 	"	.align	3\n"						\
-	"	.quad	1b, 3b\n"					\
+	"	.long	(1b - .), (3b - .)\n"				\
 	"	.previous"						\
 	: "+r" (err), "=&r" (x)						\
 	: "r" (addr), "i" (-EFAULT))
@@ -192,7 +194,7 @@ do {									\
 	"	.previous\n"						\
 	"	.section __ex_table,\"a\"\n"				\
 	"	.align	3\n"						\
-	"	.quad	1b, 3b\n"					\
+	"	.long	(1b - .), (3b - .)\n"				\
 	"	.previous"						\
 	: "+r" (err)							\
 	: "r" (x), "r" (addr), "i" (-EFAULT))
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index 937f5e58a4d3..8f21b1363387 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -299,8 +299,8 @@ static void register_insn_emulation_sysctl(struct ctl_table *table)
 	"	.popsection"					\
 	"	.pushsection	 __ex_table,\"a\"\n"		\
 	"	.align		3\n"				\
-	"	.quad		0b, 4b\n"			\
-	"	.quad		1b, 4b\n"			\
+	"	.long		(0b - .), (4b - .)\n"		\
+	"	.long		(1b - .), (4b - .)\n"		\
 	"	.popsection\n"					\
 	ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,	\
 		CONFIG_ARM64_PAN)				\
diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c
index 79444279ba8c..81acd4706878 100644
--- a/arch/arm64/mm/extable.c
+++ b/arch/arm64/mm/extable.c
@@ -11,7 +11,7 @@ int fixup_exception(struct pt_regs *regs)
 
 	fixup = search_exception_tables(instruction_pointer(regs));
 	if (fixup)
-		regs->pc = fixup->fixup;
+		regs->pc = (unsigned long)&fixup->fixup + fixup->fixup;
 
 	return fixup != NULL;
 }
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index c2423d913b46..af247c70fb66 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -282,12 +282,12 @@ do_file(char const *const fname)
 	case EM_386:
 	case EM_X86_64:
 	case EM_S390:
+	case EM_AARCH64:
 		custom_sort = sort_relative_table;
 		break;
 	case EM_ARCOMPACT:
 	case EM_ARCV2:
 	case EM_ARM:
-	case EM_AARCH64:
 	case EM_MICROBLAZE:
 	case EM_MIPS:
 	case EM_XTENSA:
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300786 — Re: [PATCH 6/6] arm64: switch to relative exception tables

FromWill Deacon <will.deacon@arm.com>
Date2016-01-04 15:50 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNeCl-4IB-9@gated-at.bofh.it>
In reply to#1300329
On Sun, Jan 03, 2016 at 05:05:57PM +0100, Ard Biesheuvel wrote:
> Instead of using absolute addresses for both the exception location
> and the fixup, use offsets relative to the exception table entry values.
> Not only does this cut the size of the exception table in half, it is
> also a prerequisite for KASLR, since absolute exception table entries
> are subject to dynamic relocation, which is incompatible with the sorting
> of the exception table that occurs at build time.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> 
> Note that this patch supersedes the version I sent as part of the series that
> implements KASLR for arm64: http://thread.gmane.org/gmane.linux.kernel/2116531
> 
>  arch/arm64/include/asm/assembler.h   |  2 +-
>  arch/arm64/include/asm/futex.h       |  4 ++--
>  arch/arm64/include/asm/uaccess.h     | 18 ++++++++++--------
>  arch/arm64/kernel/armv8_deprecated.c |  4 ++--
>  arch/arm64/mm/extable.c              |  2 +-
>  scripts/sortextable.c                |  2 +-
>  6 files changed, 17 insertions(+), 15 deletions(-)

This looks good to me, so for the arm64 part (i.e. this patch):

  Acked-by: Will Deacon <will.deacon@arm.com>

Will

> diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
> index 12eff928ef8b..8094d50f05bc 100644
> --- a/arch/arm64/include/asm/assembler.h
> +++ b/arch/arm64/include/asm/assembler.h
> @@ -98,7 +98,7 @@
>  9999:	x;					\
>  	.section __ex_table,"a";		\
>  	.align	3;				\
> -	.quad	9999b,l;			\
> +	.long	(9999b - .), (l - .);		\
>  	.previous
>  
>  /*
> diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
> index 007a69fc4f40..35e73e255ad3 100644
> --- a/arch/arm64/include/asm/futex.h
> +++ b/arch/arm64/include/asm/futex.h
> @@ -44,7 +44,7 @@
>  "	.popsection\n"							\
>  "	.pushsection __ex_table,\"a\"\n"				\
>  "	.align	3\n"							\
> -"	.quad	1b, 4b, 2b, 4b\n"					\
> +"	.long	(1b - .), (4b - .), (2b - .), (4b - .)\n"		\
>  "	.popsection\n"							\
>  	ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,		\
>  		    CONFIG_ARM64_PAN)					\
> @@ -135,7 +135,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
>  "	.popsection\n"
>  "	.pushsection __ex_table,\"a\"\n"
>  "	.align	3\n"
> -"	.quad	1b, 4b, 2b, 4b\n"
> +"	.long	(1b - .), (4b - .), (2b - .), (4b - .)\n"
>  "	.popsection\n"
>  	: "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp)
>  	: "r" (oldval), "r" (newval), "Ir" (-EFAULT)
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index b2ede967fe7d..ab627e6c06c9 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -36,11 +36,11 @@
>  #define VERIFY_WRITE 1
>  
>  /*
> - * The exception table consists of pairs of addresses: the first is the
> - * address of an instruction that is allowed to fault, and the second is
> - * the address at which the program should continue.  No registers are
> - * modified, so it is entirely up to the continuation code to figure out
> - * what to do.
> + * The exception table consists of pairs of relative offsets: the first
> + * is the relative offset to an instruction that is allowed to fault,
> + * and the second is the relative offset at which the program should
> + * continue. No registers are modified, so it is entirely up to the
> + * continuation code to figure out what to do.
>   *
>   * All the routines below use bits of fixup code that are out of line
>   * with the main instruction path.  This means when everything is well,
> @@ -50,9 +50,11 @@
>  
>  struct exception_table_entry
>  {
> -	unsigned long insn, fixup;
> +	int insn, fixup;
>  };
>  
> +#define ARCH_HAS_RELATIVE_EXTABLE
> +
>  extern int fixup_exception(struct pt_regs *regs);
>  
>  #define KERNEL_DS	(-1UL)
> @@ -125,7 +127,7 @@ static inline void set_fs(mm_segment_t fs)
>  	"	.previous\n"						\
>  	"	.section __ex_table,\"a\"\n"				\
>  	"	.align	3\n"						\
> -	"	.quad	1b, 3b\n"					\
> +	"	.long	(1b - .), (3b - .)\n"				\
>  	"	.previous"						\
>  	: "+r" (err), "=&r" (x)						\
>  	: "r" (addr), "i" (-EFAULT))
> @@ -192,7 +194,7 @@ do {									\
>  	"	.previous\n"						\
>  	"	.section __ex_table,\"a\"\n"				\
>  	"	.align	3\n"						\
> -	"	.quad	1b, 3b\n"					\
> +	"	.long	(1b - .), (3b - .)\n"				\
>  	"	.previous"						\
>  	: "+r" (err)							\
>  	: "r" (x), "r" (addr), "i" (-EFAULT))
> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> index 937f5e58a4d3..8f21b1363387 100644
> --- a/arch/arm64/kernel/armv8_deprecated.c
> +++ b/arch/arm64/kernel/armv8_deprecated.c
> @@ -299,8 +299,8 @@ static void register_insn_emulation_sysctl(struct ctl_table *table)
>  	"	.popsection"					\
>  	"	.pushsection	 __ex_table,\"a\"\n"		\
>  	"	.align		3\n"				\
> -	"	.quad		0b, 4b\n"			\
> -	"	.quad		1b, 4b\n"			\
> +	"	.long		(0b - .), (4b - .)\n"		\
> +	"	.long		(1b - .), (4b - .)\n"		\
>  	"	.popsection\n"					\
>  	ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,	\
>  		CONFIG_ARM64_PAN)				\
> diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c
> index 79444279ba8c..81acd4706878 100644
> --- a/arch/arm64/mm/extable.c
> +++ b/arch/arm64/mm/extable.c
> @@ -11,7 +11,7 @@ int fixup_exception(struct pt_regs *regs)
>  
>  	fixup = search_exception_tables(instruction_pointer(regs));
>  	if (fixup)
> -		regs->pc = fixup->fixup;
> +		regs->pc = (unsigned long)&fixup->fixup + fixup->fixup;
>  
>  	return fixup != NULL;
>  }
> diff --git a/scripts/sortextable.c b/scripts/sortextable.c
> index c2423d913b46..af247c70fb66 100644
> --- a/scripts/sortextable.c
> +++ b/scripts/sortextable.c
> @@ -282,12 +282,12 @@ do_file(char const *const fname)
>  	case EM_386:
>  	case EM_X86_64:
>  	case EM_S390:
> +	case EM_AARCH64:
>  		custom_sort = sort_relative_table;
>  		break;
>  	case EM_ARCOMPACT:
>  	case EM_ARCV2:
>  	case EM_ARM:
> -	case EM_AARCH64:
>  	case EM_MICROBLAZE:
>  	case EM_MIPS:
>  	case EM_XTENSA:
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300924 — Re: [PATCH 6/6] arm64: switch to relative exception tables

From"H. Peter Anvin" <hpa@zytor.com>
Date2016-01-04 19:20 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNhTA-73f-11@gated-at.bofh.it>
In reply to#1300786
On 01/04/2016 06:46 AM, Will Deacon wrote:
> On Sun, Jan 03, 2016 at 05:05:57PM +0100, Ard Biesheuvel wrote:
>> Instead of using absolute addresses for both the exception location
>> and the fixup, use offsets relative to the exception table entry values.
>> Not only does this cut the size of the exception table in half, it is
>> also a prerequisite for KASLR, since absolute exception table entries
>> are subject to dynamic relocation, which is incompatible with the sorting
>> of the exception table that occurs at build time.
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>>
>> Note that this patch supersedes the version I sent as part of the series that
>> implements KASLR for arm64: http://thread.gmane.org/gmane.linux.kernel/2116531
>>
>>  arch/arm64/include/asm/assembler.h   |  2 +-
>>  arch/arm64/include/asm/futex.h       |  4 ++--
>>  arch/arm64/include/asm/uaccess.h     | 18 ++++++++++--------
>>  arch/arm64/kernel/armv8_deprecated.c |  4 ++--
>>  arch/arm64/mm/extable.c              |  2 +-
>>  scripts/sortextable.c                |  2 +-
>>  6 files changed, 17 insertions(+), 15 deletions(-)
> 
> This looks good to me, so for the arm64 part (i.e. this patch):
> 
>   Acked-by: Will Deacon <will.deacon@arm.com>

May I humbly ask why the [Finnish] you don't use the equivalent of the
x86 _ASM_EXTABLE() macro?  In fact, why don't we make that one generic, too?

	-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300934 — RE: [PATCH 6/6] arm64: switch to relative exception tables

From"Luck, Tony" <tony.luck@intel.com>
Date2016-01-04 19:30 +0100
SubjectRE: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNi3g-76n-9@gated-at.bofh.it>
In reply to#1300924
PiBNYXkgSSBodW1ibHkgYXNrIHdoeSB0aGUgW0Zpbm5pc2hdIHlvdSBkb24ndCB1c2UgdGhlIGVx
dWl2YWxlbnQgb2YgdGhlDQo+IHg4NiBfQVNNX0VYVEFCTEUoKSBtYWNybz8gIEluIGZhY3QsIHdo
eSBkb24ndCB3ZSBtYWtlIHRoYXQgb25lIGdlbmVyaWMsIHRvbz8NCg0KSSdtIG1lc3Npbmcgd2l0
aCB0aGF0IHJpZ2h0IG5vdyAod2l0aCBoZWxwIGZyb20gQW5keSBMdXRvbWlyc2tpIGFuZCBCb3Jp
cykgdG8NCmFkZCBkaWZmZXJlbnQgY2xhc3NlcyBvZiBleGNlcHRpb24gdGFibGUgKHNvIEkgY2Fu
IHRhZyBzb21lIGluc3RydWN0aW9ucyBhcyBiZWluZw0Kc3VpdGFibGUgZm9yIGZpeHVwIGZyb20g
dGhlIG1hY2hpbmUgY2hlY2sgaGFuZGxlcikuICBTbyBpdCBtaWdodCBub3QgYmUgZ2VuZXJpYw0K
Zm9yIG11Y2ggbG9uZ2VyLg0KDQpodHRwOi8vbWFyYy5pbmZvLz9sPWxpbnV4LWtlcm5lbCZtPTE0
NTE4NzA3OTUwNDg0NiZ3PTINCg0KLVRvbnkNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300960 — Re: [PATCH 6/6] arm64: switch to relative exception tables

From"H. Peter Anvin" <hpa@zytor.com>
Date2016-01-04 19:50 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNimC-7d3-5@gated-at.bofh.it>
In reply to#1300934
On 01/04/2016 10:20 AM, Luck, Tony wrote:
>> May I humbly ask why the [Finnish] you don't use the equivalent of the
>> x86 _ASM_EXTABLE() macro?  In fact, why don't we make that one generic, too?
> 
> I'm messing with that right now (with help from Andy Lutomirski and Boris) to
> add different classes of exception table (so I can tag some instructions as being
> suitable for fixup from the machine check handler).  So it might not be generic
> for much longer.
> 
> http://marc.info/?l=linux-kernel&m=145187079504846&w=2
> 

That doesn't mean it can't be overridden.

	-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300987 — Re: [PATCH 6/6] arm64: switch to relative exception tables

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-01-04 20:30 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNiZk-7GT-7@gated-at.bofh.it>
In reply to#1300934
On 4 January 2016 at 20:21, H. Peter Anvin <hpa@zytor.com> wrote:
> On 01/04/2016 10:20 AM, Luck, Tony wrote:
>>> May I humbly ask why the [Finnish] you don't use the equivalent of the
>>> x86 _ASM_EXTABLE() macro?  In fact, why don't we make that one generic, too?
>>
>> I'm messing with that right now (with help from Andy Lutomirski and Boris) to
>> add different classes of exception table (so I can tag some instructions as being
>> suitable for fixup from the machine check handler).  So it might not be generic
>> for much longer.
>>
>> http://marc.info/?l=linux-kernel&m=145187079504846&w=2
>>
>
> I suspect that means we will also need to go back to arch-specific
> sorting for x86.
>

AFAICT, Tony's patches are not incompatible with mine. The fixup
address is offset with a large constant, but this does not affect the
sort order (since that is based on the other member), and the swap
operation that adds/subtracts the delta should not care about the
class bits. (I don't see any changes to sort_extable() in Tony's
patch)

@Tony: any comments? And do you have any objections to the ia64 patch
in this series?

I agree that it makes sense to define a macro to emit the extable
entries in this patch, but I am not sure how that extrapolates to the
other architectures, and testing those is going to be cumbersome for
me, so I'd prefer to keep that a local change for arm64 for now.

Thanks,
Ard.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1301002 — Re: [PATCH 6/6] arm64: switch to relative exception tables

From"Luck, Tony" <tony.luck@intel.com>
Date2016-01-04 20:50 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNjiI-7Q7-75@gated-at.bofh.it>
In reply to#1300987
On Mon, Jan 04, 2016 at 08:28:52PM +0100, Ard Biesheuvel wrote:
> On 4 January 2016 at 20:21, H. Peter Anvin <hpa@zytor.com> wrote:
> > I suspect that means we will also need to go back to arch-specific
> > sorting for x86.
> >
> 
> AFAICT, Tony's patches are not incompatible with mine. The fixup
> address is offset with a large constant, but this does not affect the
> sort order (since that is based on the other member), and the swap
> operation that adds/subtracts the delta should not care about the
> class bits. (I don't see any changes to sort_extable() in Tony's
> patch)

Correct. Sorting is by the "insn" field (which I did not change).
The "fixup" field is just modified by an offset value, so survives
the math when moved to a new slot by the sort.

> @Tony: any comments? And do you have any objections to the ia64 patch
> in this series?
The ia64 bits look OK. I haven't tested, but add my Acked-by: anyway.

-Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300990 — Re: [PATCH 6/6] arm64: switch to relative exception tables

From"H. Peter Anvin" <hpa@zytor.com>
Date2016-01-04 20:30 +0100
SubjectRe: [PATCH 6/6] arm64: switch to relative exception tables
Message-ID<qNiZk-7GT-9@gated-at.bofh.it>
In reply to#1300934
On 01/04/2016 10:20 AM, Luck, Tony wrote:
>> May I humbly ask why the [Finnish] you don't use the equivalent of the
>> x86 _ASM_EXTABLE() macro?  In fact, why don't we make that one generic, too?
> 
> I'm messing with that right now (with help from Andy Lutomirski and Boris) to
> add different classes of exception table (so I can tag some instructions as being
> suitable for fixup from the machine check handler).  So it might not be generic
> for much longer.
> 
> http://marc.info/?l=linux-kernel&m=145187079504846&w=2
> 

I suspect that means we will also need to go back to arch-specific
sorting for x86.

	-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300642

FromHeiko Carstens <heiko.carstens@de.ibm.com>
Date2016-01-04 12:30 +0100
Message-ID<qNbuO-2MN-19@gated-at.bofh.it>
In reply to#1300324
On Sun, Jan 03, 2016 at 05:05:51PM +0100, Ard Biesheuvel wrote:
> 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).
> 
> Note that the s390 patch applies on top of the following patch:
> 
>   http://article.gmane.org/gmane.linux.kernel/2117036
> 
> which fixes a bug I spotted while working on this code. Since that probably
> needs to go to -stable, I broke it out and posted it separately.
> 
> Ard Biesheuvel (6):
>   extable: add support for relative extables to search and sort routines
>   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
>   arm64: switch to relative exception tables

For the s390 bits:

Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300923

From"H. Peter Anvin" <hpa@zytor.com>
Date2016-01-04 19:20 +0100
Message-ID<qNhTA-73f-1@gated-at.bofh.it>
In reply to#1300642
On 01/04/2016 03:20 AM, Heiko Carstens wrote:
> On Sun, Jan 03, 2016 at 05:05:51PM +0100, Ard Biesheuvel wrote:
>> 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).
>>
>> Note that the s390 patch applies on top of the following patch:
>>
>>   http://article.gmane.org/gmane.linux.kernel/2117036
>>
>> which fixes a bug I spotted while working on this code. Since that probably
>> needs to go to -stable, I broke it out and posted it separately.
>>
>> Ard Biesheuvel (6):
>>   extable: add support for relative extables to search and sort routines
>>   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
>>   arm64: switch to relative exception tables
> 
> For the s390 bits:
> 
> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> 

For the x86 bits:

Acked-by: H. Peter Anvin <hpa@linux.intel.com>

*However*, please see my comment about generalizing _ASM_EXTABLE() for
the non-x86 architectures.

	-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web