forked from pool/kdump
200 lines
6.4 KiB
Diff
200 lines
6.4 KiB
Diff
|
From: Matthias Brugger <mbrugger@suse.com>
|
||
|
Date: Mon May 8 13:58:38 2017 +0200
|
||
|
Subject: kdumptool: add aarch64
|
||
|
References: bsc#1033464
|
||
|
Upstream: v0.8.17
|
||
|
Git-commit: 914c79f493c858e7ab2c07248c17f23f9195daa3
|
||
|
Git-commit: f43e30a71f294020817f0c4f35ea96931ea9ab93
|
||
|
Git-commit: e6afa41112b5ab4a961a595841f3d6b6751f99b4
|
||
|
Git-commit: a885ddf80fb2c6c2490f2550338042581bca6150
|
||
|
|
||
|
Add support for Aarch64.
|
||
|
|
||
|
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
|
||
|
Acked-by: Petr Tesarik <ptesarik@suse.com>
|
||
|
|
||
|
---
|
||
|
kdumptool/identifykernel.cc | 3 ++
|
||
|
kdumptool/kerneltool.cc | 47 +++++++++++++++++++++++++++++++++++++++++++-
|
||
|
kdumptool/kerneltool.h | 9 ++++++++
|
||
|
kdumptool/savedump.cc | 7 ++++++
|
||
|
tests/identify_kernel.sh | 5 +++-
|
||
|
5 files changed, 69 insertions(+), 2 deletions(-)
|
||
|
|
||
|
--- a/kdumptool/kerneltool.cc
|
||
|
+++ b/kdumptool/kerneltool.cc
|
||
|
@@ -130,6 +130,8 @@ list<string> KernelTool::imageNames(cons
|
||
|
ret.push_back("vmlinuz");
|
||
|
} else if (arch == "s390x") {
|
||
|
ret.push_back("image");
|
||
|
+ } else if (arch == "aarch64") {
|
||
|
+ ret.push_back("Image");
|
||
|
} else {
|
||
|
ret.push_back("vmlinux");
|
||
|
}
|
||
|
@@ -181,6 +183,11 @@ KernelTool::KernelType KernelTool::getKe
|
||
|
return KT_S390;
|
||
|
else
|
||
|
return KT_NONE;
|
||
|
+ } else if (Util::getArch() == "aarch64") {
|
||
|
+ if (isAarch64Kernel())
|
||
|
+ return KT_AARCH64;
|
||
|
+ else
|
||
|
+ return KT_NONE;
|
||
|
} else
|
||
|
return KT_NONE;
|
||
|
}
|
||
|
@@ -201,6 +208,9 @@ bool KernelTool::isRelocatable() const
|
||
|
case KernelTool::KT_S390:
|
||
|
return true;
|
||
|
|
||
|
+ case KernelTool::KT_AARCH64:
|
||
|
+ return true;
|
||
|
+
|
||
|
default:
|
||
|
throw KError("Invalid kernel type.");
|
||
|
break;
|
||
|
@@ -257,6 +267,39 @@ bool KernelTool::isS390Kernel() const
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------------------------------------------
|
||
|
+bool KernelTool::isAarch64Kernel() const
|
||
|
+ throw (KError)
|
||
|
+{
|
||
|
+ struct {
|
||
|
+ uint32_t code0; /* Executable code */
|
||
|
+ uint32_t code1; /* Executable code */
|
||
|
+ uint64_t text_offset; /* Image load offset, little endian */
|
||
|
+ uint64_t image_size; /* Effective Image size, little endian */
|
||
|
+ uint64_t flags; /* kernel flags, little endian */
|
||
|
+ uint64_t res2; /* reserved */
|
||
|
+ uint64_t res3; /* reserved */
|
||
|
+ uint64_t res4; /* reserved */
|
||
|
+ uint32_t magic; /* Magic number, little endian, "ARM\x64" */
|
||
|
+ uint32_t res5; /* reserved (used for PE COFF offset) */
|
||
|
+ } buffer;
|
||
|
+
|
||
|
+ /* check the magic number */
|
||
|
+ if (lseek(m_fd, 0, SEEK_SET) == (off_t)-1) {
|
||
|
+ throw KSystemError("IdentifyKernel::isAarch64Kernel: lseek to "
|
||
|
+ "file start failed", errno);
|
||
|
+ }
|
||
|
+
|
||
|
+ int ret = read(m_fd, &buffer, sizeof(buffer));
|
||
|
+ if (ret < 0) {
|
||
|
+ throw KSystemError("IdentifyKernel::isAarch64Kernel: read of magic "
|
||
|
+ "start failed", errno);
|
||
|
+ } else if (ret < (int)sizeof(buffer))
|
||
|
+ return false;
|
||
|
+
|
||
|
+ return buffer.magic == 0x644d5241; /* little endian "ARM\x64" */
|
||
|
+}
|
||
|
+
|
||
|
+// -----------------------------------------------------------------------------
|
||
|
bool KernelTool::x86isRelocatable() const
|
||
|
throw (KError)
|
||
|
{
|
||
|
@@ -390,7 +433,7 @@ bool KernelTool::elfIsRelocatable() cons
|
||
|
bool KernelTool::isArchAlwaysRelocatable(const string &machine) const
|
||
|
throw ()
|
||
|
{
|
||
|
- return machine == "ia64";
|
||
|
+ return machine == "ia64" || machine == "aarch64";
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------------------------------------------
|
||
|
@@ -426,6 +469,7 @@ string KernelTool::archFromElfMachine(un
|
||
|
case EM_S390: return "s390";
|
||
|
case EM_IA_64: return "ia64";
|
||
|
case EM_X86_64: return "x86_64";
|
||
|
+ case EM_AARCH64: return "aarch64";
|
||
|
default: return "unknown";
|
||
|
}
|
||
|
}
|
||
|
@@ -681,6 +725,7 @@ string KernelTool::extractKernelConfig()
|
||
|
case KernelTool::KT_ELF:
|
||
|
case KernelTool::KT_ELF_GZ:
|
||
|
case KernelTool::KT_S390:
|
||
|
+ case KernelTool::KT_AARCH64:
|
||
|
return extractKernelConfigELF();
|
||
|
|
||
|
case KernelTool::KT_X86:
|
||
|
--- a/tests/identify_kernel.sh
|
||
|
+++ b/tests/identify_kernel.sh
|
||
|
@@ -28,18 +28,21 @@ KERNEL_IMAGES=("kernel-bzImage-x86_64"
|
||
|
"kernel-ELFgz-ia64"
|
||
|
"kernel-ELF-ia64"
|
||
|
"kernel-ELF-ppc64"
|
||
|
+ "kernel-ELF-aarch64"
|
||
|
)
|
||
|
RELOCATABLE=( 1
|
||
|
0
|
||
|
0
|
||
|
1
|
||
|
1
|
||
|
- 0 )
|
||
|
+ 0
|
||
|
+ 1 )
|
||
|
TYPE=( "x86"
|
||
|
"ELF gzip"
|
||
|
"ELF"
|
||
|
"ELF gzip"
|
||
|
"ELF"
|
||
|
+ "ELF"
|
||
|
"ELF" )
|
||
|
|
||
|
# }}}
|
||
|
--- a/kdumptool/savedump.cc
|
||
|
+++ b/kdumptool/savedump.cc
|
||
|
@@ -563,6 +563,13 @@ string SaveDump::findKernel()
|
||
|
if (binaryroot.exists())
|
||
|
return binary;
|
||
|
|
||
|
+ // 5: Image
|
||
|
+ (binary = "/boot").appendPath("Image-" + m_crashrelease);
|
||
|
+ (binaryroot = m_rootdir).appendPath(binary);
|
||
|
+ Debug::debug()->dbg("Trying %s", binaryroot.c_str());
|
||
|
+ if (binaryroot.exists())
|
||
|
+ return binary;
|
||
|
+
|
||
|
FilePath fp = m_rootdir;
|
||
|
fp.appendPath("/boot");
|
||
|
throw KError("No kernel image found in " + fp);
|
||
|
--- a/kdumptool/identifykernel.cc
|
||
|
+++ b/kdumptool/identifykernel.cc
|
||
|
@@ -91,6 +91,9 @@ void IdentifyKernel::execute()
|
||
|
case KernelTool::KT_S390:
|
||
|
cout << "S390" << endl;
|
||
|
break;
|
||
|
+ case KernelTool::KT_AARCH64:
|
||
|
+ cout << "Aarch64" << endl;
|
||
|
+ break;
|
||
|
default:
|
||
|
throw KError("The specified file is not a kernel image.");
|
||
|
}
|
||
|
--- a/kdumptool/kerneltool.h
|
||
|
+++ b/kdumptool/kerneltool.h
|
||
|
@@ -42,6 +42,7 @@ class KernelTool {
|
||
|
KT_ELF_GZ,
|
||
|
KT_X86,
|
||
|
KT_S390,
|
||
|
+ KT_AARCH64,
|
||
|
KT_NONE
|
||
|
};
|
||
|
|
||
|
@@ -207,6 +208,14 @@ class KernelTool {
|
||
|
throw (KError);
|
||
|
|
||
|
/**
|
||
|
+ * Checks if the kernel is an Aarch64 kernel image.
|
||
|
+ *
|
||
|
+ * @return @c true if it's an Aarch64 kernel image, @c false otherwise.
|
||
|
+ */
|
||
|
+ bool isAarch64Kernel() const
|
||
|
+ throw (KError);
|
||
|
+
|
||
|
+ /**
|
||
|
* Returns the architecture as string from the ELF machine type.
|
||
|
*
|
||
|
* @param[in] et_machine the ELF machine type such as EM_386
|