All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Speed booting by sorting exception tables at build time.
@ 2012-04-19 21:59 David Daney
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
                   ` (4 more replies)
  0 siblings, 5 replies; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

v2: Cosmetic changes only.  Cleanup makefile indentation.  Rebase MIPS
    and x86 Kconfig changes against 3.4-rc2.

    Michal Marek had suggested using $(call cmd,sortextable), but I
    wasn't able to figure out a good way to do that *and* have it print
    'SORTEX vmlinux', so I left it as I originally had it.

v1:

I noticed when booting MIPS64 kernels that sorting of the main
__ex_table was taking a long time (2,692,220 cycles or 3.3 mS at
800MHz to be exact).  That is not too bad for real silicon
implementations, but when running on a slow simulator, it can be
significant.

I can get this down to about 1,000,000 cycles by supplying a custom
swap function for the sort, but even better is to eliminate it
entirely by doing the sort at build time. That is the idea behind
this patch set.

Here is more or less what I did:

o A flag word is added to the kernel to indicate that the __ex_table
  is already sorted.  sort_main_extable() checks this and if it is
  clear, returns without doing the sort.

o I shamelessly stole code from recordmcount and created a new build
  time helper program 'sortextable'.  This is run on the final vmlinux
  image, it sorts the table, and then clears the flag word.

Potential areas for improvement:

o Sort module exception tables too.

o Get rid of the flag word, and assume that if an architecture supports
  build time sorting, that it must have been done.

o Add support for architectures other than MIPS and x86

David Daney (5):
  scripts: Add sortextable to sort the kernel's exception table.
  extable: Skip sorting if sorted at build time.
  kbuild/extable: Hook up sortextable into the build system.
  MIPS: Select BUILDTIME_EXTABLE_SORT
  x86: Select BUILDTIME_EXTABLE_SORT

 Makefile              |   10 ++
 arch/mips/Kconfig     |    1 +
 arch/x86/Kconfig      |    1 +
 init/Kconfig          |    3 +
 kernel/extable.c      |    8 ++-
 scripts/.gitignore    |    1 +
 scripts/Makefile      |    1 +
 scripts/sortextable.c |  273 +++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/sortextable.h |  168 ++++++++++++++++++++++++++++++
 9 files changed, 465 insertions(+), 1 deletions(-)
 create mode 100644 scripts/sortextable.c
 create mode 100644 scripts/sortextable.h

-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
@ 2012-04-19 21:59 ` David Daney
  2012-04-20  0:20   ` [tip:x86/extable] scripts: Add sortextable to sort the kernel' s " tip-bot for David Daney
                     ` (2 more replies)
  2012-04-19 21:59 ` [PATCH v2 2/5] extable: Skip sorting if sorted at build time David Daney
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

Using this build-time sort saves time booting as we don't have to burn
cycles sorting the exception table.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 scripts/.gitignore    |    1 +
 scripts/Makefile      |    1 +
 scripts/sortextable.c |  273 +++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/sortextable.h |  168 ++++++++++++++++++++++++++++++
 4 files changed, 443 insertions(+), 0 deletions(-)
 create mode 100644 scripts/sortextable.c
 create mode 100644 scripts/sortextable.h

diff --git a/scripts/.gitignore b/scripts/.gitignore
index 105b21f..65f362d 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -9,3 +9,4 @@ unifdef
 ihex2fw
 recordmcount
 docproc
+sortextable
diff --git a/scripts/Makefile b/scripts/Makefile
index df7678f..43e19b9 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -13,6 +13,7 @@ hostprogs-$(CONFIG_LOGO)         += pnmtologo
 hostprogs-$(CONFIG_VT)           += conmakehash
 hostprogs-$(CONFIG_IKCONFIG)     += bin2c
 hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
+hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable
 
 always		:= $(hostprogs-y) $(hostprogs-m)
 
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
new file mode 100644
index 0000000..6546785
--- /dev/null
+++ b/scripts/sortextable.c
@@ -0,0 +1,273 @@
+/*
+ * sortextable.c: Sort the kernel's exception table
+ *
+ * Copyright 2011 Cavium, Inc.
+ *
+ * Based on code taken from recortmcount.c which is:
+ *
+ * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.
+ * Licensed under the GNU General Public License, version 2 (GPLv2).
+ *
+ * Restructured to fit Linux format, as well as other updates:
+ *  Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
+ */
+
+/*
+ * Strategy: alter the vmlinux file in-place.
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <getopt.h>
+#include <elf.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static int fd_map;	/* File descriptor for file being modified. */
+static int mmap_failed; /* Boolean flag. */
+static void *ehdr_curr; /* current ElfXX_Ehdr *  for resource cleanup */
+static struct stat sb;	/* Remember .st_size, etc. */
+static jmp_buf jmpenv;	/* setjmp/longjmp per-file error escape */
+
+/* setjmp() return values */
+enum {
+	SJ_SETJMP = 0,  /* hardwired first return */
+	SJ_FAIL,
+	SJ_SUCCEED
+};
+
+/* Per-file resource cleanup when multiple files. */
+static void
+cleanup(void)
+{
+	if (!mmap_failed)
+		munmap(ehdr_curr, sb.st_size);
+	close(fd_map);
+}
+
+static void __attribute__((noreturn))
+fail_file(void)
+{
+	cleanup();
+	longjmp(jmpenv, SJ_FAIL);
+}
+
+static void __attribute__((noreturn))
+succeed_file(void)
+{
+	cleanup();
+	longjmp(jmpenv, SJ_SUCCEED);
+}
+
+
+/*
+ * Get the whole file as a programming convenience in order to avoid
+ * malloc+lseek+read+free of many pieces.  If successful, then mmap
+ * avoids copying unused pieces; else just read the whole file.
+ * Open for both read and write.
+ */
+static void *mmap_file(char const *fname)
+{
+	void *addr;
+
+	fd_map = open(fname, O_RDWR);
+	if (fd_map < 0 || fstat(fd_map, &sb) < 0) {
+		perror(fname);
+		fail_file();
+	}
+	if (!S_ISREG(sb.st_mode)) {
+		fprintf(stderr, "not a regular file: %s\n", fname);
+		fail_file();
+	}
+	addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
+		    fd_map, 0);
+	if (addr == MAP_FAILED) {
+		mmap_failed = 1;
+		fprintf(stderr, "Could not mmap file: %s\n", fname);
+		fail_file();
+	}
+	return addr;
+}
+
+/* w8rev, w8nat, ...: Handle endianness. */
+
+static uint64_t w8rev(uint64_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (7 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (6 * 8))
+	       | ((0xff & (x >> (2 * 8))) << (5 * 8))
+	       | ((0xff & (x >> (3 * 8))) << (4 * 8))
+	       | ((0xff & (x >> (4 * 8))) << (3 * 8))
+	       | ((0xff & (x >> (5 * 8))) << (2 * 8))
+	       | ((0xff & (x >> (6 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (7 * 8))) << (0 * 8));
+}
+
+static uint32_t w4rev(uint32_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (3 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (2 * 8))
+	       | ((0xff & (x >> (2 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (3 * 8))) << (0 * 8));
+}
+
+static uint32_t w2rev(uint16_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (0 * 8));
+}
+
+static uint64_t w8nat(uint64_t const x)
+{
+	return x;
+}
+
+static uint32_t w4nat(uint32_t const x)
+{
+	return x;
+}
+
+static uint32_t w2nat(uint16_t const x)
+{
+	return x;
+}
+
+static uint64_t (*w8)(uint64_t);
+static uint32_t (*w)(uint32_t);
+static uint32_t (*w2)(uint16_t);
+
+
+/* 32 bit and 64 bit are very similar */
+#include "sortextable.h"
+#define SORTEXTABLE_64
+#include "sortextable.h"
+
+
+static void
+do_file(char const *const fname)
+{
+	Elf32_Ehdr *const ehdr = mmap_file(fname);
+
+	ehdr_curr = ehdr;
+	w = w4nat;
+	w2 = w2nat;
+	w8 = w8nat;
+	switch (ehdr->e_ident[EI_DATA]) {
+		static unsigned int const endian = 1;
+	default:
+		fprintf(stderr, "unrecognized ELF data encoding %d: %s\n",
+			ehdr->e_ident[EI_DATA], fname);
+		fail_file();
+		break;
+	case ELFDATA2LSB:
+		if (*(unsigned char const *)&endian != 1) {
+			/* main() is big endian, file.o is little endian. */
+			w = w4rev;
+			w2 = w2rev;
+			w8 = w8rev;
+		}
+		break;
+	case ELFDATA2MSB:
+		if (*(unsigned char const *)&endian != 0) {
+			/* main() is little endian, file.o is big endian. */
+			w = w4rev;
+			w2 = w2rev;
+			w8 = w8rev;
+		}
+		break;
+	}  /* end switch */
+	if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
+	||  w2(ehdr->e_type) != ET_EXEC
+	||  ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
+		fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname);
+		fail_file();
+	}
+
+	switch (w2(ehdr->e_machine)) {
+	default:
+		fprintf(stderr, "unrecognized e_machine %d %s\n",
+			w2(ehdr->e_machine), fname);
+		fail_file();
+		break;
+	case EM_386:
+	case EM_MIPS:
+	case EM_X86_64:
+		break;
+	}  /* end switch */
+
+	switch (ehdr->e_ident[EI_CLASS]) {
+	default:
+		fprintf(stderr, "unrecognized ELF class %d %s\n",
+			ehdr->e_ident[EI_CLASS], fname);
+		fail_file();
+		break;
+	case ELFCLASS32:
+		if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
+		||  w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
+			fprintf(stderr,
+				"unrecognized ET_EXEC file: %s\n", fname);
+			fail_file();
+		}
+		do32(ehdr, fname);
+		break;
+	case ELFCLASS64: {
+		Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr;
+		if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
+		||  w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
+			fprintf(stderr,
+				"unrecognized ET_EXEC file: %s\n", fname);
+			fail_file();
+		}
+		do64(ghdr, fname);
+		break;
+	}
+	}  /* end switch */
+
+	cleanup();
+}
+
+int
+main(int argc, char *argv[])
+{
+	int n_error = 0;  /* gcc-4.3.0 false positive complaint */
+	int i;
+
+	if (argc < 2) {
+		fprintf(stderr, "usage: sortextable vmlinux...\n");
+		return 0;
+	}
+
+	/* Process each file in turn, allowing deep failure. */
+	for (i = 1; i < argc; i++) {
+		char *file = argv[i];
+		int const sjval = setjmp(jmpenv);
+
+		switch (sjval) {
+		default:
+			fprintf(stderr, "internal error: %s\n", file);
+			exit(1);
+			break;
+		case SJ_SETJMP:    /* normal sequence */
+			/* Avoid problems if early cleanup() */
+			fd_map = -1;
+			ehdr_curr = NULL;
+			mmap_failed = 1;
+			do_file(file);
+			break;
+		case SJ_FAIL:    /* error in do_file or below */
+			++n_error;
+			break;
+		case SJ_SUCCEED:    /* premature success */
+			/* do nothing */
+			break;
+		}  /* end switch */
+	}
+	return !!n_error;
+}
+
+
diff --git a/scripts/sortextable.h b/scripts/sortextable.h
new file mode 100644
index 0000000..bb6aaf1
--- /dev/null
+++ b/scripts/sortextable.h
@@ -0,0 +1,168 @@
+/*
+ * sortextable.h
+ *
+ * Copyright 2011 Cavium, Inc.
+ *
+ * Some of this code was taken out of recordmcount.h written by:
+ *
+ * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.
+ * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
+ *
+ *
+ * Licensed under the GNU General Public License, version 2 (GPLv2).
+ */
+
+#undef extable_ent_size
+#undef compare_extable
+#undef do_func
+#undef Elf_Addr
+#undef Elf_Ehdr
+#undef Elf_Shdr
+#undef Elf_Rel
+#undef Elf_Rela
+#undef Elf_Sym
+#undef ELF_R_SYM
+#undef Elf_r_sym
+#undef ELF_R_INFO
+#undef Elf_r_info
+#undef ELF_ST_BIND
+#undef ELF_ST_TYPE
+#undef fn_ELF_R_SYM
+#undef fn_ELF_R_INFO
+#undef uint_t
+#undef _w
+
+#ifdef SORTEXTABLE_64
+# define extable_ent_size	16
+# define compare_extable	compare_extable_64
+# define do_func		do64
+# define Elf_Addr		Elf64_Addr
+# define Elf_Ehdr		Elf64_Ehdr
+# define Elf_Shdr		Elf64_Shdr
+# define Elf_Rel		Elf64_Rel
+# define Elf_Rela		Elf64_Rela
+# define Elf_Sym		Elf64_Sym
+# define ELF_R_SYM		ELF64_R_SYM
+# define Elf_r_sym		Elf64_r_sym
+# define ELF_R_INFO		ELF64_R_INFO
+# define Elf_r_info		Elf64_r_info
+# define ELF_ST_BIND		ELF64_ST_BIND
+# define ELF_ST_TYPE		ELF64_ST_TYPE
+# define fn_ELF_R_SYM		fn_ELF64_R_SYM
+# define fn_ELF_R_INFO		fn_ELF64_R_INFO
+# define uint_t			uint64_t
+# define _w			w8
+#else
+# define extable_ent_size	8
+# define compare_extable	compare_extable_32
+# define do_func		do32
+# define Elf_Addr		Elf32_Addr
+# define Elf_Ehdr		Elf32_Ehdr
+# define Elf_Shdr		Elf32_Shdr
+# define Elf_Rel		Elf32_Rel
+# define Elf_Rela		Elf32_Rela
+# define Elf_Sym		Elf32_Sym
+# define ELF_R_SYM		ELF32_R_SYM
+# define Elf_r_sym		Elf32_r_sym
+# define ELF_R_INFO		ELF32_R_INFO
+# define Elf_r_info		Elf32_r_info
+# define ELF_ST_BIND		ELF32_ST_BIND
+# define ELF_ST_TYPE		ELF32_ST_TYPE
+# define fn_ELF_R_SYM		fn_ELF32_R_SYM
+# define fn_ELF_R_INFO		fn_ELF32_R_INFO
+# define uint_t			uint32_t
+# define _w			w
+#endif
+
+static int compare_extable(const void *a, const void *b)
+{
+	const uint_t *aa = a;
+	const uint_t *bb = b;
+
+	if (_w(*aa) < _w(*bb))
+		return -1;
+	if (_w(*aa) > _w(*bb))
+		return 1;
+	return 0;
+}
+
+static void
+do_func(Elf_Ehdr *const ehdr, char const *const fname)
+{
+	Elf_Shdr *shdr;
+	Elf_Shdr *shstrtab_sec;
+	Elf_Shdr *strtab_sec = NULL;
+	Elf_Shdr *symtab_sec = NULL;
+	Elf_Shdr *extab_sec = NULL;
+	Elf_Sym *sym;
+	Elf_Sym *sort_needed_sym;
+	Elf_Shdr *sort_needed_sec;
+	uint32_t *sort_done_location;
+	const char *secstrtab;
+	const char *strtab;
+	int i;
+	int idx;
+
+	shdr = (Elf_Shdr *)((void *)ehdr + _w(ehdr->e_shoff));
+	shstrtab_sec = shdr + w2(ehdr->e_shstrndx);
+	secstrtab = (const char *)ehdr + _w(shstrtab_sec->sh_offset);
+	for (i = 0; i < w2(ehdr->e_shnum); i++) {
+		idx = w(shdr[i].sh_name);
+		if (strcmp(secstrtab + idx, "__ex_table") == 0)
+			extab_sec = shdr + i;
+		if (strcmp(secstrtab + idx, ".symtab") == 0)
+			symtab_sec = shdr + i;
+		if (strcmp(secstrtab + idx, ".strtab") == 0)
+			strtab_sec = shdr + i;
+	}
+	if (strtab_sec == NULL) {
+		fprintf(stderr,	"no .strtab in  file: %s\n", fname);
+		fail_file();
+	}
+	if (symtab_sec == NULL) {
+		fprintf(stderr,	"no .symtab in  file: %s\n", fname);
+		fail_file();
+	}
+	if (extab_sec == NULL) {
+		fprintf(stderr,	"no __ex_table in  file: %s\n", fname);
+		fail_file();
+	}
+	strtab = (const char *)ehdr + _w(strtab_sec->sh_offset);
+
+	/* Sort the table in place */
+	qsort((void *)ehdr + _w(extab_sec->sh_offset),
+	      (_w(extab_sec->sh_size) / extable_ent_size),
+	      extable_ent_size, compare_extable);
+
+	/* find main_extable_sort_needed */
+	sort_needed_sym = NULL;
+	for (i = 0; i < _w(symtab_sec->sh_size) / sizeof(Elf_Sym); i++) {
+		sym = (void *)ehdr + _w(symtab_sec->sh_offset);
+		sym += i;
+		if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
+			continue;
+		idx = w(sym->st_name);
+		if (strcmp(strtab + idx, "main_extable_sort_needed") == 0) {
+			sort_needed_sym = sym;
+			break;
+		}
+	}
+	if (sort_needed_sym == NULL) {
+		fprintf(stderr,
+			"no main_extable_sort_needed symbol in  file: %s\n",
+			fname);
+		fail_file();
+	}
+	sort_needed_sec = &shdr[w2(sort_needed_sym->st_shndx)];
+	sort_done_location = (void *)ehdr +
+		_w(sort_needed_sec->sh_offset) +
+		_w(sort_needed_sym->st_value) -
+		_w(sort_needed_sec->sh_addr);
+
+	printf("sort done marker at %lx\n",
+		(unsigned long) (_w(sort_needed_sec->sh_offset) +
+				 _w(sort_needed_sym->st_value) -
+				 _w(sort_needed_sec->sh_addr)));
+	/* We sorted it, clear the flag. */
+	*sort_done_location = 0;
+}
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 2/5] extable: Skip sorting if sorted at build time.
  2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
@ 2012-04-19 21:59 ` David Daney
  2012-04-20  0:21   ` [tip:x86/extable] " tip-bot for David Daney
  2012-04-19 21:59 ` [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system David Daney
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

If the build program sortextable has already sorted the exception
table, don't sort it again.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 kernel/extable.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index 5339705..fe35a63 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -35,10 +35,16 @@ DEFINE_MUTEX(text_mutex);
 extern struct exception_table_entry __start___ex_table[];
 extern struct exception_table_entry __stop___ex_table[];
 
+/* Cleared by build time tools if the table is already sorted. */
+u32 __initdata main_extable_sort_needed = 1;
+
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
 {
-	sort_extable(__start___ex_table, __stop___ex_table);
+	if (main_extable_sort_needed)
+		sort_extable(__start___ex_table, __stop___ex_table);
+	else
+		pr_notice("__ex_table already sorted, skipping sort\n");
 }
 
 /* Given an address, look for it in the exception tables. */
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system.
  2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
  2012-04-19 21:59 ` [PATCH v2 2/5] extable: Skip sorting if sorted at build time David Daney
@ 2012-04-19 21:59 ` David Daney
  2012-04-20  0:22   ` [tip:x86/extable] " tip-bot for David Daney
  2012-04-20 15:02   ` [PATCH v2 3/5] " Sam Ravnborg
  2012-04-19 21:59 ` [PATCH v2 4/5] MIPS: Select BUILDTIME_EXTABLE_SORT David Daney
  2012-04-19 21:59 ` [PATCH v2 5/5] x86: " David Daney
  4 siblings, 2 replies; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

Define a config variable BUILDTIME_EXTABLE_SORT to control build time
sorting of the kernel's exception table.

Patch Makefile to do the sorting when BUILDTIME_EXTABLE_SORT is
selected.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 Makefile     |   10 ++++++++++
 init/Kconfig |    3 +++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index ae947cc..e3bbca9 100644
--- a/Makefile
+++ b/Makefile
@@ -784,6 +784,10 @@ quiet_cmd_vmlinux_version = GEN     .version
 quiet_cmd_sysmap = SYSMAP
       cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
 
+# Sort exception table at build time
+quiet_cmd_sortextable = SORTEX
+      cmd_sortextable = $(objtree)/scripts/sortextable
+
 # Link of vmlinux
 # If CONFIG_KALLSYMS is set .version is already updated
 # Generate System.map and verify that the content is consistent
@@ -796,6 +800,12 @@ define rule_vmlinux__
 	$(call cmd,vmlinux__)
 	$(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
 
+	$(if $(CONFIG_BUILDTIME_EXTABLE_SORT),				\
+	  $(Q)$(if $($(quiet)cmd_sortextable),				\
+	    echo '  $($(quiet)cmd_sortextable)  vmlinux' &&)		\
+	  $(cmd_sortextable)  vmlinux)
+
+
 	$(Q)$(if $($(quiet)cmd_sysmap),                                      \
 	  echo '  $($(quiet)cmd_sysmap)  System.map' &&)                     \
 	$(cmd_sysmap) $@ System.map;                                         \
diff --git a/init/Kconfig b/init/Kconfig
index 6cfd71d..92a1296 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -27,6 +27,9 @@ config IRQ_WORK
 	bool
 	depends on HAVE_IRQ_WORK
 
+config BUILDTIME_EXTABLE_SORT
+	bool
+
 menu "General setup"
 
 config EXPERIMENTAL
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 4/5] MIPS: Select BUILDTIME_EXTABLE_SORT
  2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
                   ` (2 preceding siblings ...)
  2012-04-19 21:59 ` [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system David Daney
@ 2012-04-19 21:59 ` David Daney
  2012-04-20  0:23   ` [tip:x86/extable] " tip-bot for David Daney
  2012-04-19 21:59 ` [PATCH v2 5/5] x86: " David Daney
  4 siblings, 1 reply; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

We can sort the exeception table at build time for MIPS, so let's do
it.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 arch/mips/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3134457..0db1cde 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -29,6 +29,7 @@ config MIPS
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_DISCARD_MEMBLOCK
+	select BUILDTIME_EXTABLE_SORT
 
 menu "Machine selection"
 
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 5/5] x86: Select BUILDTIME_EXTABLE_SORT
  2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
                   ` (3 preceding siblings ...)
  2012-04-19 21:59 ` [PATCH v2 4/5] MIPS: Select BUILDTIME_EXTABLE_SORT David Daney
@ 2012-04-19 21:59 ` David Daney
  2012-04-20  0:23   ` [tip:x86/extable] " tip-bot for David Daney
  4 siblings, 1 reply; 41+ messages in thread
From: David Daney @ 2012-04-19 21:59 UTC (permalink / raw)
  To: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek
  Cc: linux-kernel, linux-mips, Andrew Morton, David Daney

From: David Daney <david.daney@cavium.com>

We can sort the exeception table at build time for x86, so let's do
it.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 arch/x86/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1d14cc6..2f925cc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -82,6 +82,7 @@ config X86
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
 	select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC
+	select BUILDTIME_EXTABLE_SORT
 
 config INSTRUCTION_DECODER
 	def_bool (KPROBES || PERF_EVENTS)
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] scripts: Add sortextable to sort the kernel' s exception table.
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
@ 2012-04-20  0:20   ` tip-bot for David Daney
  2012-04-20  1:44   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's " H. Peter Anvin
  2012-04-20 14:59   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table Sam Ravnborg
  2 siblings, 0 replies; 41+ messages in thread
From: tip-bot for David Daney @ 2012-04-20  0:20 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx, hpa

Commit-ID:  a79f248b9b309ebb5f34ca6a8fd1eb9e18db5720
Gitweb:     http://git.kernel.org/tip/a79f248b9b309ebb5f34ca6a8fd1eb9e18db5720
Author:     David Daney <david.daney@cavium.com>
AuthorDate: Thu, 19 Apr 2012 14:59:55 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Apr 2012 15:06:55 -0700

scripts: Add sortextable to sort the kernel's exception table.

Using this build-time sort saves time booting as we don't have to burn
cycles sorting the exception table.

Signed-off-by: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/1334872799-14589-2-git-send-email-ddaney.cavm@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 scripts/.gitignore    |    1 +
 scripts/Makefile      |    1 +
 scripts/sortextable.c |  271 +++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/sortextable.h |  168 ++++++++++++++++++++++++++++++
 4 files changed, 441 insertions(+), 0 deletions(-)

diff --git a/scripts/.gitignore b/scripts/.gitignore
index 105b21f..65f362d 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -9,3 +9,4 @@ unifdef
 ihex2fw
 recordmcount
 docproc
+sortextable
diff --git a/scripts/Makefile b/scripts/Makefile
index df7678f..43e19b9 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -13,6 +13,7 @@ hostprogs-$(CONFIG_LOGO)         += pnmtologo
 hostprogs-$(CONFIG_VT)           += conmakehash
 hostprogs-$(CONFIG_IKCONFIG)     += bin2c
 hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
+hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable
 
 always		:= $(hostprogs-y) $(hostprogs-m)
 
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
new file mode 100644
index 0000000..f51f1d4
--- /dev/null
+++ b/scripts/sortextable.c
@@ -0,0 +1,271 @@
+/*
+ * sortextable.c: Sort the kernel's exception table
+ *
+ * Copyright 2011 Cavium, Inc.
+ *
+ * Based on code taken from recortmcount.c which is:
+ *
+ * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.
+ * Licensed under the GNU General Public License, version 2 (GPLv2).
+ *
+ * Restructured to fit Linux format, as well as other updates:
+ *  Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
+ */
+
+/*
+ * Strategy: alter the vmlinux file in-place.
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <getopt.h>
+#include <elf.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static int fd_map;	/* File descriptor for file being modified. */
+static int mmap_failed; /* Boolean flag. */
+static void *ehdr_curr; /* current ElfXX_Ehdr *  for resource cleanup */
+static struct stat sb;	/* Remember .st_size, etc. */
+static jmp_buf jmpenv;	/* setjmp/longjmp per-file error escape */
+
+/* setjmp() return values */
+enum {
+	SJ_SETJMP = 0,  /* hardwired first return */
+	SJ_FAIL,
+	SJ_SUCCEED
+};
+
+/* Per-file resource cleanup when multiple files. */
+static void
+cleanup(void)
+{
+	if (!mmap_failed)
+		munmap(ehdr_curr, sb.st_size);
+	close(fd_map);
+}
+
+static void __attribute__((noreturn))
+fail_file(void)
+{
+	cleanup();
+	longjmp(jmpenv, SJ_FAIL);
+}
+
+static void __attribute__((noreturn))
+succeed_file(void)
+{
+	cleanup();
+	longjmp(jmpenv, SJ_SUCCEED);
+}
+
+
+/*
+ * Get the whole file as a programming convenience in order to avoid
+ * malloc+lseek+read+free of many pieces.  If successful, then mmap
+ * avoids copying unused pieces; else just read the whole file.
+ * Open for both read and write.
+ */
+static void *mmap_file(char const *fname)
+{
+	void *addr;
+
+	fd_map = open(fname, O_RDWR);
+	if (fd_map < 0 || fstat(fd_map, &sb) < 0) {
+		perror(fname);
+		fail_file();
+	}
+	if (!S_ISREG(sb.st_mode)) {
+		fprintf(stderr, "not a regular file: %s\n", fname);
+		fail_file();
+	}
+	addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
+		    fd_map, 0);
+	if (addr == MAP_FAILED) {
+		mmap_failed = 1;
+		fprintf(stderr, "Could not mmap file: %s\n", fname);
+		fail_file();
+	}
+	return addr;
+}
+
+/* w8rev, w8nat, ...: Handle endianness. */
+
+static uint64_t w8rev(uint64_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (7 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (6 * 8))
+	       | ((0xff & (x >> (2 * 8))) << (5 * 8))
+	       | ((0xff & (x >> (3 * 8))) << (4 * 8))
+	       | ((0xff & (x >> (4 * 8))) << (3 * 8))
+	       | ((0xff & (x >> (5 * 8))) << (2 * 8))
+	       | ((0xff & (x >> (6 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (7 * 8))) << (0 * 8));
+}
+
+static uint32_t w4rev(uint32_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (3 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (2 * 8))
+	       | ((0xff & (x >> (2 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (3 * 8))) << (0 * 8));
+}
+
+static uint32_t w2rev(uint16_t const x)
+{
+	return   ((0xff & (x >> (0 * 8))) << (1 * 8))
+	       | ((0xff & (x >> (1 * 8))) << (0 * 8));
+}
+
+static uint64_t w8nat(uint64_t const x)
+{
+	return x;
+}
+
+static uint32_t w4nat(uint32_t const x)
+{
+	return x;
+}
+
+static uint32_t w2nat(uint16_t const x)
+{
+	return x;
+}
+
+static uint64_t (*w8)(uint64_t);
+static uint32_t (*w)(uint32_t);
+static uint32_t (*w2)(uint16_t);
+
+
+/* 32 bit and 64 bit are very similar */
+#include "sortextable.h"
+#define SORTEXTABLE_64
+#include "sortextable.h"
+
+
+static void
+do_file(char const *const fname)
+{
+	Elf32_Ehdr *const ehdr = mmap_file(fname);
+
+	ehdr_curr = ehdr;
+	w = w4nat;
+	w2 = w2nat;
+	w8 = w8nat;
+	switch (ehdr->e_ident[EI_DATA]) {
+		static unsigned int const endian = 1;
+	default:
+		fprintf(stderr, "unrecognized ELF data encoding %d: %s\n",
+			ehdr->e_ident[EI_DATA], fname);
+		fail_file();
+		break;
+	case ELFDATA2LSB:
+		if (*(unsigned char const *)&endian != 1) {
+			/* main() is big endian, file.o is little endian. */
+			w = w4rev;
+			w2 = w2rev;
+			w8 = w8rev;
+		}
+		break;
+	case ELFDATA2MSB:
+		if (*(unsigned char const *)&endian != 0) {
+			/* main() is little endian, file.o is big endian. */
+			w = w4rev;
+			w2 = w2rev;
+			w8 = w8rev;
+		}
+		break;
+	}  /* end switch */
+	if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
+	||  w2(ehdr->e_type) != ET_EXEC
+	||  ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
+		fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname);
+		fail_file();
+	}
+
+	switch (w2(ehdr->e_machine)) {
+	default:
+		fprintf(stderr, "unrecognized e_machine %d %s\n",
+			w2(ehdr->e_machine), fname);
+		fail_file();
+		break;
+	case EM_386:
+	case EM_MIPS:
+	case EM_X86_64:
+		break;
+	}  /* end switch */
+
+	switch (ehdr->e_ident[EI_CLASS]) {
+	default:
+		fprintf(stderr, "unrecognized ELF class %d %s\n",
+			ehdr->e_ident[EI_CLASS], fname);
+		fail_file();
+		break;
+	case ELFCLASS32:
+		if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
+		||  w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
+			fprintf(stderr,
+				"unrecognized ET_EXEC file: %s\n", fname);
+			fail_file();
+		}
+		do32(ehdr, fname);
+		break;
+	case ELFCLASS64: {
+		Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr;
+		if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
+		||  w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
+			fprintf(stderr,
+				"unrecognized ET_EXEC file: %s\n", fname);
+			fail_file();
+		}
+		do64(ghdr, fname);
+		break;
+	}
+	}  /* end switch */
+
+	cleanup();
+}
+
+int
+main(int argc, char *argv[])
+{
+	int n_error = 0;  /* gcc-4.3.0 false positive complaint */
+	int i;
+
+	if (argc < 2) {
+		fprintf(stderr, "usage: sortextable vmlinux...\n");
+		return 0;
+	}
+
+	/* Process each file in turn, allowing deep failure. */
+	for (i = 1; i < argc; i++) {
+		char *file = argv[i];
+		int const sjval = setjmp(jmpenv);
+
+		switch (sjval) {
+		default:
+			fprintf(stderr, "internal error: %s\n", file);
+			exit(1);
+			break;
+		case SJ_SETJMP:    /* normal sequence */
+			/* Avoid problems if early cleanup() */
+			fd_map = -1;
+			ehdr_curr = NULL;
+			mmap_failed = 1;
+			do_file(file);
+			break;
+		case SJ_FAIL:    /* error in do_file or below */
+			++n_error;
+			break;
+		case SJ_SUCCEED:    /* premature success */
+			/* do nothing */
+			break;
+		}  /* end switch */
+	}
+	return !!n_error;
+}
diff --git a/scripts/sortextable.h b/scripts/sortextable.h
new file mode 100644
index 0000000..bb6aaf1
--- /dev/null
+++ b/scripts/sortextable.h
@@ -0,0 +1,168 @@
+/*
+ * sortextable.h
+ *
+ * Copyright 2011 Cavium, Inc.
+ *
+ * Some of this code was taken out of recordmcount.h written by:
+ *
+ * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>.  All rights reserved.
+ * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
+ *
+ *
+ * Licensed under the GNU General Public License, version 2 (GPLv2).
+ */
+
+#undef extable_ent_size
+#undef compare_extable
+#undef do_func
+#undef Elf_Addr
+#undef Elf_Ehdr
+#undef Elf_Shdr
+#undef Elf_Rel
+#undef Elf_Rela
+#undef Elf_Sym
+#undef ELF_R_SYM
+#undef Elf_r_sym
+#undef ELF_R_INFO
+#undef Elf_r_info
+#undef ELF_ST_BIND
+#undef ELF_ST_TYPE
+#undef fn_ELF_R_SYM
+#undef fn_ELF_R_INFO
+#undef uint_t
+#undef _w
+
+#ifdef SORTEXTABLE_64
+# define extable_ent_size	16
+# define compare_extable	compare_extable_64
+# define do_func		do64
+# define Elf_Addr		Elf64_Addr
+# define Elf_Ehdr		Elf64_Ehdr
+# define Elf_Shdr		Elf64_Shdr
+# define Elf_Rel		Elf64_Rel
+# define Elf_Rela		Elf64_Rela
+# define Elf_Sym		Elf64_Sym
+# define ELF_R_SYM		ELF64_R_SYM
+# define Elf_r_sym		Elf64_r_sym
+# define ELF_R_INFO		ELF64_R_INFO
+# define Elf_r_info		Elf64_r_info
+# define ELF_ST_BIND		ELF64_ST_BIND
+# define ELF_ST_TYPE		ELF64_ST_TYPE
+# define fn_ELF_R_SYM		fn_ELF64_R_SYM
+# define fn_ELF_R_INFO		fn_ELF64_R_INFO
+# define uint_t			uint64_t
+# define _w			w8
+#else
+# define extable_ent_size	8
+# define compare_extable	compare_extable_32
+# define do_func		do32
+# define Elf_Addr		Elf32_Addr
+# define Elf_Ehdr		Elf32_Ehdr
+# define Elf_Shdr		Elf32_Shdr
+# define Elf_Rel		Elf32_Rel
+# define Elf_Rela		Elf32_Rela
+# define Elf_Sym		Elf32_Sym
+# define ELF_R_SYM		ELF32_R_SYM
+# define Elf_r_sym		Elf32_r_sym
+# define ELF_R_INFO		ELF32_R_INFO
+# define Elf_r_info		Elf32_r_info
+# define ELF_ST_BIND		ELF32_ST_BIND
+# define ELF_ST_TYPE		ELF32_ST_TYPE
+# define fn_ELF_R_SYM		fn_ELF32_R_SYM
+# define fn_ELF_R_INFO		fn_ELF32_R_INFO
+# define uint_t			uint32_t
+# define _w			w
+#endif
+
+static int compare_extable(const void *a, const void *b)
+{
+	const uint_t *aa = a;
+	const uint_t *bb = b;
+
+	if (_w(*aa) < _w(*bb))
+		return -1;
+	if (_w(*aa) > _w(*bb))
+		return 1;
+	return 0;
+}
+
+static void
+do_func(Elf_Ehdr *const ehdr, char const *const fname)
+{
+	Elf_Shdr *shdr;
+	Elf_Shdr *shstrtab_sec;
+	Elf_Shdr *strtab_sec = NULL;
+	Elf_Shdr *symtab_sec = NULL;
+	Elf_Shdr *extab_sec = NULL;
+	Elf_Sym *sym;
+	Elf_Sym *sort_needed_sym;
+	Elf_Shdr *sort_needed_sec;
+	uint32_t *sort_done_location;
+	const char *secstrtab;
+	const char *strtab;
+	int i;
+	int idx;
+
+	shdr = (Elf_Shdr *)((void *)ehdr + _w(ehdr->e_shoff));
+	shstrtab_sec = shdr + w2(ehdr->e_shstrndx);
+	secstrtab = (const char *)ehdr + _w(shstrtab_sec->sh_offset);
+	for (i = 0; i < w2(ehdr->e_shnum); i++) {
+		idx = w(shdr[i].sh_name);
+		if (strcmp(secstrtab + idx, "__ex_table") == 0)
+			extab_sec = shdr + i;
+		if (strcmp(secstrtab + idx, ".symtab") == 0)
+			symtab_sec = shdr + i;
+		if (strcmp(secstrtab + idx, ".strtab") == 0)
+			strtab_sec = shdr + i;
+	}
+	if (strtab_sec == NULL) {
+		fprintf(stderr,	"no .strtab in  file: %s\n", fname);
+		fail_file();
+	}
+	if (symtab_sec == NULL) {
+		fprintf(stderr,	"no .symtab in  file: %s\n", fname);
+		fail_file();
+	}
+	if (extab_sec == NULL) {
+		fprintf(stderr,	"no __ex_table in  file: %s\n", fname);
+		fail_file();
+	}
+	strtab = (const char *)ehdr + _w(strtab_sec->sh_offset);
+
+	/* Sort the table in place */
+	qsort((void *)ehdr + _w(extab_sec->sh_offset),
+	      (_w(extab_sec->sh_size) / extable_ent_size),
+	      extable_ent_size, compare_extable);
+
+	/* find main_extable_sort_needed */
+	sort_needed_sym = NULL;
+	for (i = 0; i < _w(symtab_sec->sh_size) / sizeof(Elf_Sym); i++) {
+		sym = (void *)ehdr + _w(symtab_sec->sh_offset);
+		sym += i;
+		if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
+			continue;
+		idx = w(sym->st_name);
+		if (strcmp(strtab + idx, "main_extable_sort_needed") == 0) {
+			sort_needed_sym = sym;
+			break;
+		}
+	}
+	if (sort_needed_sym == NULL) {
+		fprintf(stderr,
+			"no main_extable_sort_needed symbol in  file: %s\n",
+			fname);
+		fail_file();
+	}
+	sort_needed_sec = &shdr[w2(sort_needed_sym->st_shndx)];
+	sort_done_location = (void *)ehdr +
+		_w(sort_needed_sec->sh_offset) +
+		_w(sort_needed_sym->st_value) -
+		_w(sort_needed_sec->sh_addr);
+
+	printf("sort done marker at %lx\n",
+		(unsigned long) (_w(sort_needed_sec->sh_offset) +
+				 _w(sort_needed_sym->st_value) -
+				 _w(sort_needed_sec->sh_addr)));
+	/* We sorted it, clear the flag. */
+	*sort_done_location = 0;
+}

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] extable: Skip sorting if sorted at build time.
  2012-04-19 21:59 ` [PATCH v2 2/5] extable: Skip sorting if sorted at build time David Daney
@ 2012-04-20  0:21   ` tip-bot for David Daney
  0 siblings, 0 replies; 41+ messages in thread
