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

[PATCH v7 1/2] libelf: Store maximum PHDR p_align


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 4 Apr 2024 17:25:18 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6/XTvVNBqr8I/opYfrvk/te/N175FWqds5zuSoBwBvA=; b=k6+hJ3WSKMtBdF7odts2x5AcQTLbPvIsM25FbOOBKd7TfTqLn2pniLdNhQ1yjcRhM60aDqNHBLujlhD9jo35xw3fybOSwFpeNtNQ2yBxYk0E/MkgB6BV+/WE/MXE7MlsiASkU/B81D8syx3UeDWE8QDqAR9GHk1Fc3eizxKl25jZYFxcGjxKMraZpJrAg6EmI6GsZ/fhJF0eYEQCr4X0Gqg7mY1IU2zxHxNTjglmYQb/SdqkKIJuLyz6Y1P+0pnRzFUCWMloKCm9mHvTqWiw9eVgickJrrRgAvZ3oz4mvi4a8s6G+rTVUgfGjaGZ08cX5FyKL4IKX3cc3ojnS8PT0A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MWmbkKXJoEa8Bt5yRDy1AlXr3ZJDfF5zB/n7b3gE3pPaVgeEb3aAqyhx/TiRg+rT6vvuzY66nLTRBFRg3JZ8PZNbOXYhaKZTwTVKHPQIvTCmodZqlh5oPxEN38NbdvStpWQwRkUVc2Xknmt/yRs/gSYkk7SFdI5tzYoXskDcLPPYIV0vTn6/2EFcPGwwGuSiOhFk5VsJiq3f1YcKzD268B9N/SNgZYh6oPvIhNrhEFRUkDQAumkFYD4RyjuUzUEzGzRUyy6dWcQLwtlir3tgbYgaQqB5ISqvCWK3n3x2LW7qqCtGlqZP200Rz4ZNrPKHctG2z7HB5tIumOgGQorR0A==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 04 Apr 2024 21:25:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
---
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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.