[Crash-utility] [PATCH v3 09/10] LoongArch64: Add "--kaslr" command line option support

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

 



Apply initial changes to support kernel address space layout
randomization (KASLR) for loongarch64.  This is the minimal patch
required to process loongarch64 dumps for the kernels configured
with CONFIG_RANDOMIZE_BASE(CONFIG_RELOCATABLE), and to accept the
"--kaslr" command line option. Only dumpfiles whose headers contain
kernel VMCOREINFO data are supported.

Example:
crash vmcore vmlinux --kaslr auto

Co-developed-by: Youling Tang <tangyouling@xxxxxxxxxxx>
Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
Signed-off-by: Ming Wang <wangming01@xxxxxxxxxxx>
---
 crash.8   |  2 +-
 help.c    |  9 +++++----
 main.c    |  3 ++-
 symbols.c | 10 ++++++----
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/crash.8 b/crash.8
index e553a0b..0662f92 100644
--- a/crash.8
+++ b/crash.8
@@ -491,7 +491,7 @@ Search for the kernel source code in directory instead of in the
 standard location that is compiled into the debuginfo data.
 .TP
 .BI --kaslr \ offset | auto
-If an x86_64 kernel was configured with 
+If an x86, x86_64, s390x or loongarch64 kernel was configured with
 .B CONFIG_RANDOMIZE_BASE,
 the offset value is equal to the difference between the symbol values 
 compiled into the vmlinux file and their relocated KASLR values.  If set to
diff --git a/help.c b/help.c
index d80e843..cd3c97f 100644
--- a/help.c
+++ b/help.c
@@ -336,10 +336,11 @@ char *program_usage_info[] = {
     "    and verification.  The default count is 32768.",
     "",
     "  --kaslr offset | auto",
-    "    If x86, x86_64 or s390x kernel was configured with CONFIG_RANDOMIZE_BASE,",
-    "    the offset value is equal to the difference between the symbol values ",
-    "    compiled into the vmlinux file and their relocated KASLR value.  If", 
-    "    set to auto, the KASLR offset value will be automatically calculated.",
+    "    If x86, x86_64, s390x or loongarch64 kernel was configured with",
+    "    CONFIG_RANDOMIZE_BASE, the offset value is equal to the difference",
+    "    between the symbol values compiled into the vmlinux file and their",
+    "    relocated KASLR value.  If set to auto, the KASLR offset value will",
+    "    be automatically calculated.",
     "",
     "  --minimal",
     "    Bring up a session that is restricted to the log, dis, rd, sym,",
diff --git a/main.c b/main.c
index 4fd4ca5..0b6b927 100644
--- a/main.c
+++ b/main.c
@@ -228,7 +228,8 @@ main(int argc, char **argv)
 			} else if (STREQ(long_options[option_index].name, "kaslr")) {
 				if (!machine_type("X86_64") &&
 				    !machine_type("ARM64") && !machine_type("X86") &&
-				    !machine_type("S390X") && !machine_type("RISCV64"))
+				    !machine_type("S390X") && !machine_type("RISCV64") &&
++				    !machine_type("LOONGARCH64"))
 					error(INFO, "--kaslr not valid "
 						"with this machine type.\n");
 				else if (STREQ(optarg, "auto"))
diff --git a/symbols.c b/symbols.c
index 11e0ca2..d017681 100644
--- a/symbols.c
+++ b/symbols.c
@@ -629,7 +629,8 @@ kaslr_init(void)
 	char *string;
 
 	if ((!machine_type("X86_64") && !machine_type("ARM64") && !machine_type("X86") &&
-	    !machine_type("S390X") && !machine_type("RISCV64")) || (kt->flags & RELOC_SET))
+	    !machine_type("S390X") && !machine_type("RISCV64") && !machine_type("LOONGARCH64")) ||
+			(kt->flags & RELOC_SET))
 		return;
 
 	if (!kt->vmcoreinfo._stext_SYMBOL &&
@@ -794,8 +795,8 @@ store_symbols(bfd *abfd, int dynamic, void *minisyms, long symcount,
 					fromend, size, store);
 		} else if (!(kt->flags & RELOC_SET))
 			kt->flags |= RELOC_FORCE;
-	} else if (machine_type("X86_64") || machine_type("ARM64") ||
-		   machine_type("S390X") || machine_type("RISCV64")) {
+	} else if (machine_type("X86_64") || machine_type("ARM64") || machine_type("S390X") ||
+			machine_type("RISCV64") || machine_type("LOONGARCH64")) {
 		if ((kt->flags2 & RELOC_AUTO) && !(kt->flags & RELOC_SET))
 			derive_kaslr_offset(abfd, dynamic, from,
 				fromend, size, store);
@@ -867,7 +868,8 @@ store_sysmap_symbols(void)
                         strerror(errno));
 
 	if (!machine_type("X86") && !machine_type("X86_64") &&
-	    !machine_type("ARM64") && !machine_type("S390X"))
+	    !machine_type("ARM64") && !machine_type("S390X") &&
+	    !machine_type("LOONGARCH64"))
 		kt->flags &= ~RELOC_SET;
 
 	first = 0;
-- 
2.39.2
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux