Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1300326
| Path | csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod |
|---|---|
| From | Ard Biesheuvel <ard.biesheuvel@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/6] ia64/extable: use generic search and sort routines |
| Date | Sun, 03 Jan 2016 17:10:02 +0100 |
| Message-ID | <qMToe-7DP-23@gated-at.bofh.it> (permalink) |
| References | <qMTod-7DP-3@gated-at.bofh.it> |
| X-Original-To | linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, x86@kernel.org, hpa@zytor.com, mingo@redhat.com, heiko.carstens@de.ibm.com, schwidefsky@de.ibm.com, mattst88@gmail.com, ink@jurassic.park.msu.ru, rth@twiddle.net, tony.luck@intel.com, fenghua.yu@intel.com, catalin.marinas@arm.com, will.deacon@arm.com, arnd@arndb.de, akpm@linux-foundation.org |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sBg/q0MZi6S3qTUfctnQJTiQTnrPAWw373rJs7eEINs=; b=Gtvrd2NTzltLlU16np38XLaTYlCL0hpQdWG/FMPTbUUNvRYSLyv5PuwHa5W+cXDaSG szdUqfTNV5lOjd7gvxyropbVoYaFNygxY0ZfJsdALXnmP3Gn2K/GZJh9nqOJOZU1TOL+ hTLsywigUJ4BdvOfZ44h9sNI89Z2jR2kDMdHY= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sBg/q0MZi6S3qTUfctnQJTiQTnrPAWw373rJs7eEINs=; b=dZl6PDeO/Z+30cHWr1M9Vdg5fgd/kTpAWCfz3IL+YPyYxp5EuA8kDtfIMlQ7MAHBEf rRD4DlSPPZneFF9uDwUQLwy8ruJdCHovvUmj5hc+4xrhfmZ3fZrSe7h3JrhzxZsKXQkD h+P5jes3as1SJqrEaA6POB+3pFOa93rM0O2D0ahYa2nVIckmiZjnpYZvxR5e+qey/tcf okR4ckL6bVqMFWp3Ypkj5SPV07yi4Flv34oanj1B0VC3A8aCQryqqkmzb5UHXX1CY3m1 QIFiE/DzkSSNfJN7likxbDru3rfuD92FaN32cPqTOJPA9EE4/5AOm++aSqX9z+gyOZJE AYug== |
| X-Gm-Message-State | ALoCoQlg872zO1P6QFYrCL7GbyjHy5+H7wTRqKv6poNICpsKGhaef/fUAiwRh67vqmcuOqzV8uENK48P7mn3BBHECdWvkIk0DA== |
| X-Received | by 10.28.223.67 with SMTP id w64mr45250264wmg.28.1451837187517; Sun, 03 Jan 2016 08:06:27 -0800 (PST) |
| X-Mailer | git-send-email 1.9.1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 154 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | mark.rutland@arm.com, marc.zyngier@arm.com, Ard Biesheuvel <ard.biesheuvel@linaro.org> |
| X-Original-Date | Sun, 3 Jan 2016 17:05:56 +0100 |
| X-Original-Message-ID | <1451837157-447-6-git-send-email-ard.biesheuvel@linaro.org> |
| X-Original-References | <1451837157-447-1-git-send-email-ard.biesheuvel@linaro.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1300326 |
Show key headers only | View raw
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[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
csiph-web