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

Re: [PATCH] xen/efi: Handle efi_memmap with Xen relocating itself


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • Date: Tue, 17 Nov 2026 15:44:21 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=fm3 header.d=invisiblethingslab.com header.i="@invisiblethingslab.com" header.h="Cc:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=fm3 header.d=messagingengine.com header.i="@messagingengine.com" header.h="Cc:Content-Type:Date:Feedback-ID:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To:X-ME-Proxy:X-ME-Sender"
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 17 Nov 2026 14:44:40 +0000
  • Dkim2-signature: i=1; m=1; t=1794926666; d=invisiblethingslab.com; mf=PG1hcm1hcmVrQGludmlzaWJsZXRoaW5nc2xhYi5jb20+; rt=PHhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZz4=; s=fm3:rsa-sha256:MV89knqkCkgM07l1VJuHCrVEgCt9bS/iddfUp0nmPbD90/+ SsSL5EBXaoONZTUNuJcdUAeFDZiOcgDOhOKMimBP9invPEIFbNnF8ACuvh+qYmtF w+7CUxRbx8Nnak9Wkcg/M08Ht3TJ8AKpyRffTOFe2s0luZYS/b08Cjo4MoTyKh39 V3dZI4HWN0gGN5WOiZl5QVbDjxz3prDAB9yQ9hQU4vJ5Mz03yygX4WfkZkqVTIpy kXHol8/KyjKmF3FfzmYIOZd2YfY4yglE2zCoxdpMbmiCRJVw4EpPWgucRn8geMZF 3lI94AHrYgqyjLMppH8rqD+EJQNcUamDOiCjeqQ==;
  • Feedback-id: i1568416f:Fastmail
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Message-instance: m=1; h=sha256:SD5SXMCn4xnUWaZgxhH1T9tV18ybgCKAZBAU4/4Y5Ro=:EJsme7I5DbVfU8UpBy3aNydo+fEYjlWHwvAavUKP+Vg=;

On Tue, Nov 10, 2026 at 04:16:49PM +0100, Jan Beulich wrote:
> On 10.11.2026 16:14, Jan Beulich wrote:
> > On 10.11.2026 15:42, Jason Andryuk wrote:
> >> On 2026-11-10 03:42, Jan Beulich wrote:
> >>> On 07.11.2026 00:18, Jason Andryuk wrote:
> >>>> --- a/xen/arch/x86/efi/efi-boot.h
> >>>> +++ b/xen/arch/x86/efi/efi-boot.h
> >>>> @@ -224,6 +224,16 @@ static void *__init 
> >>>> efi_arch_allocate_mmap_buffer(UINTN map_size)
> >>>>       return ebmalloc(map_size);
> >>>>   }
> >>>>   
> >>>> +static void *__init efi_arch_mmap_buffer_virt(void *ptr)
> >>>> +{
> >>>> +    unsigned long load_base;
> >>>> +
> >>>> +    /* RIP-relative address is the current Xen load address. */
> >>>> +    asm("lea __image_base__(%%rip), %0" : "=r" (load_base));
> >>>> +
> >>>> +    return ptr - load_base + XEN_VIRT_START;
> >>>> +}
> >>>
> >>> There's nothing specific to the mmap in this function, hence it's name is
> >>> a little odd.
> >>
> >> It is paired with efi_arch_allocate_mmap_buffer() above, so I wanted the 
> >> name to indicate that it is converting mmap_buffer to a virt address. 
> > 
> > Hmm, right.

If the current name is confusing, maybe name it
efi_arch_mmap_buffer_to_virt()? But IMHO the current version is clear
enough.

> > And this is entirely different between x86 and Arm. So common
> > code wants to call a function of this name, but on x86 this may then want
> > to be a thin wrapper around ...
> > 
> >> Having said that, I am open to renaming if that is desired. 
> >> Alternatives could be:
> >> efi_arch_xen_phys_to_virt()
> >> or
> >> efi_arch_image_phys_to_virt()
> >> or
> >> efi_arch_xen_image_to_virt()
> > 
> > ... a function of any of these names (which in turn would be possible to
> > use for other purposes). Marek - thoughts?

efi_arch_image_phys_to_virt() for a helper function sounds okay
(efi_arch_xen_image_to_virt would work too, but IMO a little less
clear).

> > With this constraint on the x86 side, wouldn't you then better add an
> > ASSERT()-like construct to the actual translation function?
> 
> Or use the existing (and Arm) logic when the pointer isn't within the Xen
> image. (There can be ambiguous cases, though, I fear.)

Automatic fallback I fear could hide some issues and make them harder to
debug (like the original issue this patch attempts to fix). But an
assert for the argument may be a good idea.

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab

Attachment: signature.asc
Description: PGP signature


 


Rackspace

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