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

Re: [PATCH v2 2/3] libelf: Expand ELF note printing


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 14 Mar 2024 16:36:27 -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=piwOf8ANvZ+qozANPPSOGx1ygTDKAE5UUxoJUqgz4Mk=; b=nNCsvxAiFTuEfCb0+xuInShM4qP37pkz9iqWqwCPfACqi4NFezQgOcOsB96H1EIoWjK98pLGctcuwnyKZlDl3BDxJOWLirvG8Va1I0OW9o1JhZ2oQktsQxXUm9L1O2BC99z1HXA+oPgbmI/B0lprWru22h8XiIlN4D6bh6vNmGC0XYeo25NewRB9wWfdJlas0Kh6epLFkjBjF9xzoursc7o7+grIzZDPgWhKkRXGKkRU+sKLJD+jCP0736P5UmVAPnlqtRTb7NVgUM3W27jPB90zg5O/ZsQF4IPGA1cee1zdGZAy3jaZHoUTTt+BarF8FlTDNUIzF+O+XkhBCG9PgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iriAO/cXkp52RhhXjvoa82enwqTn+a7epl+vUDfhGtnhFJI6z75pM5/s3KaJ5th6w9HdA1nOOEqE5trgyBlfN/t7AumjhUJu8ACfXVeKB8kr0IVO3VPZ8LN35ZzHI3wG3mQ+/BEltUF252d24UtZsmlcczFdOIpl7H7g2Y+g7XPGeHEAN3cfNva4B4++5Dc5nTi8/E4kjzU+bbW5lObQE0YDaKn/2yfApCE93rQbrniuLxKzq+Zqx/HhGqgLAnHnc5Kx83ieitwJ+4MNAUyvsJvj/rQKE4gS3wt/RLAQ5t92d2elMdiVDzRRtdQEWGwTrj53ub09AGeO7OoPdQftYg==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 14 Mar 2024 20:36:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2024-03-14 09:16, Jan Beulich wrote:
On 13.03.2024 20:30, Jason Andryuk wrote:
@@ -217,6 +225,15 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf,
      case XEN_ELFNOTE_PHYS32_ENTRY:
          parms->phys_entry = val;
          break;
+
+    case XEN_ELFNOTE_L1_MFN_VALID:
+        if ( elf_uval(elf, note, descsz) != 2 * sizeof(uint64_t) )
+            return -1;

elf_note_numeric() use sites don't have such a check. Why would we need
one here, and even more so causing a error to be raised when in reality
the supplied values (still) aren't consumed? Furthermore the documentation
says "pairs" (plural) for a reason. Finally maddr_t-sized only happens to
mean uint64_t on all architectures we presently support.

I failed to pay attention to the definition stating plural pairs. I saw Linux stored two 64bit values and printed them.

I added the size check to avoid going out of bounds. elf_note_numeric() handles 1, 2, 4 or 8 bytes and returns 0 otherwise, so it won't overrun boundaries. That's why it was getting printed as "ELF: note: L1_MFN_VALID = 0"

What motivated this was seeing "PVH_RELOCATION = 0". That confusingly looks like relocation is disabled.

I'm fine dropping this attempt at printing the L1_MFN_VALID note. maddr_t is not defined, and it looks the note values were 32bit in non-PAE kernels. It could just be printed as "ELF: note: L1_MFN_VALID" with no details.

Regards,
Jason

+        elf_msg(elf, "mask: %#"PRIx64" val: %#"PRIx64"\n",
+                elf_note_numeric_array(elf, note, 8, 0),
+                elf_note_numeric_array(elf, note, 8, 1));
+        break;
      }
      return 0;
  }




 


Rackspace

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