From: tip-bot for David Daney @ 2012-04-20  0:21 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx, hpa

Commit-ID:  d219e2e86a407035303b987e4184ca0b1de53257
Gitweb:     http://git.kernel.org/tip/d219e2e86a407035303b987e4184ca0b1de53257
Author:     David Daney <david.daney@cavium.com>
AuthorDate: Thu, 19 Apr 2012 14:59:56 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Apr 2012 15:06:55 -0700

extable: Skip sorting if sorted at build time.

If the build program sortextable has already sorted the exception
table, don't sort it again.

Signed-off-by: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/1334872799-14589-3-git-send-email-ddaney.cavm@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 kernel/extable.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index 5339705..fe35a63 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -35,10 +35,16 @@ DEFINE_MUTEX(text_mutex);
 extern struct exception_table_entry __start___ex_table[];
 extern struct exception_table_entry __stop___ex_table[];
 
+/* Cleared by build time tools if the table is already sorted. */
+u32 __initdata main_extable_sort_needed = 1;
+
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
 {
-	sort_extable(__start___ex_table, __stop___ex_table);
+	if (main_extable_sort_needed)
+		sort_extable(__start___ex_table, __stop___ex_table);
+	else
+		pr_notice("__ex_table already sorted, skipping sort\n");
 }
 
 /* Given an address, look for it in the exception tables. */

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] kbuild/extable: Hook up sortextable into the build system.
  2012-04-19 21:59 ` [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system David Daney
@ 2012-04-20  0:22   ` tip-bot for David Daney
  2012-04-20 15:02   ` [PATCH v2 3/5] " Sam Ravnborg
  1 sibling, 0 replies; 41+ messages in thread
From: tip-bot for David Daney @ 2012-04-20  0:22 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx, hpa

Commit-ID:  1dbdc6f177c627ae462752c80a5c7f3b06a7f92a
Gitweb:     http://git.kernel.org/tip/1dbdc6f177c627ae462752c80a5c7f3b06a7f92a
Author:     David Daney <david.daney@cavium.com>
AuthorDate: Thu, 19 Apr 2012 14:59:57 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Apr 2012 15:06:56 -0700

kbuild/extable: Hook up sortextable into the build system.

Define a config variable BUILDTIME_EXTABLE_SORT to control build time
sorting of the kernel's exception table.

Patch Makefile to do the sorting when BUILDTIME_EXTABLE_SORT is
selected.

Signed-off-by: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/1334872799-14589-4-git-send-email-ddaney.cavm@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 Makefile     |   10 ++++++++++
 init/Kconfig |    3 +++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index f6578f4..622c918 100644
--- a/Makefile
+++ b/Makefile
@@ -784,6 +784,10 @@ quiet_cmd_vmlinux_version = GEN     .version
 quiet_cmd_sysmap = SYSMAP
       cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
 
+# Sort exception table at build time
+quiet_cmd_sortextable = SORTEX
+      cmd_sortextable = $(objtree)/scripts/sortextable
+
 # Link of vmlinux
 # If CONFIG_KALLSYMS is set .version is already updated
 # Generate System.map and verify that the content is consistent
@@ -796,6 +800,12 @@ define rule_vmlinux__
 	$(call cmd,vmlinux__)
 	$(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
 
+	$(if $(CONFIG_BUILDTIME_EXTABLE_SORT),				\
+	  $(Q)$(if $($(quiet)cmd_sortextable),				\
+	    echo '  $($(quiet)cmd_sortextable)  vmlinux' &&)		\
+	  $(cmd_sortextable)  vmlinux)
+
+
 	$(Q)$(if $($(quiet)cmd_sysmap),                                      \
 	  echo '  $($(quiet)cmd_sysmap)  System.map' &&)                     \
 	$(cmd_sysmap) $@ System.map;                                         \
diff --git a/init/Kconfig b/init/Kconfig
index 6cfd71d..92a1296 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -27,6 +27,9 @@ config IRQ_WORK
 	bool
 	depends on HAVE_IRQ_WORK
 
+config BUILDTIME_EXTABLE_SORT
+	bool
+
 menu "General setup"
 
 config EXPERIMENTAL

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] MIPS: Select BUILDTIME_EXTABLE_SORT
  2012-04-19 21:59 ` [PATCH v2 4/5] MIPS: Select BUILDTIME_EXTABLE_SORT David Daney
