+ kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: kallsyms: add support for relative offsets in kallsyms address table
has been added to the -mm tree.  Its filename is
     kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
Subject: kallsyms: add support for relative offsets in kallsyms address table

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: Michal Marek <mmarek@xxxxxxx>
Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Sudip Mukherjee <sudipm.mukherjee@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 init/Kconfig       |   10 +++++----
 kernel/kallsyms.c  |    8 +++++--
 scripts/kallsyms.c |   47 +++++++++++++++++--------------------------
 3 files changed, 31 insertions(+), 34 deletions(-)

diff -puN init/Kconfig~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5 init/Kconfig
--- a/init/Kconfig~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5
+++ a/init/Kconfig
@@ -1449,13 +1449,15 @@ config KALLSYMS_ABSOLUTE_PERCPU
 config KALLSYMS_BASE_RELATIVE
 	bool
 	depends on KALLSYMS
-	default !IA64
+	default !IA64 && !(TILE && 64BIT)
 	help
 	  Instead of emitting them as absolute values in the native word size,
 	  emit the symbol references in the kallsyms table as 32-bit entries,
-	  each containing either an absolute value in the range [0, S32_MAX] or
-	  a relative value in the range [base, base + S32_MAX], where base is
-	  the lowest relative symbol address encountered in the image.
+	  each containing a relative value in the range [base, base + U32_MAX]
+	  or, when KALLSYMS_ABSOLUTE_PERCPU is in effect, each containing either
+	  an absolute value in the range [0, S32_MAX] or a relative value in the
+	  range [base, base + S32_MAX], where base is the lowest relative symbol
+	  address encountered in the image.
 
 	  On 64-bit builds, this reduces the size of the address table by 50%,
 	  but more importantly, it results in entries whose values are build
diff -puN kernel/kallsyms.c~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5 kernel/kallsyms.c
--- a/kernel/kallsyms.c~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5
+++ a/kernel/kallsyms.c
@@ -185,11 +185,15 @@ static unsigned long kallsyms_sym_addres
 	if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
 		return kallsyms_addresses[idx];
 
-	/* positive offsets are absolute values */
+	/* values are unsigned offsets if --absolute-percpu is not in effect */
+	if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
+		return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
+
+	/* ...otherwise, positive offsets are absolute values */
 	if (kallsyms_offsets[idx] >= 0)
 		return kallsyms_offsets[idx];
 
-	/* negative offsets are relative to kallsyms_relative_base - 1 */
+	/* ...and negative offsets are relative to kallsyms_relative_base - 1 */
 	return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
 }
 
diff -puN scripts/kallsyms.c~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5 scripts/kallsyms.c
--- a/scripts/kallsyms.c~kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5
+++ a/scripts/kallsyms.c
@@ -375,23 +375,24 @@ static void write_src(void)
 	for (i = 0; i < table_cnt; i++) {
 		if (base_relative) {
 			long long offset;
+			int overflow;
 
-			if (symbol_absolute(&table[i])) {
+			if (!absolute_percpu) {
+				offset = table[i].addr - relative_base;
+				overflow = (offset < 0 || offset > UINT_MAX);
+			} else if (symbol_absolute(&table[i])) {
 				offset = table[i].addr;
-				if (offset < 0 || offset > INT_MAX) {
-					fprintf(stderr, "kallsyms failure: "
-						"absolute symbol value %#llx out of range in relative mode\n",
-						table[i].addr);
-					exit(EXIT_FAILURE);
-				}
+				overflow = (offset < 0 || offset > INT_MAX);
 			} else {
 				offset = relative_base - table[i].addr - 1;
-				if (offset < INT_MIN || offset >= 0) {
-					fprintf(stderr, "kallsyms failure: "
-						"relative symbol value %#llx out of range in relative mode\n",
-						table[i].addr);
-					exit(EXIT_FAILURE);
-				}
+				overflow = (offset < INT_MIN || offset >= 0);
+			}
+			if (overflow) {
+				fprintf(stderr, "kallsyms failure: "
+					"%s symbol value %#llx out of range in relative mode\n",
+					symbol_absolute(&table[i]) ? "absolute" : "relative",
+					table[i].addr);
+				exit(EXIT_FAILURE);
 			}
 			printf("\t.long\t%#x\n", (int)offset);
 		} else if (!symbol_absolute(&table[i])) {
@@ -742,21 +743,11 @@ static void record_relative_base(void)
 {
 	unsigned int i;
 
-	if (kernel_start_addr > 0) {
-		/*
-		 * If the kernel start address was specified, use that as
-		 * the relative base rather than going through the table,
-		 * since it should be a reasonable default, and values below
-		 * it will be ignored anyway.
-		 */
-		relative_base = kernel_start_addr;
-	} else {
-		relative_base = -1ULL;
-		for (i = 0; i < table_cnt; i++)
-			if (!symbol_absolute(&table[i]) &&
-			    table[i].addr < relative_base)
-				relative_base = table[i].addr;
-	}
+	relative_base = -1ULL;
+	for (i = 0; i < table_cnt; i++)
+		if (!symbol_absolute(&table[i]) &&
+		    table[i].addr < relative_base)
+			relative_base = table[i].addr;
 }
 
 int main(int argc, char **argv)
_

Patches currently in -mm which might be from ard.biesheuvel@xxxxxxxxxx are

extable-add-support-for-relative-extables-to-search-and-sort-routines.patch
alpha-extable-use-generic-search-and-sort-routines.patch
s390-extable-use-generic-search-and-sort-routines.patch
x86-extable-use-generic-search-and-sort-routines.patch
ia64-extable-use-generic-search-and-sort-routines.patch
arm64-switch-to-relative-exception-tables.patch
x86-kallsyms-disable-absolute-percpu-symbols-on-smp.patch
x86-kallsyms-disable-absolute-percpu-symbols-on-smp-v5.patch
kallsyms-dont-overload-absolute-symbol-type-for-percpu-symbols.patch
kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table.patch
kallsyms-add-support-for-relative-offsets-in-kallsyms-address-table-v5.patch
scripts-link-vmlinuxsh-force-error-on-kallsyms-failure.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux