From: Jason Andryuk <jason.andryuk@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: Jason Andryuk <jason.andryuk@amd.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH v7 1/2] libelf: Store maximum PHDR p_align
Date: Thu, 4 Apr 2024 17:25:18 -0400 [thread overview]
Message-ID: <20240404212519.16401-2-jason.andryuk@amd.com> (raw)
In-Reply-To: <20240404212519.16401-1-jason.andryuk@amd.com>
While parsing the PHDRs, store the maximum p_align value. This may be
consulted for moving a PVH image's load address.
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
v6:
New
v7:
Remove printing p_align. It may be confusing and is only useful when
a PVH kernel needs to be moved.
---
xen/common/libelf/libelf-loader.c | 5 +++++
xen/include/xen/libelf.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/xen/common/libelf/libelf-loader.c b/xen/common/libelf/libelf-loader.c
index 629cc0d3e6..e571ea670e 100644
--- a/xen/common/libelf/libelf-loader.c
+++ b/xen/common/libelf/libelf-loader.c
@@ -468,6 +468,7 @@ void elf_parse_binary(struct elf_binary *elf)
{
ELF_HANDLE_DECL(elf_phdr) phdr;
uint64_t low = -1, high = 0, paddr, memsz;
+ uint64_t max_align = 0, palign;
unsigned i, count;
count = elf_phdr_count(elf);
@@ -481,15 +482,19 @@ void elf_parse_binary(struct elf_binary *elf)
continue;
paddr = elf_uval(elf, phdr, p_paddr);
memsz = elf_uval(elf, phdr, p_memsz);
+ palign = elf_uval(elf, phdr, p_align);
elf_msg(elf, "ELF: phdr: paddr=%#" PRIx64 " memsz=%#" PRIx64 "\n",
paddr, memsz);
if ( low > paddr )
low = paddr;
if ( high < paddr + memsz )
high = paddr + memsz;
+ if ( max_align < palign )
+ max_align = palign;
}
elf->pstart = low;
elf->pend = high;
+ elf->palign = max_align;
elf_msg(elf, "ELF: memory: %#" PRIx64 " -> %#" PRIx64 "\n",
elf->pstart, elf->pend);
}
diff --git a/xen/include/xen/libelf.h b/xen/include/xen/libelf.h
index 1c77e3df31..2d971f958e 100644
--- a/xen/include/xen/libelf.h
+++ b/xen/include/xen/libelf.h
@@ -196,6 +196,7 @@ struct elf_binary {
size_t dest_size;
uint64_t pstart;
uint64_t pend;
+ uint64_t palign;
uint64_t reloc_offset;
uint64_t bsd_symtab_pstart;
--
2.44.0
next prev parent reply other threads:[~2024-04-04 21:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 21:25 [PATCH v7 0/2] x86/pvh: Support relocating dom0 kernel Jason Andryuk
2024-04-04 21:25 ` Jason Andryuk [this message]
2024-04-08 6:55 ` [PATCH v7 1/2] libelf: Store maximum PHDR p_align Jan Beulich
2024-04-04 21:25 ` [PATCH v7 2/2] x86/PVH: Support relocatable dom0 kernels Jason Andryuk
2024-04-08 7:00 ` Jan Beulich
2024-04-08 16:56 ` Jason Andryuk
2024-04-17 13:24 ` Jan Beulich
2024-04-18 14:34 ` Jason Andryuk
2024-04-18 15:17 ` Jan Beulich
2024-04-04 21:30 ` [PATCH v7] RFC: x86/pvh: Make Xen PVH entrypoint PIC for x86-64 Jason Andryuk
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=20240404212519.16401-2-jason.andryuk@amd.com \
--to=jason.andryuk@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.