kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: WANG Rui <wangrui@loongson.cn>
To: kexec@lists.infradead.org
Cc: Varad Gautam <vrd@amazon.de>,
	AKASHI Takahiro <takahiro.akashi@linaro.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	WANG Rui <wangrui@loongson.cn>
Subject: [PATCH] LoongArch: Fix an issue with relocatable vmlinux
Date: Fri, 24 Nov 2023 16:54:10 +0800	[thread overview]
Message-ID: <20231124085410.107080-1-wangrui@loongson.cn> (raw)

Normally vmlinux for LoongArch is of ET_EXEC type, while if built with
CONFIG_RELOCATABLE (this is PIE) and Clang, it will be of ET_DYN type.
Meanwhile, physical address field of segments in vmlinux has actually
the same value as virtual address field.

Similar to arm64, this patch allows to unconditionally skip the check
on LoongArch.

Link: https://github.com/ClangBuiltLinux/linux/issues/1963
Signed-off-by: WANG Rui <wangrui@loongson.cn>
---
 kexec/kexec-elf-exec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c
index bea7b3e..b337642 100644
--- a/kexec/kexec-elf-exec.c
+++ b/kexec/kexec-elf-exec.c
@@ -39,12 +39,13 @@ static int get_elf_exec_load_base(struct mem_ehdr *ehdr, struct kexec_info *info
 	unsigned long first, last;
 	size_t i;
 
-	/* Note on arm64:
+	/* Note on arm64 and loongarch64:
 	 * arm64's vmlinux has virtual address in physical address
 	 * field of PT_LOAD segments. So the following validity check
 	 * and relocation makes no sense on arm64.
+	 * This is also applies to LoongArch.
 	 */
-	if (ehdr->e_machine == EM_AARCH64)
+	if (ehdr->e_machine == EM_AARCH64 || ehdr->e_machine == EM_LOONGARCH)
 		return 0;
 
 	first = ULONG_MAX;
-- 
2.43.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2023-11-24  8:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24  8:54 WANG Rui [this message]
2023-11-26  3:28 ` [PATCH] LoongArch: Fix an issue with relocatable vmlinux Huacai Chen
2023-11-27 13:47 ` Simon Horman

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=20231124085410.107080-1-wangrui@loongson.cn \
    --to=wangrui@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=vrd@amazon.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).