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

Re: [PATCH v6 3/4] libelf: Store maximum PHDR p_align


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Fri, 29 Mar 2024 10:41:50 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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=vu6xrJyNtWjN2IpLDYgUlIrzINv61r/ruyOOPOcIvDM=; b=JlfGlhVRUlL9qDI+mD8yvmDUAXFV8nnqtEAmlWFlXxySP7raeVRTShL8Q6pfIjSMOUlLm8KmzugOqCF+LVll8VxGzh9O2s4ru+44Wx/PMQrKvZNzz4F62VTO/6xe5yt1f5+K0Wi3D622K0WcjA1+tJTpUuaCYc1VbUw1epQ6OILvtTQVrsBiLymRArS89XfrCnKjpAfQyWgp7yf7vsxqG31XuKfKWI+GbjgSLnY/sw5HjUinLms3p1HkaLsmMBAPpRAnZ/EzVsrvHx4RnlQSohT2FDspO38E1qhTmvQXWZel+ooiaJTz+YuFrNisTSV5YXFErUw4qTmgPBA94VUwHw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mfhOe+xJhcQnVG2rofqwxy+xfGL4llUJqxSZ3Tw9OpQuINpE2CMQ+nsZhHLmwCw3DKJU1015BltT1yTC318kFaDL4o1B87t49/NEglYL0SmdmbB6rQfdBR/X7Li+h847lmi8simtC0SWpLCgbbnLIG3PJQgt9Vxs6v0eqnWZP6FLkTa2AOmjkTJnyqVdsI960MZdW4XsfdXoxsy+EUnN0xhp30d/Uhsw/GF30uoK4IYPNc6aFZ1CosfbAuBWlCkTfRWL7iCChHwxKfyuiISLXs3BnHq86DsLtNOMuu06eyGN33scPu6GIQyfOJNM4V/GGkyQh0trjpuK2e2T5rMAaw==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 29 Mar 2024 14:42:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2024-03-28 12:47, Jan Beulich wrote:
On 27.03.2024 22:51, Jason Andryuk wrote:
--- 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,17 +482,23 @@ void elf_parse_binary(struct elf_binary *elf)
              continue;
          paddr = elf_uval(elf, phdr, p_paddr);
          memsz = elf_uval(elf, phdr, p_memsz);
-        elf_msg(elf, "ELF: phdr: paddr=%#" PRIx64 " memsz=%#" PRIx64 "\n",
-                paddr, memsz);
+        palign = elf_uval(elf, phdr, p_align);
+        elf_msg(elf,
+                "ELF: phdr: paddr=%#" PRIx64 " memsz=%#" PRIx64 " palign=%#" PRIx64 
"\n",
+                paddr, memsz, palign);
          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_msg(elf, "ELF: memory: %#" PRIx64 " -> %#" PRIx64 "\n",
-            elf->pstart, elf->pend);
+    elf->palign = max_align;
+    elf_msg(elf,
+            "ELF: memory: %#" PRIx64 " -> %#" PRIx64 " align:%#" PRIx64 "\n",
+            elf->pstart, elf->pend, elf->palign);
  }

Hmm, it's just this final logging change which I'm a little concerned by:
Having looked at Linux'es phdr, I noticed that the addresses there aren't
necessarily matching the corresponding alignment. Therefore I'm a little
concerned that the output here might raise questions when people see
seemingly inconsistent values in the log. Could you/we at least make it
read like e.g. "align (max): ..."?

max_align?

Looking at my test vmlinux, it looks like PHDR 0 (.text) and PHDR 1 (.data) are aligned. It's the PHDR 2 (.init) that isn't aligned. Is that what you see?

This line is already printing the min and max across all the PHDRs, so it would only look confusing if the start didn't match the align.

I'm not sure how useful it is to print the alignment, and I considered not printing it. It's only used with PVH Dom0 right now, so it's not relevant in most cases.

Regards,
Jason



 


Rackspace

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