Delete unused patches
Signed-off-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
parent
abfed0b6d6
commit
55ff20016d
File diff suppressed because it is too large
Load Diff
@ -1,106 +0,0 @@
|
||||
From patchwork Thu Oct 20 10:43:31 2016
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Subject: [v2] arm64: Add support for additional relocations in the kexec
|
||||
purgatory code
|
||||
From: Catalin Marinas <catalin.marinas@arm.com>
|
||||
X-Patchwork-Id: 9386541
|
||||
Message-Id: <1476960211-25594-1-git-send-email-catalin.marinas@arm.com>
|
||||
To: Simon Horman <horms@verge.net.au>
|
||||
Cc: Geoff Levand <geoff@infradead.org>, kexec@lists.infradead.org,
|
||||
linux-arm-kernel@lists.infradead.org
|
||||
Date: Thu, 20 Oct 2016 11:43:31 +0100
|
||||
|
||||
When compiling the kexec-tools with gcc6, the following additional
|
||||
reolcations are generated in the purgatory.ro file:
|
||||
|
||||
R_AARCH64_ADR_PREL_PG_HI21
|
||||
R_AARCH64_ADD_ABS_LO12_NC
|
||||
R_AARCH64_LDST64_ABS_LO12_NC
|
||||
|
||||
This patch modifies the arm64 machine_apply_elf_rel() function to handle
|
||||
these relocations.
|
||||
|
||||
Cc: Geoff Levand <geoff@infradead.org>
|
||||
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
|
||||
Reviewed-by: Geoff Levand <geoff@infradead.org>
|
||||
---
|
||||
|
||||
Changes for v2:
|
||||
- Fixed the type string to drop the "R_AARCH64_" prefix
|
||||
|
||||
kexec/arch/arm64/kexec-arm64.c | 35 +++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 35 insertions(+)
|
||||
|
||||
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
|
||||
index 2e8839a..e067a23 100644
|
||||
--- a/kexec/arch/arm64/kexec-arm64.c
|
||||
+++ b/kexec/arch/arm64/kexec-arm64.c
|
||||
@@ -550,6 +550,14 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
# define R_AARCH64_ADR_PREL_LO21 274
|
||||
#endif
|
||||
|
||||
+#if !defined(R_AARCH64_ADR_PREL_PG_HI21)
|
||||
+# define R_AARCH64_ADR_PREL_PG_HI21 275
|
||||
+#endif
|
||||
+
|
||||
+#if !defined(R_AARCH64_ADD_ABS_LO12_NC)
|
||||
+# define R_AARCH64_ADD_ABS_LO12_NC 277
|
||||
+#endif
|
||||
+
|
||||
#if !defined(R_AARCH64_JUMP26)
|
||||
# define R_AARCH64_JUMP26 282
|
||||
#endif
|
||||
@@ -558,10 +566,15 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
# define R_AARCH64_CALL26 283
|
||||
#endif
|
||||
|
||||
+#if !defined(R_AARCH64_LDST64_ABS_LO12_NC)
|
||||
+# define R_AARCH64_LDST64_ABS_LO12_NC 286
|
||||
+#endif
|
||||
+
|
||||
uint64_t *loc64;
|
||||
uint32_t *loc32;
|
||||
uint64_t *location = (uint64_t *)ptr;
|
||||
uint64_t data = *location;
|
||||
+ uint64_t imm;
|
||||
const char *type = NULL;
|
||||
|
||||
switch(r_type) {
|
||||
@@ -585,6 +598,19 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
*loc32 = cpu_to_le32(le32_to_cpu(*loc32)
|
||||
+ (((value - address) << 3) & 0xffffe0));
|
||||
break;
|
||||
+ case R_AARCH64_ADR_PREL_PG_HI21:
|
||||
+ type = "ADR_PREL_PG_HI21";
|
||||
+ imm = ((value & ~0xfff) - (address & ~0xfff)) >> 12;
|
||||
+ loc32 = ptr;
|
||||
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
|
||||
+ + ((imm & 3) << 29) + ((imm & 0x1ffffc) << (5 - 2)));
|
||||
+ break;
|
||||
+ case R_AARCH64_ADD_ABS_LO12_NC:
|
||||
+ type = "ADD_ABS_LO12_NC";
|
||||
+ loc32 = ptr;
|
||||
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
|
||||
+ + ((value & 0xfff) << 10));
|
||||
+ break;
|
||||
case R_AARCH64_JUMP26:
|
||||
type = "JUMP26";
|
||||
loc32 = ptr;
|
||||
@@ -597,6 +623,15 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
*loc32 = cpu_to_le32(le32_to_cpu(*loc32)
|
||||
+ (((value - address) >> 2) & 0x3ffffff));
|
||||
break;
|
||||
+ case R_AARCH64_LDST64_ABS_LO12_NC:
|
||||
+ if (value & 7)
|
||||
+ die("%s: ERROR Unaligned value: %lx\n", __func__,
|
||||
+ value);
|
||||
+ type = "LDST64_ABS_LO12_NC";
|
||||
+ loc32 = ptr;
|
||||
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
|
||||
+ + ((value & 0xff8) << (10 - 3)));
|
||||
+ break;
|
||||
default:
|
||||
die("%s: ERROR Unknown type: %lu\n", __func__, r_type);
|
||||
break;
|
@ -1,96 +0,0 @@
|
||||
From abdfe97736f89d9bc73662b9134604b0229a599e Mon Sep 17 00:00:00 2001
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Wed, 21 Sep 2016 18:14:25 +0000
|
||||
Subject: [PATCH 3/3] arm64: Add support for binary image files
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
[Reworked and cleaned up]
|
||||
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
||||
Tested-By: Pratyush Anand <panand@redhat.com>
|
||||
Tested-By: Matthias Brugger <mbrugger@suse.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
kexec/arch/arm64/kexec-image-arm64.c | 49 ++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 44 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
|
||||
index 42d2ea7..960ed96 100644
|
||||
--- a/kexec/arch/arm64/kexec-image-arm64.c
|
||||
+++ b/kexec/arch/arm64/kexec-image-arm64.c
|
||||
@@ -3,7 +3,9 @@
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
+
|
||||
#include "kexec-arm64.h"
|
||||
+#include <limits.h>
|
||||
|
||||
int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
|
||||
{
|
||||
@@ -21,14 +23,53 @@ int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- fprintf(stderr, "kexec: ARM64 binary image files are currently NOT SUPPORTED.\n");
|
||||
- return -1;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
int image_arm64_load(int argc, char **argv, const char *kernel_buf,
|
||||
off_t kernel_size, struct kexec_info *info)
|
||||
{
|
||||
- return -1;
|
||||
+ const struct arm64_image_header *header;
|
||||
+ unsigned long kernel_segment;
|
||||
+ int result;
|
||||
+
|
||||
+ header = (const struct arm64_image_header *)(kernel_buf);
|
||||
+
|
||||
+ if (arm64_process_image_header(header))
|
||||
+ return -1;
|
||||
+
|
||||
+ kernel_segment = arm64_locate_kernel_segment(info);
|
||||
+
|
||||
+ if (kernel_segment == ULONG_MAX) {
|
||||
+ dbgprintf("%s: Kernel segment is not allocated\n", __func__);
|
||||
+ result = -EFAILED;
|
||||
+ goto exit;
|
||||
+ }
|
||||
+
|
||||
+ dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment);
|
||||
+ dbgprintf("%s: text_offset: %016lx\n", __func__,
|
||||
+ arm64_mem.text_offset);
|
||||
+ dbgprintf("%s: image_size: %016lx\n", __func__,
|
||||
+ arm64_mem.image_size);
|
||||
+ dbgprintf("%s: phys_offset: %016lx\n", __func__,
|
||||
+ arm64_mem.phys_offset);
|
||||
+ dbgprintf("%s: vp_offset: %016lx\n", __func__,
|
||||
+ arm64_mem.vp_offset);
|
||||
+ dbgprintf("%s: PE format: %s\n", __func__,
|
||||
+ (arm64_header_check_pe_sig(header) ? "yes" : "no"));
|
||||
+
|
||||
+ /* load the kernel */
|
||||
+ add_segment_phys_virt(info, kernel_buf, kernel_size,
|
||||
+ kernel_segment + arm64_mem.text_offset,
|
||||
+ arm64_mem.image_size, 0);
|
||||
+
|
||||
+ result = arm64_load_other_segments(info, kernel_segment
|
||||
+ + arm64_mem.text_offset);
|
||||
+
|
||||
+exit:
|
||||
+ if (result)
|
||||
+ fprintf(stderr, "kexec: load failed.\n");
|
||||
+ return result;
|
||||
}
|
||||
|
||||
void image_arm64_usage(void)
|
||||
@@ -36,6 +77,4 @@ void image_arm64_usage(void)
|
||||
printf(
|
||||
" An ARM64 binary image, compressed or not, big or little endian.\n"
|
||||
" Typically an Image, Image.gz or Image.lzma file.\n\n");
|
||||
- printf(
|
||||
-" ARM64 binary image files are currently NOT SUPPORTED.\n\n");
|
||||
}
|
||||
--
|
||||
2.9.3
|
||||
|
@ -1,42 +0,0 @@
|
||||
From 3a3c61cb7f129936e5752d1ccc304c183575a8b0 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <3a3c61cb7f129936e5752d1ccc304c183575a8b0.1477402102.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Tue, 25 Oct 2016 18:55:49 +0530
|
||||
Subject: [PATCH] arm64: Add support of R_AARCH64_PREL32 relocation in
|
||||
purgatory
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
kexec/arch/arm64/kexec-arm64.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
|
||||
index 218f0bc832cd..b12de4772412 100644
|
||||
--- a/kexec/arch/arm64/kexec-arm64.c
|
||||
+++ b/kexec/arch/arm64/kexec-arm64.c
|
||||
@@ -720,6 +720,10 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
# define R_AARCH64_ABS64 257
|
||||
#endif
|
||||
|
||||
+#if !defined(R_AARCH64_PREL32)
|
||||
+# define R_AARCH64_PREL32 261
|
||||
+#endif
|
||||
+
|
||||
#if !defined(R_AARCH64_LD_PREL_LO19)
|
||||
# define R_AARCH64_LD_PREL_LO19 273
|
||||
#endif
|
||||
@@ -761,6 +765,11 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
|
||||
loc64 = ptr;
|
||||
*loc64 = cpu_to_elf64(ehdr, elf64_to_cpu(ehdr, *loc64) + value);
|
||||
break;
|
||||
+ case R_AARCH64_PREL32:
|
||||
+ type = "PREL32";
|
||||
+ loc32 = ptr;
|
||||
+ *loc32 = cpu_to_elf32(ehdr, elf32_to_cpu(ehdr, *loc32) + value - address);
|
||||
+ break;
|
||||
case R_AARCH64_LD_PREL_LO19:
|
||||
type = "LD_PREL_LO19";
|
||||
loc32 = ptr;
|
||||
--
|
||||
2.7.4
|
||||
|
@ -1,28 +0,0 @@
|
||||
Upstream kexec-tools 2.0.13 does not pack arm phys_to_virt.h and iomem.h,
|
||||
include them here for a temporary fix
|
||||
|
||||
diff -uprN kexec-tools/kexec/arch/arm/iomem.h kexec-tools.1/kexec/arch/arm/iomem.h
|
||||
--- kexec-tools/kexec/arch/arm/iomem.h 1970-01-01 08:00:00.000000000 +0800
|
||||
+++ kexec-tools.1/kexec/arch/arm/iomem.h 2016-08-09 15:38:26.938594379 +0800
|
||||
@@ -0,0 +1,9 @@
|
||||
+#ifndef IOMEM_H
|
||||
+#define IOMEM_H
|
||||
+
|
||||
+#define SYSTEM_RAM "System RAM\n"
|
||||
+#define SYSTEM_RAM_BOOT "System RAM (boot alias)\n"
|
||||
+#define CRASH_KERNEL "Crash kernel\n"
|
||||
+#define CRASH_KERNEL_BOOT "Crash kernel (boot alias)\n"
|
||||
+
|
||||
+#endif
|
||||
diff -uprN kexec-tools/kexec/arch/arm/phys_to_virt.h kexec-tools.1/kexec/arch/arm/phys_to_virt.h
|
||||
--- kexec-tools/kexec/arch/arm/phys_to_virt.h 1970-01-01 08:00:00.000000000 +0800
|
||||
+++ kexec-tools.1/kexec/arch/arm/phys_to_virt.h 2016-08-09 14:50:30.104143361 +0800
|
||||
@@ -0,0 +1,8 @@
|
||||
+#ifndef PHYS_TO_VIRT_H
|
||||
+#define PHYS_TO_VIRT_H
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+
|
||||
+extern uint64_t phys_offset;
|
||||
+
|
||||
+#endif
|
@ -1,208 +0,0 @@
|
||||
From 217bcc00c9309416a6c6cd0584196559d28a9259 Mon Sep 17 00:00:00 2001
|
||||
From: Geoff Levand <geoff@infradead.org>
|
||||
Date: Wed, 21 Sep 2016 18:14:25 +0000
|
||||
Subject: [PATCH 1/3] kexec: Add common device tree routines
|
||||
|
||||
Common device tree routines that can be shared between all arches
|
||||
that have device tree support.
|
||||
|
||||
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
||||
Tested-By: Pratyush Anand <panand@redhat.com>
|
||||
Tested-By: Matthias Brugger <mbrugger@suse.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
kexec/Makefile | 4 ++
|
||||
kexec/dt-ops.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
kexec/dt-ops.h | 13 ++++++
|
||||
3 files changed, 162 insertions(+)
|
||||
create mode 100644 kexec/dt-ops.c
|
||||
create mode 100644 kexec/dt-ops.h
|
||||
|
||||
diff --git a/kexec/Makefile b/kexec/Makefile
|
||||
index e2aee84..cc3f08b 100644
|
||||
--- a/kexec/Makefile
|
||||
+++ b/kexec/Makefile
|
||||
@@ -73,6 +73,10 @@ dist += kexec/mem_regions.c kexec/mem_regions.h
|
||||
$(ARCH)_MEM_REGIONS =
|
||||
KEXEC_SRCS += $($(ARCH)_MEM_REGIONS)
|
||||
|
||||
+dist += kexec/dt-ops.c kexec/dt-ops.h
|
||||
+$(ARCH)_DT_OPS =
|
||||
+KEXEC_SRCS += $($(ARCH)_DT_OPS)
|
||||
+
|
||||
include $(srcdir)/kexec/arch/alpha/Makefile
|
||||
include $(srcdir)/kexec/arch/arm/Makefile
|
||||
include $(srcdir)/kexec/arch/i386/Makefile
|
||||
diff --git a/kexec/dt-ops.c b/kexec/dt-ops.c
|
||||
new file mode 100644
|
||||
index 0000000..915dbf5
|
||||
--- /dev/null
|
||||
+++ b/kexec/dt-ops.c
|
||||
@@ -0,0 +1,145 @@
|
||||
+#include <assert.h>
|
||||
+#include <errno.h>
|
||||
+#include <inttypes.h>
|
||||
+#include <libfdt.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
+#include "kexec.h"
|
||||
+#include "dt-ops.h"
|
||||
+
|
||||
+static const char n_chosen[] = "/chosen";
|
||||
+
|
||||
+static const char p_bootargs[] = "bootargs";
|
||||
+static const char p_initrd_start[] = "linux,initrd-start";
|
||||
+static const char p_initrd_end[] = "linux,initrd-end";
|
||||
+
|
||||
+int dtb_set_initrd(char **dtb, off_t *dtb_size, off_t start, off_t end)
|
||||
+{
|
||||
+ int result;
|
||||
+ uint64_t value;
|
||||
+
|
||||
+ dbgprintf("%s: start %jd, end %jd, size %jd (%jd KiB)\n",
|
||||
+ __func__, (intmax_t)start, (intmax_t)end,
|
||||
+ (intmax_t)(end - start),
|
||||
+ (intmax_t)(end - start) / 1024);
|
||||
+
|
||||
+ value = cpu_to_fdt64(start);
|
||||
+
|
||||
+ result = dtb_set_property(dtb, dtb_size, n_chosen, p_initrd_start,
|
||||
+ &value, sizeof(value));
|
||||
+
|
||||
+ if (result)
|
||||
+ return result;
|
||||
+
|
||||
+ value = cpu_to_fdt64(end);
|
||||
+
|
||||
+ result = dtb_set_property(dtb, dtb_size, n_chosen, p_initrd_end,
|
||||
+ &value, sizeof(value));
|
||||
+
|
||||
+ if (result) {
|
||||
+ dtb_delete_property(*dtb, n_chosen, p_initrd_start);
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int dtb_set_bootargs(char **dtb, off_t *dtb_size, const char *command_line)
|
||||
+{
|
||||
+ return dtb_set_property(dtb, dtb_size, n_chosen, p_bootargs,
|
||||
+ command_line, strlen(command_line) + 1);
|
||||
+}
|
||||
+
|
||||
+int dtb_set_property(char **dtb, off_t *dtb_size, const char *node,
|
||||
+ const char *prop, const void *value, int value_len)
|
||||
+{
|
||||
+ int result;
|
||||
+ int nodeoffset;
|
||||
+ void *new_dtb;
|
||||
+ int new_size;
|
||||
+
|
||||
+ value_len = FDT_TAGALIGN(value_len);
|
||||
+
|
||||
+ new_size = FDT_TAGALIGN(*dtb_size + fdt_node_len(node)
|
||||
+ + fdt_prop_len(prop, value_len));
|
||||
+
|
||||
+ new_dtb = malloc(new_size);
|
||||
+
|
||||
+ if (!new_dtb) {
|
||||
+ dbgprintf("%s: malloc failed\n", __func__);
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ result = fdt_open_into(*dtb, new_dtb, new_size);
|
||||
+
|
||||
+ if (result) {
|
||||
+ dbgprintf("%s: fdt_open_into failed: %s\n", __func__,
|
||||
+ fdt_strerror(result));
|
||||
+ goto on_error;
|
||||
+ }
|
||||
+
|
||||
+ nodeoffset = fdt_path_offset(new_dtb, node);
|
||||
+
|
||||
+ if (nodeoffset == -FDT_ERR_NOTFOUND) {
|
||||
+ result = fdt_add_subnode(new_dtb, nodeoffset, node);
|
||||
+
|
||||
+ if (result) {
|
||||
+ dbgprintf("%s: fdt_add_subnode failed: %s\n", __func__,
|
||||
+ fdt_strerror(result));
|
||||
+ goto on_error;
|
||||
+ }
|
||||
+ } else if (nodeoffset < 0) {
|
||||
+ dbgprintf("%s: fdt_path_offset failed: %s\n", __func__,
|
||||
+ fdt_strerror(nodeoffset));
|
||||
+ goto on_error;
|
||||
+ }
|
||||
+
|
||||
+ result = fdt_setprop(new_dtb, nodeoffset, prop, value, value_len);
|
||||
+
|
||||
+ if (result) {
|
||||
+ dbgprintf("%s: fdt_setprop failed: %s\n", __func__,
|
||||
+ fdt_strerror(result));
|
||||
+ goto on_error;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Can't call free on dtb since dtb may have been mmaped by
|
||||
+ * slurp_file().
|
||||
+ */
|
||||
+
|
||||
+ result = fdt_pack(new_dtb);
|
||||
+
|
||||
+ if (result)
|
||||
+ dbgprintf("%s: Unable to pack device tree: %s\n", __func__,
|
||||
+ fdt_strerror(result));
|
||||
+
|
||||
+ *dtb = new_dtb;
|
||||
+ *dtb_size = fdt_totalsize(*dtb);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+on_error:
|
||||
+ free(new_dtb);
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+int dtb_delete_property(char *dtb, const char *node, const char *prop)
|
||||
+{
|
||||
+ int result;
|
||||
+ int nodeoffset = fdt_path_offset(dtb, node);
|
||||
+
|
||||
+ if (nodeoffset < 0) {
|
||||
+ dbgprintf("%s: fdt_path_offset failed: %s\n", __func__,
|
||||
+ fdt_strerror(nodeoffset));
|
||||
+ return nodeoffset;
|
||||
+ }
|
||||
+
|
||||
+ result = fdt_delprop(dtb, nodeoffset, prop);
|
||||
+
|
||||
+ if (result)
|
||||
+ dbgprintf("%s: fdt_delprop failed: %s\n", __func__,
|
||||
+ fdt_strerror(nodeoffset));
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
diff --git a/kexec/dt-ops.h b/kexec/dt-ops.h
|
||||
new file mode 100644
|
||||
index 0000000..e70d15d
|
||||
--- /dev/null
|
||||
+++ b/kexec/dt-ops.h
|
||||
@@ -0,0 +1,13 @@
|
||||
+#if !defined(KEXEC_DT_OPS_H)
|
||||
+#define KEXEC_DT_OPS_H
|
||||
+
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+int dtb_set_initrd(char **dtb, off_t *dtb_size, off_t start, off_t end);
|
||||
+int dtb_set_bootargs(char **dtb, off_t *dtb_size, const char *command_line);
|
||||
+int dtb_set_property(char **dtb, off_t *dtb_size, const char *node,
|
||||
+ const char *prop, const void *value, int value_len);
|
||||
+
|
||||
+int dtb_delete_property(char *dtb, const char *node, const char *prop);
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.9.3
|
||||
|
@ -1,97 +0,0 @@
|
||||
From 9f62cbddddfc93d78d9aafbddf3e1208cb242f7b Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Garnier <thgarnie@google.com>
|
||||
Date: Tue, 13 Sep 2016 15:10:05 +0800
|
||||
Subject: [PATCH] kexec/arch/i386: Add support for KASLR memory randomization
|
||||
|
||||
Multiple changes were made on KASLR (right now in linux-next). One of
|
||||
them is randomizing the virtual address of the physical mapping, vmalloc
|
||||
and vmemmap memory sections. It breaks kdump ability to read physical
|
||||
memory.
|
||||
|
||||
This change identifies if KASLR memories randomization is used by
|
||||
checking if the page_offset_base variable exists. It search for the
|
||||
correct PAGE_OFFSET value by looking at the loaded memory section and
|
||||
find the lowest aligned on PUD (the randomization level).
|
||||
|
||||
Related commits on linux-next:
|
||||
- 0483e1fa6e09d4948272680f691dccb1edb9677f: Base for randomization
|
||||
- 021182e52fe01c1f7b126f97fd6ba048dc4234fd: Enable for PAGE_OFFSET
|
||||
|
||||
Signed-off-by: Thomas Garnier <thgarnie@google.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
kexec/arch/i386/crashdump-x86.c | 29 ++++++++++++++++++++++-------
|
||||
1 file changed, 22 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
|
||||
index bbc0f35..ab833d4 100644
|
||||
--- a/kexec/arch/i386/crashdump-x86.c
|
||||
+++ b/kexec/arch/i386/crashdump-x86.c
|
||||
@@ -102,11 +102,10 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info),
|
||||
return -1;
|
||||
}
|
||||
|
||||
-/* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */
|
||||
-static unsigned long long get_kernel_stext_sym(void)
|
||||
+/* Retrieve kernel symbol virtual address from /proc/kallsyms */
|
||||
+static unsigned long long get_kernel_sym(const char *symbol)
|
||||
{
|
||||
const char *kallsyms = "/proc/kallsyms";
|
||||
- const char *stext = "_stext";
|
||||
char sym[128];
|
||||
char line[128];
|
||||
FILE *fp;
|
||||
@@ -122,13 +121,13 @@ static unsigned long long get_kernel_stext_sym(void)
|
||||
while(fgets(line, sizeof(line), fp) != NULL) {
|
||||
if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3)
|
||||
continue;
|
||||
- if (strcmp(sym, stext) == 0) {
|
||||
- dbgprintf("kernel symbol %s vaddr = %16llx\n", stext, vaddr);
|
||||
+ if (strcmp(sym, symbol) == 0) {
|
||||
+ dbgprintf("kernel symbol %s vaddr = %16llx\n", symbol, vaddr);
|
||||
return vaddr;
|
||||
}
|
||||
}
|
||||
|
||||
- fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
|
||||
+ fprintf(stderr, "Cannot get kernel %s symbol address\n", symbol);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -151,6 +150,8 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
|
||||
off_t size;
|
||||
uint32_t elf_flags = 0;
|
||||
uint64_t stext_sym;
|
||||
+ const unsigned long long pud_mask = ~((1 << 30) - 1);
|
||||
+ unsigned long long vaddr, lowest_vaddr = 0;
|
||||
|
||||
if (elf_info->machine != EM_X86_64)
|
||||
return 0;
|
||||
@@ -180,9 +181,23 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
|
||||
|
||||
end_phdr = &ehdr.e_phdr[ehdr.e_phnum];
|
||||
|
||||
+ /* Search for the real PAGE_OFFSET when KASLR memory randomization
|
||||
+ * is enabled */
|
||||
+ if (get_kernel_sym("page_offset_base") != 0) {
|
||||
+ for(phdr = ehdr.e_phdr; phdr != end_phdr; phdr++) {
|
||||
+ if (phdr->p_type == PT_LOAD) {
|
||||
+ vaddr = phdr->p_vaddr & pud_mask;
|
||||
+ if (lowest_vaddr == 0 || lowest_vaddr > vaddr)
|
||||
+ lowest_vaddr = vaddr;
|
||||
+ }
|
||||
+ }
|
||||
+ if (lowest_vaddr != 0)
|
||||
+ elf_info->page_offset = lowest_vaddr;
|
||||
+ }
|
||||
+
|
||||
/* Traverse through the Elf headers and find the region where
|
||||
* _stext symbol is located in. That's where kernel is mapped */
|
||||
- stext_sym = get_kernel_stext_sym();
|
||||
+ stext_sym = get_kernel_sym("_stext");
|
||||
for(phdr = ehdr.e_phdr; stext_sym && phdr != end_phdr; phdr++) {
|
||||
if (phdr->p_type == PT_LOAD) {
|
||||
unsigned long long saddr = phdr->p_vaddr;
|
||||
--
|
||||
2.10.1
|
||||
|
Loading…
Reference in New Issue
Block a user