@ 2012-04-20  0:23   ` tip-bot for David Daney
  0 siblings, 0 replies; 41+ messages in thread
From: tip-bot for David Daney @ 2012-04-20  0:23 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, ralf, david.daney, tglx, hpa

Commit-ID:  4b0544955a7b7fd363ac8fa709b70c8e7c3cfbea
Gitweb:     http://git.kernel.org/tip/4b0544955a7b7fd363ac8fa709b70c8e7c3cfbea
Author:     David Daney <david.daney@cavium.com>
AuthorDate: Thu, 19 Apr 2012 14:59:58 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Apr 2012 15:06:56 -0700

MIPS: Select BUILDTIME_EXTABLE_SORT

We can sort the exeception table at build time for MIPS, so let's do
it.

Signed-off-by: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/1334872799-14589-5-git-send-email-ddaney.cavm@gmail.com
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/mips/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ce30e2f..780a769 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -29,6 +29,7 @@ config MIPS
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_DISCARD_MEMBLOCK
+	select BUILDTIME_EXTABLE_SORT
 
 menu "Machine selection"
 

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86: Select BUILDTIME_EXTABLE_SORT
  2012-04-19 21:59 ` [PATCH v2 5/5] x86: " David Daney
@ 2012-04-20  0:23   ` tip-bot for David Daney
  0 siblings, 0 replies; 41+ messages in thread
From: tip-bot for David Daney @ 2012-04-20  0:23 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx, hpa

Commit-ID:  d405c60128a1973648058fa950a8960ec1f27e38
Gitweb:     http://git.kernel.org/tip/d405c60128a1973648058fa950a8960ec1f27e38
Author:     David Daney <david.daney@cavium.com>
AuthorDate: Thu, 19 Apr 2012 14:59:59 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Apr 2012 15:07:10 -0700

x86: Select BUILDTIME_EXTABLE_SORT

We can sort the exeception table at build time for x86, so let's do
it.

Signed-off-by: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/1334872799-14589-6-git-send-email-ddaney.cavm@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1d14cc6..2f925cc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -82,6 +82,7 @@ config X86
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
 	select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC
+	select BUILDTIME_EXTABLE_SORT
 
 config INSTRUCTION_DECODER
 	def_bool (KPROBES || PERF_EVENTS)

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
  2012-04-20  0:20   ` [tip:x86/extable] scripts: Add sortextable to sort the kernel' s " tip-bot for David Daney
@ 2012-04-20  1:44   ` H. Peter Anvin
  2012-04-20  3:17     ` David Daney
  2012-04-20 14:59   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table Sam Ravnborg
  2 siblings, 1 reply; 41+ messages in thread
From: H. Peter Anvin @ 2012-04-20  1:44 UTC (permalink / raw)
  To: David Daney
  Cc: Ralf Baechle, Thomas Gleixner, Ingo Molnar, x86, Linus Torvalds,
	Michal Marek, linux-kernel, linux-mips, Andrew Morton,
	David Daney

