mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liu Hua <sdu.liu@huawei.com>
To: <linux@arm.linux.org.uk>, <horms@verge.net.au>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<kexec@lists.infradead.org>, "Liu Hua" <sdu.liu@huawei.com>,
	Dan Aloni <alonid@stratoscale.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH 1/3] ARM : kdump : Add LPAE support
Date: Thu, 27 Mar 2014 16:00:38 +0800	[thread overview]
Message-ID: <1395907240-13308-2-git-send-email-sdu.liu@huawei.com> (raw)
In-Reply-To: <1395907240-13308-1-git-send-email-sdu.liu@huawei.com>

With CONFIG_LPAE=y, memory in 32-bit ARM systems can exceed
4G. So if we use kdump in such systems. The capture kernel
should parse 64-bit elf header(parse_crash_elf64_headers).

And this process can not pass because ARM linux does not
supply related check function.

This patch adds check functions related of elf64 header.

Signed-off-by: Liu Hua <sdu.liu@huawei.com>
To: Russell King <linux@arm.linux.org.uk>
Cc: Dan Aloni <alonid@stratoscale.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: <kexec@lists.infradead.org>
---
 arch/arm/include/asm/elf.h |  5 ++++-
 arch/arm/kernel/elf.c      | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index f4b46d3..6e02a6d 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -90,14 +90,17 @@ typedef struct user_fp elf_fpregset_t;
 extern char elf_platform[];
 
 struct elf32_hdr;
+struct elf64_hdr;
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
 extern int elf_check_arch(const struct elf32_hdr *);
+extern int elf_check_arch_64(const struct elf64_hdr *);
 #define elf_check_arch elf_check_arch
 
-#define vmcore_elf64_check_arch(x) (0)
+#define vmcore_elf64_check_arch(x) (elf_check_arch_64(x) || \
+				vmcore_elf_check_arch_cross(x))
 
 extern int arm_elf_read_implies_exec(const struct elf32_hdr *, int);
 #define elf_read_implies_exec(ex,stk) arm_elf_read_implies_exec(&(ex), stk)
diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c
index d0d1e83..452086a 100644
--- a/arch/arm/kernel/elf.c
+++ b/arch/arm/kernel/elf.c
@@ -38,6 +38,39 @@ int elf_check_arch(const struct elf32_hdr *x)
 }
 EXPORT_SYMBOL(elf_check_arch);
 
+int elf_check_arch_64(const struct elf64_hdr *x)
+{
+	unsigned int eflags;
+
+	/* Make sure it's an ARM executable */
+	if (x->e_machine != EM_ARM)
+		return 0;
+
+	/* Make sure the entry address is reasonable */
+	if (x->e_entry & 1) {
+		if (!(elf_hwcap & HWCAP_THUMB))
+			return 0;
+	} else if (x->e_entry & 3)
+		return 0;
+
+	eflags = x->e_flags;
+	if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) {
+		unsigned int flt_fmt;
+
+		/* APCS26 is only allowed if the CPU supports it */
+		if ((eflags & EF_ARM_APCS_26) && !(elf_hwcap & HWCAP_26BIT))
+			return 0;
+
+		flt_fmt = eflags & (EF_ARM_VFP_FLOAT | EF_ARM_SOFT_FLOAT);
+
+		/* VFP requires the supporting code */
+		if (flt_fmt == EF_ARM_VFP_FLOAT && !(elf_hwcap & HWCAP_VFP))
+			return 0;
+	}
+	return 1;
+}
+EXPORT_SYMBOL(elf_check_arch_64);
+
 void elf_set_personality(const struct elf32_hdr *x)
 {
 	unsigned int eflags = x->e_flags;
-- 
1.9.0


       reply	other threads:[~2014-03-27  8:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1395907240-13308-1-git-send-email-sdu.liu@huawei.com>
2014-03-27  8:00 ` Liu Hua [this message]
2014-03-27  8:00 ` [PATCH 2/3] ARM : kdump : add arch_crash_save_vmcoreinfo Liu Hua
2014-04-14 11:37   ` Will Deacon
2014-04-14 12:41     ` Liu hua
2014-04-14 17:31       ` Will Deacon
2014-03-27  8:00 ` [PATCH 3/3] kexec : ARM : add LPAE support Liu Hua

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395907240-13308-2-git-send-email-sdu.liu@huawei.com \
    --to=sdu.liu@huawei.com \
    --cc=alonid@stratoscale.com \
    --cc=catalin.marinas@arm.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®