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

Re: [PATCH 0/3] x86/pvh: Support relocating dom0 kernel


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 7 Mar 2024 12:33:17 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.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=yv7KW5Wwm4Hia1oW6MlVGs+pvsoaPx39pBEuqEVNQoM=; b=AtUfXvw2zTYcJDc4+7iJcQrXmacuewA6uuPvFmINCp2Vh/gJ0immwjExcHMtq4sOu8xJN6XmAtJ1Gu48buEorIaeiKtSeE76T/hpyg0IwvRk8KtYVnNoZDB6AF9th3Y3+4zJoFb6o4u1yTNlqZniB2neKYYFy5ejW37hjZWhPCEVyfxYoICLuZGgoS0d7q1gtQByloPDpBl5O1SQAG3Dw+XunRZNM19hhgUlitIlhfXoJR7bWlAow2CSpRN2j0X3TMkXkSFob8kDw+am5gYE0toY7u+n/mI2avYJVNRUP38nfaIcoIfbYCha+P0HzqNrtfTWcjEnwnym6eCM6Pp4dQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hkgz3m1XLeIl7XwjYi9qkTa+DTJmgkaUpZa0V9UG41PVdi+A/ooCUKIS055ug6SzzhO0qrWClC6WOn139rd5FYJoVCJgNmk/ZJ1vGxf9CekaRxX8RqfDx0ZIO89aawVA+7BkRyUSyoH+ui0Tq6jBWNSRVQ0G300Igc/m4uGUtuhhd15ncMRAQl/yEvdlMQ0GYaPOHD0azBxKI4agJDaZKEmcWIanYnTqtSjXmfaj8psEMOamnmx60RW/NELWbA/Jenek2R+6HFz/YayctGCGSXBL2d1Vgm54SM488KECVbOlqRdgidyTx58nF93U6oOoULPFJ28DXa3r5HczwUUF3A==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 07 Mar 2024 17:37:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2024-03-07 05:20, Roger Pau Monné wrote:
On Thu, Mar 07, 2024 at 11:08:37AM +0100, Jan Beulich wrote:
On 07.03.2024 11:00, Roger Pau Monné wrote:
On Wed, Mar 06, 2024 at 01:50:29PM -0500, Jason Andryuk wrote:
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.  XENFEAT_pvh_relocatable is added for
kernels to indicate they are relocatable.  However, we may want to
switch to an additional ELF note with the kernel alignment.  Linux
specifies a kernel alignment in the bzImage boot_params.setup_header,
but that is not present the ELF vmlinux file.

I wonder whether we need a pair of notes, to signal the min/max
addresses the kernel supports being relocated to.

Plus, as per your other reply, a 3rd one to specify alignment needs.

Alignment we could in theory get from the ELF program header, if OSes
fill those reliably.  FreeBSD seems to do so, haven't checked Linux.

I will look into this more, but at first glance, I don't see a connection between Linux's CONFIG_PHYSICAL_ALIGN and the values in the elf headers. As a quick test, I set CONFIG_PHYSICAL_ALIGN=0x800000, but the elf align values are still 0x200000.

The elf header values may be a suitable fallback though?

Then again - a single note can have multiple values. So perhaps it
doesn't need to be more than one new notes (except if dealing with
multi-value ones is deemed too complicated).

I've never dealt with a multi-value note, if that's not overly
complicated I would be fine with it, otherwise multiple notes are OK
IMO.

It looks like a single note can be followed by arbitrary data, so putting three values in should be fine. PVH is defined with a 32bit entry point, so are 32bit min, max & align values acceptable, or should 64bit be specified? Linux uses _ASM_PTR for PHYS32_ENTRY so its size matches the bitness of the target (32 on 32/ 64 on 64). I guess I'll follow that unless I hear a preference otherwise.

Regards,
Jason



 


Rackspace

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