I committed this into the tip tree, but I realized something scary on
the way home... this program is broken: it doesn't handle the
relocations that go with the entries.  Specifically, it needs to not
just handle __ex_table, it also needs to handle the corresponding
entries in .rel__ex_table.

On x86-32, in particular, *most*, but not *all*, extable relocations
will have an R_386_32 relocation on it, so the resulting binary will
"mostly work"... but the ELF metadata will be wrong, and pretty much any
user of the try/catch mechanism will be broken, unless your kernel
happens to be located at its preferred address.

This needs to be addressed, either by adjusting the exception table to
be relative (which would be good for code size on 64-bit platforms)
*and* zero out the .rel__ex_table section or by making the program
actually sort the relocations correctly.

	-hpa

On 04/19/2012 02:59 PM, David Daney wrote:
> +
> +/* w8rev, w8nat, ...: Handle endianness. */
> +
> +static uint64_t w8rev(uint64_t const x)
> +{
> +	return   ((0xff & (x >> (0 * 8))) << (7 * 8))
> +	       | ((0xff & (x >> (1 * 8))) << (6 * 8))
> +	       | ((0xff & (x >> (2 * 8))) << (5 * 8))
> +	       | ((0xff & (x >> (3 * 8))) << (4 * 8))
> +	       | ((0xff & (x >> (4 * 8))) << (3 * 8))
> +	       | ((0xff & (x >> (5 * 8))) << (2 * 8))
> +	       | ((0xff & (x >> (6 * 8))) << (1 * 8))
> +	       | ((0xff & (x >> (7 * 8))) << (0 * 8));
> +}
> +
> +static uint32_t w4rev(uint32_t const x)
> +{
> +	return   ((0xff & (x >> (0 * 8))) << (3 * 8))
> +	       | ((0xff & (x >> (1 * 8))) << (2 * 8))
> +	       | ((0xff & (x >> (2 * 8))) << (1 * 8))
> +	       | ((0xff & (x >> (3 * 8))) << (0 * 8));
> +}
> +
> +static uint32_t w2rev(uint16_t const x)
> +{
> +	return   ((0xff & (x >> (0 * 8))) << (1 * 8))
> +	       | ((0xff & (x >> (1 * 8))) << (0 * 8));
> +}
> +
> +static uint64_t w8nat(uint64_t const x)
> +{
> +	return x;
> +}
> +
> +static uint32_t w4nat(uint32_t const x)
> +{
> +	return x;
> +}
> +
> +static uint32_t w2nat(uint16_t const x)
> +{
> +	return x;
> +}
> +
> +static uint64_t (*w8)(uint64_t);
> +static uint32_t (*w)(uint32_t);
> +static uint32_t (*w2)(uint16_t);

