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

[PATCH v6 0/4] x86/pvh: Support relocating dom0 kernel


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 27 Mar 2024 17:50:58 -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=7JGDFLL2Mbk36fV41ml7871DsjzHeNM5Ecm0pDvDuaM=; b=E9A/+bOl5YE5Q8iEn86/S95OmJK5gM/IKtC6nXeNe8TaDIjctO6CDc0sPyZKd9G9845jr5+SIMV8gIU3N0fL0uvP2vwRdABXjPqj0U9lN54uOf71nMXaehB/dVzM5NtCqV45Y6yFybmJYIz6mhGycXTGfzY01P1QVsGt2WlCXQRwOOrEapIiJc45jtojZmZgwTod746k7ilm6tcnu6ec31qCj+94VEVno9IPhmeeiLUQI70PmlvUe86g1AoQsAmw+FTnAHCyZAVf4X+p5fg0+MACfau+JwJQb10p5i22nFF7Mkz4fzKVq94E637c98swF2+0UM8BRJeP/NqR3ubvaw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFloiD0pFAPMy1HkCthm5GyPGjFVubBQFmDYcKWsgfboQuTXvsxWkfexWzko7mcFZeTh9jb0CKKygnNQadZQ5PzCeIpfGZ6gRxoxMhlzcQfIxlhOH7V3YkO+g051prS3acGX5t8SYeXE85mauDMMaBbpnDc7cgHDHh+B51BYO3F85HyFeXDz/pY9RMHYx4Ruk93Dwh2SAeeospxMcKjihI5c1Gwr3+nyxocawT59zCNwRBjhew7GmBMcATqeqYEzlY3P6NbidBWbhgLRRpscdhOOOwGYF6HuEz+VS/mNpcirpBkmrQZm7Y4gtfU5/JW2EwgvPpN04ZV13NqhYwvk1Q==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 27 Mar 2024 21:55:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Xen tries to load a PVH dom0 kernel at the fixed guest physical address
from the elf headers.  For Linux, this defaults to 0x1000000 (16MB), but
it can be configured.

Unfortunately there exist firmwares that have reserved regions at this
address, so Xen fails to load the dom0 kernel since it's not RAM.

The other issue is that the Linux PVH entry point is not
position-independent.  It expects to run at the compiled
CONFIG_PHYSICAL_ADDRESS.

This patch set expands the PVH dom0 builder to try to relocate the
kernel if needed and possible.  XEN_ELFNOTE_PHYS32_RELOC is added for
kernels to indicate they are relocatable and their acceptable address
range and alignment.

v6:
Choose the alignment from the Note if specified, or the Maximum PHDR
p_align value if greater than PAGE_SIZE.  Otherwise, it falls back to
the default 2MB.

Patches from v5 commited:
853c71dfbf xen/elfnote: Specify ELF Notes are x86-specific
7d8c9b4e8d libelf: Expand ELF note printing
8802230bfa Revert "xen/x86: bzImage parse kernel_alignment"

The first and second patches move MB/GB() to common-macros.h.

The third patch stores the maximum p_align value from the ELF PHDRs.

The fourth patch expands the pvh dom0 kernel placement code.

I'll post an additional patch showing the Linux changes to make PVH
relocatable.

Jason Andryuk (4):
  tools/init-xenstore-domain: Replace variable MB() usage
  tools: Move MB/GB() to common-macros.h
  libelf: Store maximum PHDR p_align
  x86/PVH: Support relocatable dom0 kernels

 tools/firmware/hvmloader/util.h         |   3 -
 tools/helpers/init-xenstore-domain.c    |  11 ++-
 tools/include/xen-tools/common-macros.h |   4 +
 tools/libs/light/libxl_internal.h       |   4 -
 xen/arch/x86/hvm/dom0_build.c           | 108 ++++++++++++++++++++++++
 xen/common/libelf/libelf-dominfo.c      |  35 ++++++++
 xen/common/libelf/libelf-loader.c       |  15 +++-
 xen/common/libelf/libelf-private.h      |   1 +
 xen/include/public/elfnote.h            |  16 +++-
 xen/include/xen/libelf.h                |   5 ++
 10 files changed, 186 insertions(+), 16 deletions(-)

-- 
2.44.0




 


Rackspace

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