Stylistic note: these should use the <tools/*_byteshift.h> headers now.

	-hpa


-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20  1:44   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's " H. Peter Anvin
@ 2012-04-20  3:17     ` David Daney
  2012-04-20  3:31       ` Linus Torvalds
  0 siblings, 1 reply; 41+ messages in thread
From: David Daney @ 2012-04-20  3:17 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: David Daney, Ralf Baechle, Thomas Gleixner, Ingo Molnar, x86,
	Linus Torvalds, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On 04/19/2012 06:44 PM, H. Peter Anvin wrote:
> I committed this into the tip tree, but I realized something scary on
> the way home... this program is broken: it doesn't handle the
> relocations that go with the entries.  Specifically, it needs to not
> just handle __ex_table, it also needs to handle the corresponding
> entries in .rel__ex_table.
>
> On x86-32, in particular, *most*, but not *all*, extable relocations
> will have an R_386_32 relocation on it, so the resulting binary will
> "mostly work"... but the ELF metadata will be wrong, and pretty much any
> user of the try/catch mechanism will be broken, unless your kernel
> happens to be located at its preferred address.
>
> This needs to be addressed, either by adjusting the exception table to
> be relative (which would be good for code size on 64-bit platforms)
> *and* zero out the .rel__ex_table section or by making the program
> actually sort the relocations correctly.

Crap.

I hadn't considered that the image was relocatable.  Our MIPS kernels 
never have relocations.

I am working on a version of this that handles the relocations.  It 
shouldn't be too difficult.


> 	-hpa
>
> On 04/19/2012 02:59 PM, David Daney wrote:
>> +
>> +/* w8rev, w8nat, ...: Handle endianness. */
>> +
>> +static uint64_t w8rev(uint64_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (7 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (6 * 8))
>> +	       | ((0xff&  (x>>  (2 * 8)))<<  (5 * 8))
>> +	       | ((0xff&  (x>>  (3 * 8)))<<  (4 * 8))
>> +	       | ((0xff&  (x>>  (4 * 8)))<<  (3 * 8))
>> +	       | ((0xff&  (x>>  (5 * 8)))<<  (2 * 8))
>> +	       | ((0xff&  (x>>  (6 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (7 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint32_t w4rev(uint32_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (3 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (2 * 8))
>> +	       | ((0xff&  (x>>  (2 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (3 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint32_t w2rev(uint16_t const x)
>> +{
>> +	return   ((0xff&  (x>>  (0 * 8)))<<  (1 * 8))
>> +	       | ((0xff&  (x>>  (1 * 8)))<<  (0 * 8));
>> +}
>> +
>> +static uint64_t w8nat(uint64_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint32_t w4nat(uint32_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint32_t w2nat(uint16_t const x)
>> +{
>> +	return x;
>> +}
>> +
>> +static uint64_t (*w8)(uint64_t);
>> +static uint32_t (*w)(uint32_t);
>> +static uint32_t (*w2)(uint16_t);
> Stylistic note: these should use the<tools/*_byteshift.h>  headers now.

I will try to use those.

Thanks,
David Daney


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20  3:17     ` David Daney
@ 2012-04-20  3:31       ` Linus Torvalds
  2012-04-20  3:42         ` H. Peter Anvin
                           ` (21 more replies)
  0 siblings, 22 replies; 41+ messages in thread
From: Linus Torvalds @ 2012-04-20  3:31 UTC (permalink / raw)
  To: David Daney
  Cc: H. Peter Anvin, David Daney, Ralf Baechle, Thomas Gleixner,
	Ingo Molnar, x86, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On Thu, Apr 19, 2012 at 8:17 PM, David Daney <david.s.daney@gmail.com> wrote:
>
> I hadn't considered that the image was relocatable.  Our MIPS kernels never
> have relocations.
>
> I am working on a version of this that handles the relocations.  It
> shouldn't be too difficult.

It might be better to just make the rule be that we don't have
relocations there - make everything relative to the start of the code
segment or something.

On x86, we already use that _ASM_EXTABLE() macro to hide the
differences between x86-64 and x86-32. So it should be be somewhat
easy to make that same macro make it relative to the code start, and
at the same time also make the exception table perhaps be two 32-bit
words rather than two pointers.

So it would shrink the exception table and avoid relocations at the
same time. Win-win. No?

                      Linus

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20  3:31       ` Linus Torvalds
@ 2012-04-20  3:42         ` H. Peter Anvin
  2012-04-20  4:49           ` H. Peter Anvin
  2012-04-20 21:55         ` [tip:x86/extable] x86, extable: Use .pushsection ... . popsection for _ASM_EXTABLE() tip-bot for H. Peter Anvin
                           ` (20 subsequent siblings)
  21 siblings, 1 reply; 41+ messages in thread
From: H. Peter Anvin @ 2012-04-20  3:42 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Daney, David Daney, Ralf Baechle, Thomas Gleixner,
	Ingo Molnar, x86, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On 04/19/2012 08:31 PM, Linus Torvalds wrote:
> On Thu, Apr 19, 2012 at 8:17 PM, David Daney <david.s.daney@gmail.com> wrote:
>>
>> I hadn't considered that the image was relocatable.  Our MIPS kernels never
>> have relocations.
>>
>> I am working on a version of this that handles the relocations.  It
>> shouldn't be too difficult.
> 
> It might be better to just make the rule be that we don't have
> relocations there - make everything relative to the start of the code
> segment or something.
> 
> On x86, we already use that _ASM_EXTABLE() macro to hide the
> differences between x86-64 and x86-32. So it should be be somewhat
> easy to make that same macro make it relative to the code start, and
> at the same time also make the exception table perhaps be two 32-bit
> words rather than two pointers.
> 
> So it would shrink the exception table and avoid relocations at the
> same time. Win-win. No?
> 

I don't think we can get _ASM_EXTABLE() to do that work for us, because
we'd need to subtract symbols from two different sections.  We would
need the postprocessing tool to take care this, but guess what, we can
do exactly that (and then, as I mentioned, just zero out the relocation
section.)

	-hpa





^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20  3:42         ` H. Peter Anvin
@ 2012-04-20  4:49           ` H. Peter Anvin
  2012-04-20  4:54             ` H. Peter Anvin
  0 siblings, 1 reply; 41+ messages in thread
From: H. Peter Anvin @ 2012-04-20  4:49 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Daney, David Daney, Ralf Baechle, Thomas Gleixner,
	Ingo Molnar, x86, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On 04/19/2012 08:42 PM, H. Peter Anvin wrote:
> 
> I don't think we can get _ASM_EXTABLE() to do that work for us, because
> we'd need to subtract symbols from two different sections.  We would
> need the postprocessing tool to take care this, but guess what, we can
> do exactly that (and then, as I mentioned, just zero out the relocation
> section.)
> 

Ah, apparently it is possible to generate relocations relative to the
start of the current section:

# define _ASM_EXTABLE(from,to)      			\
        __ASM_EX_SEC ;              			\
        _ASM_ALIGN ;                			\
        .long (from)-__ex_table,(to)-__ex_table ;       \
        .previous

Then all the postprocessor would have to do is to zero out the
relocation section, and we would always just add the base of the
particular __ex_table section.

We need to make sure the module loader works, too, and not to break the
__{get,put}_user_ex macros (which would need to use a new variant of
_ASM_EXTABLE()).

There is still a disturbing number of open-coded __ex_table instances
too; those all need to be converted.

Looks like a worthwhile project but not for tonight.

All of this is for x86... other architectures would need to be converted
in whatever way is appropriate.

	-hpa

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20  4:49           ` H. Peter Anvin
@ 2012-04-20  4:54             ` H. Peter Anvin
  0 siblings, 0 replies; 41+ messages in thread
From: H. Peter Anvin @ 2012-04-20  4:54 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Daney, David Daney, Ralf Baechle, Thomas Gleixner,
	Ingo Molnar, x86, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On 04/19/2012 09:49 PM, H. Peter Anvin wrote:
> 
> Ah, apparently it is possible to generate relocations relative to the
> start of the current section.
> 

Nevermind... I'm wrong.  The assembler will generate them but the linker
will produce garbage.

So I think using PC-relative relocations and have the postprocessor (or
the sort in the module loader) convert them to section-relative makes
sense...

	-hpa

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
  2012-04-20  0:20   ` [tip:x86/extable] scripts: Add sortextable to sort the kernel' s " tip-bot for David Daney
  2012-04-20  1:44   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's " H. Peter Anvin
@ 2012-04-20 14:59   ` Sam Ravnborg
  2012-04-20 16:49     ` David Daney
  2 siblings, 1 reply; 41+ messages in thread
From: Sam Ravnborg @ 2012-04-20 14:59 UTC (permalink / raw)
  To: David Daney
  Cc: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On Thu, Apr 19, 2012 at 02:59:55PM -0700, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
> 
> Using this build-time sort saves time booting as we don't have to burn
> cycles sorting the exception table.
> 
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
>  scripts/.gitignore    |    1 +
>  scripts/Makefile      |    1 +
>  scripts/sortextable.c |  273 +++++++++++++++++++++++++++++++++++++++++++++++++
>  scripts/sortextable.h |  168 ++++++++++++++++++++++++++++++

If there is only a single file including the .h file - then there is no gain.
Just fold it into the .c file.


	Sam

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system.
  2012-04-19 21:59 ` [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system David Daney
  2012-04-20  0:22   ` [tip:x86/extable] " tip-bot for David Daney
@ 2012-04-20 15:02   ` Sam Ravnborg
  1 sibling, 0 replies; 41+ messages in thread
From: Sam Ravnborg @ 2012-04-20 15:02 UTC (permalink / raw)
  To: David Daney
  Cc: Ralf Baechle, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Linus Torvalds, Michal Marek, linux-kernel, linux-mips,
	Andrew Morton, David Daney

On Thu, Apr 19, 2012 at 02:59:57PM -0700, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
> 
> Define a config variable BUILDTIME_EXTABLE_SORT to control build time
> sorting of the kernel's exception table.
> 
> Patch Makefile to do the sorting when BUILDTIME_EXTABLE_SORT is
> selected.
> 
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
>  Makefile     |   10 ++++++++++
>  init/Kconfig |    3 +++
>  2 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index ae947cc..e3bbca9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -784,6 +784,10 @@ quiet_cmd_vmlinux_version = GEN     .version
>  quiet_cmd_sysmap = SYSMAP
>        cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
>  
> +# Sort exception table at build time
> +quiet_cmd_sortextable = SORTEX
> +      cmd_sortextable = $(objtree)/scripts/sortextable
> +
>  # Link of vmlinux
>  # If CONFIG_KALLSYMS is set .version is already updated
>  # Generate System.map and verify that the content is consistent
> @@ -796,6 +800,12 @@ define rule_vmlinux__
>  	$(call cmd,vmlinux__)
>  	$(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
>  
> +	$(if $(CONFIG_BUILDTIME_EXTABLE_SORT),				\
> +	  $(Q)$(if $($(quiet)cmd_sortextable),				\
> +	    echo '  $($(quiet)cmd_sortextable)  vmlinux' &&)		\
> +	  $(cmd_sortextable)  vmlinux)
> +
> +

Anything that add complexity to the top-level Makefile is bad :-(
I once looked at moving all the final link stuff to a script.
Maybe it is time to open that again...


> +config BUILDTIME_EXTABLE_SORT
> +	bool
> +
Please add a comment about what this symbol is used for.
Also we often name such symbols: HAVE_*

	Sam

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table.
  2012-04-20 14:59   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table Sam Ravnborg
@ 2012-04-20 16:49     ` David Daney
  0 siblings, 0 replies; 41+ messages in thread
From: David Daney @ 2012-04-20 16:49 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: David Daney, Ralf Baechle, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, Linus Torvalds, Michal Marek, linux-kernel,
	linux-mips, Andrew Morton

On 04/20/2012 07:59 AM, Sam Ravnborg wrote:
> On Thu, Apr 19, 2012 at 02:59:55PM -0700, David Daney wrote:
>> From: David Daney<david.daney@cavium.com>
>>
>> Using this build-time sort saves time booting as we don't have to burn
>> cycles sorting the exception table.
>>
>> Signed-off-by: David Daney<david.daney@cavium.com>
>> ---
>>   scripts/.gitignore    |    1 +
>>   scripts/Makefile      |    1 +
>>   scripts/sortextable.c |  273 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   scripts/sortextable.h |  168 ++++++++++++++++++++++++++++++
>
> If there is only a single file including the .h file - then there is no gain.
> Just fold it into the .c file.
>

s/single file/single site/, and I am in complete agreement.  However 
this patch doesn't meet that criterion.  In this particular case, there 
is more to the patch than just the diffstat.

David Daney

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Use .pushsection ... . popsection for _ASM_EXTABLE()
  2012-04-20  3:31       ` Linus Torvalds
  2012-04-20  3:42         ` H. Peter Anvin
@ 2012-04-20 21:55         ` tip-bot for H. Peter Anvin
  2012-04-20 21:56         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
                           ` (19 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:55 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  d4541805e812abb5110d5de83246488fa0aa9a8e
Gitweb:     http://git.kernel.org/tip/d4541805e812abb5110d5de83246488fa0aa9a8e
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:12:27 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Use .pushsection ... .popsection for _ASM_EXTABLE()

Instead of using .section ... .previous, use .pushsection
... .popsection; this is (hopefully) a bit more robust, especially in
complex assembly code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/asm.h |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index 9412d65..ff3f6bf 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -42,17 +42,17 @@
 
 /* Exception table entry */
 #ifdef __ASSEMBLY__
-# define _ASM_EXTABLE(from,to)	    \
-	__ASM_EX_SEC ;		    \
-	_ASM_ALIGN ;		    \
-	_ASM_PTR from , to ;	    \
-	.previous
+# define _ASM_EXTABLE(from,to)			\
+	.pushsection "__ex_table","a" ;		\
+	_ASM_ALIGN ;				\
+	_ASM_PTR from , to ;			\
+	.popsection
 #else
-# define _ASM_EXTABLE(from,to) \
-	__ASM_EX_SEC	\
-	_ASM_ALIGN "\n" \
-	_ASM_PTR #from "," #to "\n" \
-	" .previous\n"
+# define _ASM_EXTABLE(from,to)			\
+	" .pushsection \"__ex_table\",\"a\"\n"	\
+	_ASM_ALIGN "\n" 			\
+	_ASM_PTR #from "," #to "\n" 		\
+	" .popsection\n"
 #endif
 
 #endif /* _ASM_X86_ASM_H */

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S
  2012-04-20  3:31       ` Linus Torvalds
  2012-04-20  3:42         ` H. Peter Anvin
  2012-04-20 21:55         ` [tip:x86/extable] x86, extable: Use .pushsection ... . popsection for _ASM_EXTABLE() tip-bot for H. Peter Anvin
@ 2012-04-20 21:56         ` tip-bot for H. Peter Anvin
  2012-04-20 21:57         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_32.S tip-bot for H. Peter Anvin
                           ` (18 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:56 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  1ce6f86815a392acce2b45512106b525dc994cc0
Gitweb:     http://git.kernel.org/tip/1ce6f86815a392acce2b45512106b525dc994cc0
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S

Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/ia32/ia32entry.S |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index e3e7340..eb48edd 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -13,6 +13,7 @@
 #include <asm/thread_info.h>	
 #include <asm/segment.h>
 #include <asm/irqflags.h>
+#include <asm/asm.h>
 #include <linux/linkage.h>
 #include <linux/err.h>
 
@@ -146,9 +147,7 @@ ENTRY(ia32_sysenter_target)
  	/* no need to do an access_ok check here because rbp has been
  	   32bit zero extended */ 
 1:	movl	(%rbp),%ebp
- 	.section __ex_table,"a"
- 	.quad 1b,ia32_badarg
- 	.previous	
+	_ASM_EXTABLE(1b,ia32_badarg)
 	orl     $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
 	testl   $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
 	CFI_REMEMBER_STATE

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_32.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (2 preceding siblings ...)
  2012-04-20 21:56         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
@ 2012-04-20 21:57         ` tip-bot for H. Peter Anvin
  2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_64.S tip-bot for H. Peter Anvin
                           ` (17 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:57 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  6837a54dd6127f055dcb26d00fee0df05c07a674
Gitweb:     http://git.kernel.org/tip/6837a54dd6127f055dcb26d00fee0df05c07a674
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_32.S

Remove open-coded exception table entries in arch/x86/kernel/entry_32.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/kernel/entry_32.S |   47 +++++++++++++------------------------------
 1 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 7b784f4..01ccf9b 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -56,6 +56,7 @@
 #include <asm/irq_vectors.h>
 #include <asm/cpufeature.h>
 #include <asm/alternative-asm.h>
+#include <asm/asm.h>
 
 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
 #include <linux/elf-em.h>
@@ -151,10 +152,8 @@
 .pushsection .fixup, "ax"
 99:	movl $0, (%esp)
 	jmp 98b
-.section __ex_table, "a"
-	.align 4
-	.long 98b, 99b
 .popsection
+	_ASM_EXTABLE(98b,99b)
 .endm
 
 .macro PTGS_TO_GS
@@ -164,10 +163,8 @@
 .pushsection .fixup, "ax"
 99:	movl $0, PT_GS(%esp)
 	jmp 98b
-.section __ex_table, "a"
-	.align 4
-	.long 98b, 99b
 .popsection
+	_ASM_EXTABLE(98b,99b)
 .endm
 
 .macro GS_TO_REG reg
@@ -249,12 +246,10 @@
 	jmp 2b
 6:	movl $0, (%esp)
 	jmp 3b
-.section __ex_table, "a"
-	.align 4
-	.long 1b, 4b
-	.long 2b, 5b
-	.long 3b, 6b
 .popsection
+	_ASM_EXTABLE(1b,4b)
+	_ASM_EXTABLE(2b,5b)
+	_ASM_EXTABLE(3b,6b)
 	POP_GS_EX
 .endm
 
@@ -415,10 +410,7 @@ sysenter_past_esp:
 	jae syscall_fault
 1:	movl (%ebp),%ebp
 	movl %ebp,PT_EBP(%esp)
-.section __ex_table,"a"
-	.align 4
-	.long 1b,syscall_fault
-.previous
+	_ASM_EXTABLE(1b,syscall_fault)
 
 	GET_THREAD_INFO(%ebp)
 
@@ -485,10 +477,8 @@ sysexit_audit:
 .pushsection .fixup,"ax"
 2:	movl $0,PT_FS(%esp)
 	jmp 1b
-.section __ex_table,"a"
-	.align 4
-	.long 1b,2b
 .popsection
+	_ASM_EXTABLE(1b,2b)
 	PTGS_TO_GS_EX
 ENDPROC(ia32_sysenter_target)
 
@@ -543,10 +533,7 @@ ENTRY(iret_exc)
 	pushl $do_iret_error
 	jmp error_code
 .previous
-.section __ex_table,"a"
-	.align 4
-	.long irq_return,iret_exc
-.previous
+	_ASM_EXTABLE(irq_return,iret_exc)
 
 	CFI_RESTORE_STATE
 ldt_ss:
@@ -901,10 +888,7 @@ END(device_not_available)
 #ifdef CONFIG_PARAVIRT
 ENTRY(native_iret)
 	iret
-.section __ex_table,"a"
-	.align 4
-	.long native_iret, iret_exc
-.previous
+	_ASM_EXTABLE(native_iret, iret_exc)
 END(native_iret)
 
 ENTRY(native_irq_enable_sysexit)
@@ -1093,13 +1077,10 @@ ENTRY(xen_failsafe_callback)
 	movl %eax,16(%esp)
 	jmp 4b
 .previous
-.section __ex_table,"a"
-	.align 4
-	.long 1b,6b
-	.long 2b,7b
-	.long 3b,8b
-	.long 4b,9b
-.previous
+	_ASM_EXTABLE(1b,6b)
+	_ASM_EXTABLE(2b,7b)
+	_ASM_EXTABLE(3b,8b)
+	_ASM_EXTABLE(4b,9b)
 ENDPROC(xen_failsafe_callback)
 
 BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_64.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (3 preceding siblings ...)
  2012-04-20 21:57         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_32.S tip-bot for H. Peter Anvin
@ 2012-04-20 21:58         ` tip-bot for H. Peter Anvin
  2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c tip-bot for H. Peter Anvin
                           ` (16 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  d7abc0fa997972ddb6d3c403e03a6eefda0c0881
Gitweb:     http://git.kernel.org/tip/d7abc0fa997972ddb6d3c403e03a6eefda0c0881
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_64.S

Remove open-coded exception table entries in arch/x86/kernel/entry_64.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/kernel/entry_64.S |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index cdc79b5..320852d 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -55,6 +55,7 @@
 #include <asm/paravirt.h>
 #include <asm/ftrace.h>
 #include <asm/percpu.h>
+#include <asm/asm.h>
 #include <linux/err.h>
 
 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
@@ -900,18 +901,12 @@ restore_args:
 
 irq_return:
 	INTERRUPT_RETURN
-
-	.section __ex_table, "a"
-	.quad irq_return, bad_iret
-	.previous
+	_ASM_EXTABLE(irq_return, bad_iret)
 
 #ifdef CONFIG_PARAVIRT
 ENTRY(native_iret)
 	iretq
-
-	.section __ex_table,"a"
-	.quad native_iret, bad_iret
-	.previous
+	_ASM_EXTABLE(native_iret, bad_iret)
 #endif
 
 	.section .fixup,"ax"
@@ -1181,10 +1176,7 @@ gs_change:
 	CFI_ENDPROC
 END(native_load_gs_index)
 
-	.section __ex_table,"a"
-	.align 8
-	.quad gs_change,bad_gs
-	.previous
+	_ASM_EXTABLE(gs_change,bad_gs)
 	.section .fixup,"ax"
 	/* running with kernelgs */
 bad_gs:

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c
  2012-04-20  3:31       ` Linus Torvalds
                           ` (4 preceding siblings ...)
  2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_64.S tip-bot for H. Peter Anvin
@ 2012-04-20 21:58         ` tip-bot for H. Peter Anvin
  2012-04-20 21:59         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/checksum_32.S tip-bot for H. Peter Anvin
                           ` (15 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  5d6f8d77ede50417dcca4c31a74f0d40a1ee537a
Gitweb:     http://git.kernel.org/tip/5d6f8d77ede50417dcca4c31a74f0d40a1ee537a
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c

Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/kernel/test_rodata.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/test_rodata.c b/arch/x86/kernel/test_rodata.c
index c29e235..b79133a 100644
--- a/arch/x86/kernel/test_rodata.c
+++ b/arch/x86/kernel/test_rodata.c
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <asm/cacheflush.h>
 #include <asm/sections.h>
+#include <asm/asm.h>
 
 int rodata_test(void)
 {
@@ -42,14 +43,7 @@ int rodata_test(void)
 		".section .fixup,\"ax\"\n"
 		"2:	jmp 1b\n"
 		".previous\n"
-		".section __ex_table,\"a\"\n"
-		"       .align 16\n"
-#ifdef CONFIG_X86_32
-		"	.long 0b,2b\n"
-#else
-		"	.quad 0b,2b\n"
-#endif
-		".previous"
+		_ASM_EXTABLE(0b,2b)
 		: [rslt] "=r" (result)
 		: [rodata_test] "r" (&rodata_test_data), [zero] "r" (0UL)
 	);

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/checksum_32.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (5 preceding siblings ...)
  2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c tip-bot for H. Peter Anvin
@ 2012-04-20 21:59         ` tip-bot for H. Peter Anvin
  2012-04-20 22:00         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S tip-bot for H. Peter Anvin
                           ` (14 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 21:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  5f2e8a84f07bb43f9c0ce317d7e0c5e541db00e3
Gitweb:     http://git.kernel.org/tip/5f2e8a84f07bb43f9c0ce317d7e0c5e541db00e3
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/checksum_32.S

Remove open-coded exception table entries in arch/x86/lib/checksum_32.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/checksum_32.S |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
index 78d16a5..2af5df3 100644
--- a/arch/x86/lib/checksum_32.S
+++ b/arch/x86/lib/checksum_32.S
@@ -28,6 +28,7 @@
 #include <linux/linkage.h>
 #include <asm/dwarf2.h>
 #include <asm/errno.h>
+#include <asm/asm.h>
 				
 /*
  * computes a partial checksum, e.g. for TCP/UDP fragments
@@ -282,15 +283,11 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
 
 #define SRC(y...)			\
 	9999: y;			\
-	.section __ex_table, "a";	\
-	.long 9999b, 6001f	;	\
-	.previous
+	_ASM_EXTABLE(9999b, 6001f)
 
 #define DST(y...)			\
 	9999: y;			\
-	.section __ex_table, "a";	\
-	.long 9999b, 6002f	;	\
-	.previous
+	_ASM_EXTABLE(9999b, 6002f)
 
 #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
 

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (6 preceding siblings ...)
  2012-04-20 21:59         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/checksum_32.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:00         ` tip-bot for H. Peter Anvin
  2012-04-20 22:01         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/ copy_user_nocache_64.S tip-bot for H. Peter Anvin
                           ` (13 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:00 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  9732da8ca860053515431298ec969e1f3e6bc64a
Gitweb:     http://git.kernel.org/tip/9732da8ca860053515431298ec969e1f3e6bc64a
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:51 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S

Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/copy_user_64.S |   63 +++++++++++++++++-------------------------
 1 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
index 0248402..5b2995f 100644
--- a/arch/x86/lib/copy_user_64.S
+++ b/arch/x86/lib/copy_user_64.S
@@ -16,6 +16,7 @@
 #include <asm/thread_info.h>
 #include <asm/cpufeature.h>
 #include <asm/alternative-asm.h>
+#include <asm/asm.h>
 
 /*
  * By placing feature2 after feature1 in altinstructions section, we logically
@@ -63,11 +64,8 @@
 	jmp copy_user_handle_tail
 	.previous
 
-	.section __ex_table,"a"
-	.align 8
-	.quad 100b,103b
-	.quad 101b,103b
-	.previous
+	_ASM_EXTABLE(100b,103b)
+	_ASM_EXTABLE(101b,103b)
 #endif
 	.endm
 
@@ -191,29 +189,26 @@ ENTRY(copy_user_generic_unrolled)
 60:	jmp copy_user_handle_tail /* ecx is zerorest also */
 	.previous
 
-	.section __ex_table,"a"
-	.align 8
-	.quad 1b,30b
-	.quad 2b,30b
-	.quad 3b,30b
-	.quad 4b,30b
-	.quad 5b,30b
-	.quad 6b,30b
-	.quad 7b,30b
-	.quad 8b,30b
-	.quad 9b,30b
-	.quad 10b,30b
-	.quad 11b,30b
-	.quad 12b,30b
-	.quad 13b,30b
-	.quad 14b,30b
-	.quad 15b,30b
-	.quad 16b,30b
-	.quad 18b,40b
-	.quad 19b,40b
-	.quad 21b,50b
-	.quad 22b,50b
-	.previous
+	_ASM_EXTABLE(1b,30b)
+	_ASM_EXTABLE(2b,30b)
+	_ASM_EXTABLE(3b,30b)
+	_ASM_EXTABLE(4b,30b)
+	_ASM_EXTABLE(5b,30b)
+	_ASM_EXTABLE(6b,30b)
+	_ASM_EXTABLE(7b,30b)
+	_ASM_EXTABLE(8b,30b)
+	_ASM_EXTABLE(9b,30b)
+	_ASM_EXTABLE(10b,30b)
+	_ASM_EXTABLE(11b,30b)
+	_ASM_EXTABLE(12b,30b)
+	_ASM_EXTABLE(13b,30b)
+	_ASM_EXTABLE(14b,30b)
+	_ASM_EXTABLE(15b,30b)
+	_ASM_EXTABLE(16b,30b)
+	_ASM_EXTABLE(18b,40b)
+	_ASM_EXTABLE(19b,40b)
+	_ASM_EXTABLE(21b,50b)
+	_ASM_EXTABLE(22b,50b)
 	CFI_ENDPROC
 ENDPROC(copy_user_generic_unrolled)
 
@@ -259,11 +254,8 @@ ENTRY(copy_user_generic_string)
 	jmp copy_user_handle_tail
 	.previous
 
-	.section __ex_table,"a"
-	.align 8
-	.quad 1b,11b
-	.quad 3b,12b
-	.previous
+	_ASM_EXTABLE(1b,11b)
+	_ASM_EXTABLE(3b,12b)
 	CFI_ENDPROC
 ENDPROC(copy_user_generic_string)
 
@@ -294,9 +286,6 @@ ENTRY(copy_user_enhanced_fast_string)
 	jmp copy_user_handle_tail
 	.previous
 
-	.section __ex_table,"a"
-	.align 8
-	.quad 1b,12b
-	.previous
+	_ASM_EXTABLE(1b,12b)
 	CFI_ENDPROC
 ENDPROC(copy_user_enhanced_fast_string)

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/ copy_user_nocache_64.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (7 preceding siblings ...)
  2012-04-20 22:00         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:01         ` tip-bot for H. Peter Anvin
  2012-04-20 22:02         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S tip-bot for H. Peter Anvin
                           ` (12 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:01 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  0d8559feafbc9dc5a2c17ba42aea7de824b18308
Gitweb:     http://git.kernel.org/tip/0d8559feafbc9dc5a2c17ba42aea7de824b18308
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:51 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:38 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_nocache_64.S

Remove open-coded exception table entries in arch/x86/lib/copy_user_nocache_64.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/copy_user_nocache_64.S |   50 ++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
index cb0c112..cacddc7 100644
--- a/arch/x86/lib/copy_user_nocache_64.S
+++ b/arch/x86/lib/copy_user_nocache_64.S
@@ -14,6 +14,7 @@
 #include <asm/current.h>
 #include <asm/asm-offsets.h>
 #include <asm/thread_info.h>
+#include <asm/asm.h>
 
 	.macro ALIGN_DESTINATION
 #ifdef FIX_ALIGNMENT
@@ -36,11 +37,8 @@
 	jmp copy_user_handle_tail
 	.previous
 
-	.section __ex_table,"a"
-	.align 8
-	.quad 100b,103b
-	.quad 101b,103b
-	.previous
+	_ASM_EXTABLE(100b,103b)
+	_ASM_EXTABLE(101b,103b)
 #endif
 	.endm
 
@@ -111,27 +109,25 @@ ENTRY(__copy_user_nocache)
 	jmp copy_user_handle_tail
 	.previous
 
-	.section __ex_table,"a"
-	.quad 1b,30b
-	.quad 2b,30b
-	.quad 3b,30b
-	.quad 4b,30b
-	.quad 5b,30b
-	.quad 6b,30b
-	.quad 7b,30b
-	.quad 8b,30b
-	.quad 9b,30b
-	.quad 10b,30b
-	.quad 11b,30b
-	.quad 12b,30b
-	.quad 13b,30b
-	.quad 14b,30b
-	.quad 15b,30b
-	.quad 16b,30b
-	.quad 18b,40b
-	.quad 19b,40b
-	.quad 21b,50b
-	.quad 22b,50b
-	.previous
+	_ASM_EXTABLE(1b,30b)
+	_ASM_EXTABLE(2b,30b)
+	_ASM_EXTABLE(3b,30b)
+	_ASM_EXTABLE(4b,30b)
+	_ASM_EXTABLE(5b,30b)
+	_ASM_EXTABLE(6b,30b)
+	_ASM_EXTABLE(7b,30b)
+	_ASM_EXTABLE(8b,30b)
+	_ASM_EXTABLE(9b,30b)
+	_ASM_EXTABLE(10b,30b)
+	_ASM_EXTABLE(11b,30b)
+	_ASM_EXTABLE(12b,30b)
+	_ASM_EXTABLE(13b,30b)
+	_ASM_EXTABLE(14b,30b)
+	_ASM_EXTABLE(15b,30b)
+	_ASM_EXTABLE(16b,30b)
+	_ASM_EXTABLE(18b,40b)
+	_ASM_EXTABLE(19b,40b)
+	_ASM_EXTABLE(21b,50b)
+	_ASM_EXTABLE(22b,50b)
 	CFI_ENDPROC
 ENDPROC(__copy_user_nocache)

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (8 preceding siblings ...)
  2012-04-20 22:01         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/ copy_user_nocache_64.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:02         ` tip-bot for H. Peter Anvin
  2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/getuser.S tip-bot for H. Peter Anvin
                           ` (11 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:02 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  015e6f11a9737684469feef9d523373b1746159d
Gitweb:     http://git.kernel.org/tip/015e6f11a9737684469feef9d523373b1746159d
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:51 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S

Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/csum-copy_64.S |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
index fb903b7..2419d5f 100644
--- a/arch/x86/lib/csum-copy_64.S
+++ b/arch/x86/lib/csum-copy_64.S
@@ -8,6 +8,7 @@
 #include <linux/linkage.h>
 #include <asm/dwarf2.h>
 #include <asm/errno.h>
+#include <asm/asm.h>
 
 /*
  * Checksum copy with exception handling.
@@ -31,26 +32,17 @@
 
 	.macro source
 10:
-	.section __ex_table, "a"
-	.align 8
-	.quad 10b, .Lbad_source
-	.previous
+	_ASM_EXTABLE(10b, .Lbad_source)
 	.endm
 
 	.macro dest
 20:
-	.section __ex_table, "a"
-	.align 8
-	.quad 20b, .Lbad_dest
-	.previous
+	_ASM_EXTABLE(20b, .Lbad_dest)
 	.endm
 
 	.macro ignore L=.Lignore
 30:
-	.section __ex_table, "a"
-	.align 8
-	.quad 30b, \L
-	.previous
+	_ASM_EXTABLE(30b, \L)
 	.endm
 
 

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/getuser.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (9 preceding siblings ...)
  2012-04-20 22:02         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:03         ` tip-bot for H. Peter Anvin
  2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/putuser.S tip-bot for H. Peter Anvin
                           ` (10 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  1a27bc0d99aabea6b628cb994a21a1c79b569fc9
Gitweb:     http://git.kernel.org/tip/1a27bc0d99aabea6b628cb994a21a1c79b569fc9
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:51 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/getuser.S

Remove open-coded exception table entries in arch/x86/lib/getuser.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/getuser.S |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
index 51f1504..b33b1fb 100644
--- a/arch/x86/lib/getuser.S
+++ b/arch/x86/lib/getuser.S
@@ -95,10 +95,9 @@ bad_get_user:
 	CFI_ENDPROC
 END(bad_get_user)
 
-.section __ex_table,"a"
-	_ASM_PTR 1b,bad_get_user
-	_ASM_PTR 2b,bad_get_user
-	_ASM_PTR 3b,bad_get_user
+	_ASM_EXTABLE(1b,bad_get_user)
+	_ASM_EXTABLE(2b,bad_get_user)
+	_ASM_EXTABLE(3b,bad_get_user)
 #ifdef CONFIG_X86_64
-	_ASM_PTR 4b,bad_get_user
+	_ASM_EXTABLE(4b,bad_get_user)
 #endif

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/putuser.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (10 preceding siblings ...)
  2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/getuser.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:03         ` tip-bot for H. Peter Anvin
  2012-04-20 22:04         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c tip-bot for H. Peter Anvin
                           ` (9 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  a53a96e5413d3639ed75d202bbfe68aa0a56c091
Gitweb:     http://git.kernel.org/tip/a53a96e5413d3639ed75d202bbfe68aa0a56c091
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:52 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/putuser.S

Remove open-coded exception table entries in arch/x86/lib/putuser.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/putuser.S |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
index 36b0d15..7f951c8 100644
--- a/arch/x86/lib/putuser.S
+++ b/arch/x86/lib/putuser.S
@@ -86,12 +86,10 @@ bad_put_user:
 	EXIT
 END(bad_put_user)
 
-.section __ex_table,"a"
-	_ASM_PTR 1b,bad_put_user
-	_ASM_PTR 2b,bad_put_user
-	_ASM_PTR 3b,bad_put_user
-	_ASM_PTR 4b,bad_put_user
+	_ASM_EXTABLE(1b,bad_put_user)
+	_ASM_EXTABLE(2b,bad_put_user)
+	_ASM_EXTABLE(3b,bad_put_user)
+	_ASM_EXTABLE(4b,bad_put_user)
 #ifdef CONFIG_X86_32
-	_ASM_PTR 5b,bad_put_user
+	_ASM_EXTABLE(5b,bad_put_user)
 #endif
-.previous

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c
  2012-04-20  3:31       ` Linus Torvalds
                           ` (11 preceding siblings ...)
  2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/putuser.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:04         ` tip-bot for H. Peter Anvin
  2012-04-20 22:05         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/um/checksum_32.S tip-bot for H. Peter Anvin
                           ` (8 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:04 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  9c6751280b6206e2a96f9600938003a29968e4fa
Gitweb:     http://git.kernel.org/tip/9c6751280b6206e2a96f9600938003a29968e4fa
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:52 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c

Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/lib/usercopy_32.c |  232 ++++++++++++++++++++------------------------
 1 files changed, 106 insertions(+), 126 deletions(-)

diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index ef2a6a5..883b216 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -13,6 +13,7 @@
 #include <linux/interrupt.h>
 #include <asm/uaccess.h>
 #include <asm/mmx.h>
+#include <asm/asm.h>
 
 #ifdef CONFIG_X86_INTEL_USERCOPY
 /*
@@ -127,10 +128,7 @@ long strnlen_user(const char __user *s, long n)
 		"3:	movb $1,%%al\n"
 		"	jmp 1b\n"
 		".previous\n"
-		".section __ex_table,\"a\"\n"
-		"	.align 4\n"
-		"	.long 0b,2b\n"
-		".previous"
+		_ASM_EXTABLE(0b,2b)
 		:"=&r" (n), "=&D" (s), "=&a" (res), "=&c" (tmp)
 		:"0" (n), "1" (s), "2" (0), "3" (mask)
 		:"cc");
@@ -199,47 +197,44 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
 		       "101:   lea 0(%%eax,%0,4),%0\n"
 		       "       jmp 100b\n"
 		       ".previous\n"
-		       ".section __ex_table,\"a\"\n"
-		       "       .align 4\n"
-		       "       .long 1b,100b\n"
-		       "       .long 2b,100b\n"
-		       "       .long 3b,100b\n"
-		       "       .long 4b,100b\n"
-		       "       .long 5b,100b\n"
-		       "       .long 6b,100b\n"
-		       "       .long 7b,100b\n"
-		       "       .long 8b,100b\n"
-		       "       .long 9b,100b\n"
-		       "       .long 10b,100b\n"
-		       "       .long 11b,100b\n"
-		       "       .long 12b,100b\n"
-		       "       .long 13b,100b\n"
-		       "       .long 14b,100b\n"
-		       "       .long 15b,100b\n"
-		       "       .long 16b,100b\n"
-		       "       .long 17b,100b\n"
-		       "       .long 18b,100b\n"
-		       "       .long 19b,100b\n"
-		       "       .long 20b,100b\n"
-		       "       .long 21b,100b\n"
-		       "       .long 22b,100b\n"
-		       "       .long 23b,100b\n"
-		       "       .long 24b,100b\n"
-		       "       .long 25b,100b\n"
-		       "       .long 26b,100b\n"
-		       "       .long 27b,100b\n"
-		       "       .long 28b,100b\n"
-		       "       .long 29b,100b\n"
-		       "       .long 30b,100b\n"
-		       "       .long 31b,100b\n"
-		       "       .long 32b,100b\n"
-		       "       .long 33b,100b\n"
-		       "       .long 34b,100b\n"
-		       "       .long 35b,100b\n"
-		       "       .long 36b,100b\n"
-		       "       .long 37b,100b\n"
-		       "       .long 99b,101b\n"
-		       ".previous"
+		       _ASM_EXTABLE(1b,100b)
+		       _ASM_EXTABLE(2b,100b)
+		       _ASM_EXTABLE(3b,100b)
+		       _ASM_EXTABLE(4b,100b)
+		       _ASM_EXTABLE(5b,100b)
+		       _ASM_EXTABLE(6b,100b)
+		       _ASM_EXTABLE(7b,100b)
+		       _ASM_EXTABLE(8b,100b)
+		       _ASM_EXTABLE(9b,100b)
+		       _ASM_EXTABLE(10b,100b)
+		       _ASM_EXTABLE(11b,100b)
+		       _ASM_EXTABLE(12b,100b)
+		       _ASM_EXTABLE(13b,100b)
+		       _ASM_EXTABLE(14b,100b)
+		       _ASM_EXTABLE(15b,100b)
+		       _ASM_EXTABLE(16b,100b)
+		       _ASM_EXTABLE(17b,100b)
+		       _ASM_EXTABLE(18b,100b)
+		       _ASM_EXTABLE(19b,100b)
+		       _ASM_EXTABLE(20b,100b)
+		       _ASM_EXTABLE(21b,100b)
+		       _ASM_EXTABLE(22b,100b)
+		       _ASM_EXTABLE(23b,100b)
+		       _ASM_EXTABLE(24b,100b)
+		       _ASM_EXTABLE(25b,100b)
+		       _ASM_EXTABLE(26b,100b)
+		       _ASM_EXTABLE(27b,100b)
+		       _ASM_EXTABLE(28b,100b)
+		       _ASM_EXTABLE(29b,100b)
+		       _ASM_EXTABLE(30b,100b)
+		       _ASM_EXTABLE(31b,100b)
+		       _ASM_EXTABLE(32b,100b)
+		       _ASM_EXTABLE(33b,100b)
+		       _ASM_EXTABLE(34b,100b)
+		       _ASM_EXTABLE(35b,100b)
+		       _ASM_EXTABLE(36b,100b)
+		       _ASM_EXTABLE(37b,100b)
+		       _ASM_EXTABLE(99b,101b)
 		       : "=&c"(size), "=&D" (d0), "=&S" (d1)
 		       :  "1"(to), "2"(from), "0"(size)
 		       : "eax", "edx", "memory");
@@ -312,29 +307,26 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
 		       "        popl %0\n"
 		       "        jmp 8b\n"
 		       ".previous\n"
-		       ".section __ex_table,\"a\"\n"
-		       "	.align 4\n"
-		       "	.long 0b,16b\n"
-		       "	.long 1b,16b\n"
-		       "	.long 2b,16b\n"
-		       "	.long 21b,16b\n"
-		       "	.long 3b,16b\n"
-		       "	.long 31b,16b\n"
-		       "	.long 4b,16b\n"
-		       "	.long 41b,16b\n"
-		       "	.long 10b,16b\n"
-		       "	.long 51b,16b\n"
-		       "	.long 11b,16b\n"
-		       "	.long 61b,16b\n"
-		       "	.long 12b,16b\n"
-		       "	.long 71b,16b\n"
-		       "	.long 13b,16b\n"
-		       "	.long 81b,16b\n"
-		       "	.long 14b,16b\n"
-		       "	.long 91b,16b\n"
-		       "	.long 6b,9b\n"
-		       "        .long 7b,16b\n"
-		       ".previous"
+		       _ASM_EXTABLE(0b,16b)
+		       _ASM_EXTABLE(1b,16b)
+		       _ASM_EXTABLE(2b,16b)
+		       _ASM_EXTABLE(21b,16b)
+		       _ASM_EXTABLE(3b,16b)
+		       _ASM_EXTABLE(31b,16b)
+		       _ASM_EXTABLE(4b,16b)
+		       _ASM_EXTABLE(41b,16b)
+		       _ASM_EXTABLE(10b,16b)
+		       _ASM_EXTABLE(51b,16b)
+		       _ASM_EXTABLE(11b,16b)
+		       _ASM_EXTABLE(61b,16b)
+		       _ASM_EXTABLE(12b,16b)
+		       _ASM_EXTABLE(71b,16b)
+		       _ASM_EXTABLE(13b,16b)
+		       _ASM_EXTABLE(81b,16b)
+		       _ASM_EXTABLE(14b,16b)
+		       _ASM_EXTABLE(91b,16b)
+		       _ASM_EXTABLE(6b,9b)
+		       _ASM_EXTABLE(7b,16b)
 		       : "=&c"(size), "=&D" (d0), "=&S" (d1)
 		       :  "1"(to), "2"(from), "0"(size)
 		       : "eax", "edx", "memory");
@@ -414,29 +406,26 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
 	       "        popl %0\n"
 	       "        jmp 8b\n"
 	       ".previous\n"
-	       ".section __ex_table,\"a\"\n"
-	       "	.align 4\n"
-	       "	.long 0b,16b\n"
-	       "	.long 1b,16b\n"
-	       "	.long 2b,16b\n"
-	       "	.long 21b,16b\n"
-	       "	.long 3b,16b\n"
-	       "	.long 31b,16b\n"
-	       "	.long 4b,16b\n"
-	       "	.long 41b,16b\n"
-	       "	.long 10b,16b\n"
-	       "	.long 51b,16b\n"
-	       "	.long 11b,16b\n"
-	       "	.long 61b,16b\n"
-	       "	.long 12b,16b\n"
-	       "	.long 71b,16b\n"
-	       "	.long 13b,16b\n"
-	       "	.long 81b,16b\n"
-	       "	.long 14b,16b\n"
-	       "	.long 91b,16b\n"
-	       "	.long 6b,9b\n"
-	       "        .long 7b,16b\n"
-	       ".previous"
+	       _ASM_EXTABLE(0b,16b)
+	       _ASM_EXTABLE(1b,16b)
+	       _ASM_EXTABLE(2b,16b)
+	       _ASM_EXTABLE(21b,16b)
+	       _ASM_EXTABLE(3b,16b)
+	       _ASM_EXTABLE(31b,16b)
+	       _ASM_EXTABLE(4b,16b)
+	       _ASM_EXTABLE(41b,16b)
+	       _ASM_EXTABLE(10b,16b)
+	       _ASM_EXTABLE(51b,16b)
+	       _ASM_EXTABLE(11b,16b)
+	       _ASM_EXTABLE(61b,16b)
+	       _ASM_EXTABLE(12b,16b)
+	       _ASM_EXTABLE(71b,16b)
+	       _ASM_EXTABLE(13b,16b)
+	       _ASM_EXTABLE(81b,16b)
+	       _ASM_EXTABLE(14b,16b)
+	       _ASM_EXTABLE(91b,16b)
+	       _ASM_EXTABLE(6b,9b)
+	       _ASM_EXTABLE(7b,16b)
 	       : "=&c"(size), "=&D" (d0), "=&S" (d1)
 	       :  "1"(to), "2"(from), "0"(size)
 	       : "eax", "edx", "memory");
@@ -505,29 +494,26 @@ static unsigned long __copy_user_intel_nocache(void *to,
 	       "9:      lea 0(%%eax,%0,4),%0\n"
 	       "16:     jmp 8b\n"
 	       ".previous\n"
-	       ".section __ex_table,\"a\"\n"
-	       "	.align 4\n"
-	       "	.long 0b,16b\n"
-	       "	.long 1b,16b\n"
-	       "	.long 2b,16b\n"
-	       "	.long 21b,16b\n"
-	       "	.long 3b,16b\n"
-	       "	.long 31b,16b\n"
-	       "	.long 4b,16b\n"
-	       "	.long 41b,16b\n"
-	       "	.long 10b,16b\n"
-	       "	.long 51b,16b\n"
-	       "	.long 11b,16b\n"
-	       "	.long 61b,16b\n"
-	       "	.long 12b,16b\n"
-	       "	.long 71b,16b\n"
-	       "	.long 13b,16b\n"
-	       "	.long 81b,16b\n"
-	       "	.long 14b,16b\n"
-	       "	.long 91b,16b\n"
-	       "	.long 6b,9b\n"
-	       "        .long 7b,16b\n"
-	       ".previous"
+	       _ASM_EXTABLE(0b,16b)
+	       _ASM_EXTABLE(1b,16b)
+	       _ASM_EXTABLE(2b,16b)
+	       _ASM_EXTABLE(21b,16b)
+	       _ASM_EXTABLE(3b,16b)
+	       _ASM_EXTABLE(31b,16b)
+	       _ASM_EXTABLE(4b,16b)
+	       _ASM_EXTABLE(41b,16b)
+	       _ASM_EXTABLE(10b,16b)
+	       _ASM_EXTABLE(51b,16b)
+	       _ASM_EXTABLE(11b,16b)
+	       _ASM_EXTABLE(61b,16b)
+	       _ASM_EXTABLE(12b,16b)
+	       _ASM_EXTABLE(71b,16b)
+	       _ASM_EXTABLE(13b,16b)
+	       _ASM_EXTABLE(81b,16b)
+	       _ASM_EXTABLE(14b,16b)
+	       _ASM_EXTABLE(91b,16b)
+	       _ASM_EXTABLE(6b,9b)
+	       _ASM_EXTABLE(7b,16b)
 	       : "=&c"(size), "=&D" (d0), "=&S" (d1)
 	       :  "1"(to), "2"(from), "0"(size)
 	       : "eax", "edx", "memory");
@@ -574,12 +560,9 @@ do {									\
 		"3:	lea 0(%3,%0,4),%0\n"				\
 		"	jmp 2b\n"					\
 		".previous\n"						\
-		".section __ex_table,\"a\"\n"				\
-		"	.align 4\n"					\
-		"	.long 4b,5b\n"					\
-		"	.long 0b,3b\n"					\
-		"	.long 1b,2b\n"					\
-		".previous"						\
+		_ASM_EXTABLE(4b,5b)					\
+		_ASM_EXTABLE(0b,3b)					\
+		_ASM_EXTABLE(1b,2b)					\
 		: "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)	\
 		: "3"(size), "0"(size), "1"(to), "2"(from)		\
 		: "memory");						\
@@ -616,12 +599,9 @@ do {									\
 		"	popl %0\n"					\
 		"	jmp 2b\n"					\
 		".previous\n"						\
-		".section __ex_table,\"a\"\n"				\
-		"	.align 4\n"					\
-		"	.long 4b,5b\n"					\
-		"	.long 0b,3b\n"					\
-		"	.long 1b,6b\n"					\
-		".previous"						\
+		_ASM_EXTABLE(4b,5b)					\
+		_ASM_EXTABLE(0b,3b)					\
+		_ASM_EXTABLE(1b,6b)					\
 		: "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)	\
 		: "3"(size), "0"(size), "1"(to), "2"(from)		\
 		: "memory");						\

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/um/checksum_32.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (12 preceding siblings ...)
  2012-04-20 22:04         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c tip-bot for H. Peter Anvin
@ 2012-04-20 22:05         ` tip-bot for H. Peter Anvin
  2012-04-20 22:06         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S tip-bot for H. Peter Anvin
                           ` (7 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, richard, david.daney, tglx, viro

Commit-ID:  f542c5d6e57ea32daae3708a71911d9f5c883c5a
Gitweb:     http://git.kernel.org/tip/f542c5d6e57ea32daae3708a71911d9f5c883c5a
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:52 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/um/checksum_32.S

Remove open-coded exception table entries in arch/x86/um/checksum_32.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/um/checksum_32.S |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/um/checksum_32.S b/arch/x86/um/checksum_32.S
index f058d2f..8d0c420 100644
--- a/arch/x86/um/checksum_32.S
+++ b/arch/x86/um/checksum_32.S
@@ -26,6 +26,7 @@
  */
 
 #include <asm/errno.h>
+#include <asm/asm.h>
 				
 /*
  * computes a partial checksum, e.g. for TCP/UDP fragments
@@ -232,15 +233,11 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
 
 #define SRC(y...)			\
 	9999: y;			\
-	.section __ex_table, "a";	\
-	.long 9999b, 6001f	;	\
-	.previous
+	_ASM_EXTABLE(9999b, 6001f)
 
 #define DST(y...)			\
 	9999: y;			\
-	.section __ex_table, "a";	\
-	.long 9999b, 6002f	;	\
-	.previous
+	_ASM_EXTABLE(9999b, 6002f)
 
 .align 4
 

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (13 preceding siblings ...)
  2012-04-20 22:05         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/um/checksum_32.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:06         ` tip-bot for H. Peter Anvin
  2012-04-20 22:07         ` [tip:x86/extable] x86, extable: Remove the now-unused __ASM_EX_SEC macros tip-bot for H. Peter Anvin
                           ` (6 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, jeremy, hpa, mingo, konrad.wilk, david.daney, tglx

Commit-ID:  8f6380b9ec1cc4bed9b38144f739b87dd2cddb1d
Gitweb:     http://git.kernel.org/tip/8f6380b9ec1cc4bed9b38144f739b87dd2cddb1d
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:19:52 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:39 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S

Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/xen/xen-asm_32.S |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
index b040b0e..f9643fc 100644
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -14,6 +14,7 @@
 #include <asm/thread_info.h>
 #include <asm/processor-flags.h>
 #include <asm/segment.h>
+#include <asm/asm.h>
 
 #include <xen/interface/xen.h>
 
@@ -137,10 +138,7 @@ iret_restore_end:
 
 1:	iret
 xen_iret_end_crit:
-.section __ex_table, "a"
-	.align 4
-	.long 1b, iret_exc
-.previous
+	_ASM_EXTABLE(1b, iret_exc)
 
 hyper_iret:
 	/* put this out of line since its very rarely used */

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove the now-unused __ASM_EX_SEC macros
  2012-04-20  3:31       ` Linus Torvalds
                           ` (14 preceding siblings ...)
  2012-04-20 22:06         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S tip-bot for H. Peter Anvin
@ 2012-04-20 22:07         ` tip-bot for H. Peter Anvin
  2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/kvm_host .h tip-bot for H. Peter Anvin
                           ` (5 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:07 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  447657e31235c692f579c639250317c7f565cd0d
Gitweb:     http://git.kernel.org/tip/447657e31235c692f579c639250317c7f565cd0d
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 12:20:30 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:40 -0700

x86, extable: Remove the now-unused __ASM_EX_SEC macros

Nothing should use them anymore; only _ASM_EXTABLE() should ever be
used.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/asm.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index ff3f6bf..53dce41 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -4,11 +4,9 @@
 #ifdef __ASSEMBLY__
 # define __ASM_FORM(x)	x
 # define __ASM_FORM_COMMA(x) x,
-# define __ASM_EX_SEC	.section __ex_table, "a"
 #else
 # define __ASM_FORM(x)	" " #x " "
 # define __ASM_FORM_COMMA(x) " " #x ","
-# define __ASM_EX_SEC	" .section __ex_table,\"a\"\n"
 #endif
 
 #ifdef CONFIG_X86_32

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/kvm_host .h
  2012-04-20  3:31       ` Linus Torvalds
                           ` (15 preceding siblings ...)
  2012-04-20 22:07         ` [tip:x86/extable] x86, extable: Remove the now-unused __ASM_EX_SEC macros tip-bot for H. Peter Anvin
@ 2012-04-20 22:08         ` tip-bot for H. Peter Anvin
  2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/xsave.h tip-bot for H. Peter Anvin
                           ` (4 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, mtosatti, david.daney, tglx, avi

Commit-ID:  3ee89722cfb165295cc8eb498018c0bdafc57062
Gitweb:     http://git.kernel.org/tip/3ee89722cfb165295cc8eb498018c0bdafc57062
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 13:41:59 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:40 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/kvm_host.h

Remove open-coded exception table entries in arch/x86/include/asm/kvm_host.h,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/kvm_host.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e216ba0..e5b97be 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -27,6 +27,7 @@
 #include <asm/desc.h>
 #include <asm/mtrr.h>
 #include <asm/msr-index.h>
+#include <asm/asm.h>
 
 #define KVM_MAX_VCPUS 254
 #define KVM_SOFT_MAX_VCPUS 160
@@ -921,9 +922,7 @@ extern bool kvm_rebooting;
 	__ASM_SIZE(push) " $666b \n\t"	      \
 	"call kvm_spurious_fault \n\t"	      \
 	".popsection \n\t" \
-	".pushsection __ex_table, \"a\" \n\t" \
-	_ASM_PTR " 666b, 667b \n\t" \
-	".popsection"
+	_ASM_EXTABLE(666b, 667b)
 
 #define __kvm_handle_fault_on_reboot(insn)		\
 	____kvm_handle_fault_on_reboot(insn, "")

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/xsave.h
  2012-04-20  3:31       ` Linus Torvalds
                           ` (16 preceding siblings ...)
  2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/kvm_host .h tip-bot for H. Peter Anvin
@ 2012-04-20 22:08         ` tip-bot for H. Peter Anvin
  2012-04-21  0:16         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
                           ` (3 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-20 22:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, suresh.b.siddha, david.daney, tglx

Commit-ID:  7a040a4384c7c4973deb4d58a76e1b0ee3c8aa39
Gitweb:     http://git.kernel.org/tip/7a040a4384c7c4973deb4d58a76e1b0ee3c8aa39
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 13:42:25 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 13:51:40 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/xsave.h

Remove open-coded exception table entries in arch/x86/include/asm/xsave.h,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/xsave.h |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
index c6ce245..8a1b6f9 100644
--- a/arch/x86/include/asm/xsave.h
+++ b/arch/x86/include/asm/xsave.h
@@ -80,10 +80,7 @@ static inline int xsave_user(struct xsave_struct __user *buf)
 			     "3:  movl $-1,%[err]\n"
 			     "    jmp  2b\n"
 			     ".previous\n"
-			     ".section __ex_table,\"a\"\n"
-			     _ASM_ALIGN "\n"
-			     _ASM_PTR "1b,3b\n"
-			     ".previous"
+			     _ASM_EXTABLE(1b,3b)
 			     : [err] "=r" (err)
 			     : "D" (buf), "a" (-1), "d" (-1), "0" (0)
 			     : "memory");
@@ -106,10 +103,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
 			     "3:  movl $-1,%[err]\n"
 			     "    jmp  2b\n"
 			     ".previous\n"
-			     ".section __ex_table,\"a\"\n"
-			     _ASM_ALIGN "\n"
-			     _ASM_PTR "1b,3b\n"
-			     ".previous"
+			     _ASM_EXTABLE(1b,3b)
 			     : [err] "=r" (err)
 			     : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
 			     : "memory");	/* memory required? */

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S
  2012-04-20  3:31       ` Linus Torvalds
                           ` (17 preceding siblings ...)
  2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/xsave.h tip-bot for H. Peter Anvin
@ 2012-04-21  0:16         ` tip-bot for H. Peter Anvin
  2012-04-21  0:17         ` [tip:x86/extable] x86, extable: Add _ASM_EXTABLE_EX() macro tip-bot for H. Peter Anvin
                           ` (2 subsequent siblings)
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-21  0:16 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  a3e859fed1244b72253718e076a724ffe13a9584
Gitweb:     http://git.kernel.org/tip/a3e859fed1244b72253718e076a724ffe13a9584
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 16:51:50 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 16:51:50 -0700

x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S

Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S,
and replace them with _ASM_EXTABLE() macros; this will allow us to
change the format and type of the exception table entries.

This one was missed from the previous patch to this file.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/ia32/ia32entry.S |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index eb48edd..20e5f7b 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -302,9 +302,7 @@ ENTRY(ia32_cstar_target)
 	   32bit zero extended */ 
 	/* hardware stack frame is complete now */	
 1:	movl	(%r8),%r9d
-	.section __ex_table,"a"
-	.quad 1b,ia32_badarg
-	.previous	
+	_ASM_EXTABLE(1b,ia32_badarg)
 	orl     $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
 	testl   $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
 	CFI_REMEMBER_STATE

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Add _ASM_EXTABLE_EX() macro
  2012-04-20  3:31       ` Linus Torvalds
                           ` (18 preceding siblings ...)
  2012-04-21  0:16         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
@ 2012-04-21  0:17         ` tip-bot for H. Peter Anvin
  2012-04-21  1:16         ` [tip:x86/extable] x86, extable: Disable presorted exception table for now tip-bot for H. Peter Anvin
  2012-04-21  1:17         ` [tip:x86/extable] x86, extable: Switch to relative exception table entries tip-bot for H. Peter Anvin
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-21  0:17 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  535c0c34698061544f81a51c65fc51f4eeeebff6
Gitweb:     http://git.kernel.org/tip/535c0c34698061544f81a51c65fc51f4eeeebff6
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 16:57:35 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 16:57:35 -0700

x86, extable: Add _ASM_EXTABLE_EX() macro

Add _ASM_EXTABLE_EX() to generate the special extable entries that are
associated with uaccess_err.  This allows us to change the protocol
associated with these special entries.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/asm.h     |   28 ++++++++++++++++++++--------
 arch/x86/include/asm/uaccess.h |    8 ++++----
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index 53dce41..0f15e8a 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -40,16 +40,28 @@
 
 /* Exception table entry */
 #ifdef __ASSEMBLY__
-# define _ASM_EXTABLE(from,to)			\
-	.pushsection "__ex_table","a" ;		\
-	_ASM_ALIGN ;				\
-	_ASM_PTR from , to ;			\
+# define _ASM_EXTABLE(from,to)					\
+	.pushsection "__ex_table","a" ;				\
+	_ASM_ALIGN ;						\
+	_ASM_PTR from , to ;					\
+	.popsection
+
+# define _ASM_EXTABLE_EX(from,to)				\
+	.pushsection "__ex_table","a" ;				\
+	_ASM_ALIGN ;						\
+	_ASM_PTR from , (to) - (from) ;				\
 	.popsection
 #else
-# define _ASM_EXTABLE(from,to)			\
-	" .pushsection \"__ex_table\",\"a\"\n"	\
-	_ASM_ALIGN "\n" 			\
-	_ASM_PTR #from "," #to "\n" 		\
+# define _ASM_EXTABLE(from,to)					\
+	" .pushsection \"__ex_table\",\"a\"\n"			\
+	_ASM_ALIGN "\n" 					\
+	_ASM_PTR #from "," #to "\n" 				\
+	" .popsection\n"
+
+# define _ASM_EXTABLE_EX(from,to)				\
+	" .pushsection \"__ex_table\",\"a\"\n"			\
+	_ASM_ALIGN "\n" 					\
+	_ASM_PTR #from ",(" #to ")-(" #from ")\n" 		\
 	" .popsection\n"
 #endif
 
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index e054459..4ee59dd 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -202,8 +202,8 @@ extern int __get_user_bad(void);
 	asm volatile("1:	movl %%eax,0(%1)\n"			\
 		     "2:	movl %%edx,4(%1)\n"			\
 		     "3:\n"						\
-		     _ASM_EXTABLE(1b, 2b - 1b)				\
-		     _ASM_EXTABLE(2b, 3b - 2b)				\
+		     _ASM_EXTABLE_EX(1b, 2b)				\
+		     _ASM_EXTABLE_EX(2b, 3b)				\
 		     : : "A" (x), "r" (addr))
 
 #define __put_user_x8(x, ptr, __ret_pu)				\
@@ -408,7 +408,7 @@ do {									\
 #define __get_user_asm_ex(x, addr, itype, rtype, ltype)			\
 	asm volatile("1:	mov"itype" %1,%"rtype"0\n"		\
 		     "2:\n"						\
-		     _ASM_EXTABLE(1b, 2b - 1b)				\
+		     _ASM_EXTABLE_EX(1b, 2b)				\
 		     : ltype(x) : "m" (__m(addr)))
 
 #define __put_user_nocheck(x, ptr, size)			\
@@ -450,7 +450,7 @@ struct __large_struct { unsigned long buf[100]; };
 #define __put_user_asm_ex(x, addr, itype, rtype, ltype)			\
 	asm volatile("1:	mov"itype" %"rtype"0,%1\n"		\
 		     "2:\n"						\
-		     _ASM_EXTABLE(1b, 2b - 1b)				\
+		     _ASM_EXTABLE_EX(1b, 2b)				\
 		     : : ltype(x), "m" (__m(addr)))
 
 /*

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Disable presorted exception table for now
  2012-04-20  3:31       ` Linus Torvalds
                           ` (19 preceding siblings ...)
  2012-04-21  0:17         ` [tip:x86/extable] x86, extable: Add _ASM_EXTABLE_EX() macro tip-bot for H. Peter Anvin
@ 2012-04-21  1:16         ` tip-bot for H. Peter Anvin
  2012-04-21  1:17         ` [tip:x86/extable] x86, extable: Switch to relative exception table entries tip-bot for H. Peter Anvin
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-21  1:16 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  fa574a48a1e9706bba38188d3bf61ecb66546a77
Gitweb:     http://git.kernel.org/tip/fa574a48a1e9706bba38188d3bf61ecb66546a77
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 17:11:17 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 17:11:17 -0700

x86, extable: Disable presorted exception table for now

Disable presorting the exception table in preparation for changing the
format.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/Kconfig |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 2f925cc..1d14cc6 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -82,7 +82,6 @@ config X86
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
 	select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC
-	select BUILDTIME_EXTABLE_SORT
 
 config INSTRUCTION_DECODER
 	def_bool (KPROBES || PERF_EVENTS)

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [tip:x86/extable] x86, extable: Switch to relative exception table entries
  2012-04-20  3:31       ` Linus Torvalds
                           ` (20 preceding siblings ...)
  2012-04-21  1:16         ` [tip:x86/extable] x86, extable: Disable presorted exception table for now tip-bot for H. Peter Anvin
@ 2012-04-21  1:17         ` tip-bot for H. Peter Anvin
  21 siblings, 0 replies; 41+ messages in thread
From: tip-bot for H. Peter Anvin @ 2012-04-21  1:17 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, david.daney, tglx

Commit-ID:  706276543b699d80f546e45f8b12574e7b18d952
Gitweb:     http://git.kernel.org/tip/706276543b699d80f546e45f8b12574e7b18d952
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 20 Apr 2012 17:12:48 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 20 Apr 2012 17:22:34 -0700

x86, extable: Switch to relative exception table entries

Switch to using relative exception table entries on x86.  On i386,
this has the advantage that the exception table entries don't need to
be relocated; on x86-64 this means the exception table entries take up
only half the space.

In either case, a 32-bit delta is sufficient, as the range of kernel
code addresses is limited.

Since part of the goal is to avoid needing to adjust the entries when
the kernel is relocated, the old trick of using addresses in the NULL
pointer range to indicate uaccess_err no longer works (and unlike RISC
architectures we can't use a flag bit); instead use an delta just
below +2G to indicate these special entries.  The reach is still
limited to a single instruction.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: David Daney <david.daney@cavium.com>
Link: http://lkml.kernel.org/r/CA%2B55aFyijf43qSu3N9nWHEBwaGbb7T2Oq9A=9EyR=Jtyqfq_cQ@mail.gmail.com
---
 arch/x86/include/asm/asm.h     |   20 ++++---
 arch/x86/include/asm/uaccess.h |   17 ++++--
 arch/x86/mm/extable.c          |  131 +++++++++++++++++++++++++++++++++++++---
 3 files changed, 146 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index 0f15e8a..1c2d247 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -42,26 +42,30 @@
 #ifdef __ASSEMBLY__
 # define _ASM_EXTABLE(from,to)					\
 	.pushsection "__ex_table","a" ;				\
-	_ASM_ALIGN ;						\
-	_ASM_PTR from , to ;					\
+	.balign 8 ;						\
+	.long (from) - . ;					\
+	.long (to) - . ;					\
 	.popsection
 
 # define _ASM_EXTABLE_EX(from,to)				\
 	.pushsection "__ex_table","a" ;				\
-	_ASM_ALIGN ;						\
-	_ASM_PTR from , (to) - (from) ;				\
+	.balign 8 ;						\
+	.long (from) - . ;					\
+	.long (to) - . + 0x7ffffff0 ;				\
 	.popsection
 #else
 # define _ASM_EXTABLE(from,to)					\
 	" .pushsection \"__ex_table\",\"a\"\n"			\
-	_ASM_ALIGN "\n" 					\
-	_ASM_PTR #from "," #to "\n" 				\
+	" .balign 8\n"						\
+	" .long (" #from ") - .\n"				\
+	" .long (" #to ") - .\n"				\
 	" .popsection\n"
 
 # define _ASM_EXTABLE_EX(from,to)				\
 	" .pushsection \"__ex_table\",\"a\"\n"			\
-	_ASM_ALIGN "\n" 					\
-	_ASM_PTR #from ",(" #to ")-(" #from ")\n" 		\
+	" .balign 8\n"						\
+	" .long (" #from ") - .\n"				\
+	" .long (" #to ") - . + 0x7ffffff0\n"			\
 	" .popsection\n"
 #endif
 
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 4ee59dd..851fe0d 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -79,11 +79,12 @@
 #define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
 
 /*
- * 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 addresses relative to the
+ * exception table enty itself: 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.
  *
  * 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,
@@ -92,10 +93,14 @@
  */
 
 struct exception_table_entry {
-	unsigned long insn, fixup;
+	int insn, fixup;
 };
+/* This is not the generic standard exception_table_entry format */
+#define ARCH_HAS_SORT_EXTABLE
+#define ARCH_HAS_SEARCH_EXTABLE
 
 extern int fixup_exception(struct pt_regs *regs);
+extern int early_fixup_exception(unsigned long *ip);
 
 /*
  * These are the main single-value transfer routines.  They automatically
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 5555675..903ec1e 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -1,11 +1,23 @@
 #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;
+}
 
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
+	unsigned long new_ip;
 
 #ifdef CONFIG_PNPBIOS
 	if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
@@ -23,13 +35,14 @@ int fixup_exception(struct pt_regs *regs)
 
 	fixup = search_exception_tables(regs->ip);
 	if (fixup) {
-		/* If fixup is less than 16, it means uaccess error */
-		if (fixup->fixup < 16) {
+		new_ip = ex_fixup_addr(fixup);
+
+		if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
+			/* Special hack for uaccess_err */
 			current_thread_info()->uaccess_err = 1;
-			regs->ip += fixup->fixup;
-			return 1;
+			new_ip -= 0x7ffffff0;
 		}
-		regs->ip = fixup->fixup;
+		regs->ip = new_ip;
 		return 1;
 	}
 
@@ -40,15 +53,117 @@ int fixup_exception(struct pt_regs *regs)
 int __init early_fixup_exception(unsigned long *ip)
 {
 	const struct exception_table_entry *fixup;
+	unsigned long new_ip;
 
 	fixup = search_exception_tables(*ip);
 	if (fixup) {
-		if (fixup->fixup < 16)
-			return 0; /* Not supported during early boot */
+		new_ip = ex_fixup_addr(fixup);
+
+		if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
+			/* uaccess handling not supported during early boot */
+			return 0;
+		}
 
-		*ip = fixup->fixup;
+		*ip = new_ip;
 		return 1;
 	}
 
 	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 */

^ permalink raw reply related	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2012-04-21  1:17 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-19 21:59 [PATCH v2 0/5] Speed booting by sorting exception tables at build time David Daney
2012-04-19 21:59 ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table David Daney
2012-04-20  0:20   ` [tip:x86/extable] scripts: Add sortextable to sort the kernel' s " tip-bot for David Daney
2012-04-20  1:44   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's " H. Peter Anvin
2012-04-20  3:17     ` David Daney
2012-04-20  3:31       ` Linus Torvalds
2012-04-20  3:42         ` H. Peter Anvin
2012-04-20  4:49           ` H. Peter Anvin
2012-04-20  4:54             ` H. Peter Anvin
2012-04-20 21:55         ` [tip:x86/extable] x86, extable: Use .pushsection ... . popsection for _ASM_EXTABLE() tip-bot for H. Peter Anvin
2012-04-20 21:56         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
2012-04-20 21:57         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_32.S tip-bot for H. Peter Anvin
2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/entry_64.S tip-bot for H. Peter Anvin
2012-04-20 21:58         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/kernel/test_rodata.c tip-bot for H. Peter Anvin
2012-04-20 21:59         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/checksum_32.S tip-bot for H. Peter Anvin
2012-04-20 22:00         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/copy_user_64.S tip-bot for H. Peter Anvin
2012-04-20 22:01         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/ copy_user_nocache_64.S tip-bot for H. Peter Anvin
2012-04-20 22:02         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/csum-copy_64.S tip-bot for H. Peter Anvin
2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/getuser.S tip-bot for H. Peter Anvin
2012-04-20 22:03         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/putuser.S tip-bot for H. Peter Anvin
2012-04-20 22:04         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/lib/usercopy_32.c tip-bot for H. Peter Anvin
2012-04-20 22:05         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/um/checksum_32.S tip-bot for H. Peter Anvin
2012-04-20 22:06         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/xen/xen-asm_32.S tip-bot for H. Peter Anvin
2012-04-20 22:07         ` [tip:x86/extable] x86, extable: Remove the now-unused __ASM_EX_SEC macros tip-bot for H. Peter Anvin
2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/kvm_host .h tip-bot for H. Peter Anvin
2012-04-20 22:08         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/include/asm/xsave.h tip-bot for H. Peter Anvin
2012-04-21  0:16         ` [tip:x86/extable] x86, extable: Remove open-coded exception table entries in arch/x86/ia32/ia32entry.S tip-bot for H. Peter Anvin
2012-04-21  0:17         ` [tip:x86/extable] x86, extable: Add _ASM_EXTABLE_EX() macro tip-bot for H. Peter Anvin
2012-04-21  1:16         ` [tip:x86/extable] x86, extable: Disable presorted exception table for now tip-bot for H. Peter Anvin
2012-04-21  1:17         ` [tip:x86/extable] x86, extable: Switch to relative exception table entries tip-bot for H. Peter Anvin
2012-04-20 14:59   ` [PATCH v1 1/5] scripts: Add sortextable to sort the kernel's exception table Sam Ravnborg
2012-04-20 16:49     ` David Daney
2012-04-19 21:59 ` [PATCH v2 2/5] extable: Skip sorting if sorted at build time David Daney
2012-04-20  0:21   ` [tip:x86/extable] " tip-bot for David Daney
2012-04-19 21:59 ` [PATCH v2 3/5] kbuild/extable: Hook up sortextable into the build system David Daney
2012-04-20  0:22   ` [tip:x86/extable] " tip-bot for David Daney
2012-04-20 15:02   ` [PATCH v2 3/5] " Sam Ravnborg
2012-04-19 21:59 ` [PATCH v2 4/5] MIPS: Select BUILDTIME_EXTABLE_SORT David Daney
2012-04-20  0:23   ` [tip:x86/extable] " tip-bot for David Daney
2012-04-19 21:59 ` [PATCH v2 5/5] x86: " David Daney
2012-04-20  0:23   ` [tip:x86/extable] " tip-bot for David Daney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.