|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/efi: Handle efi_memmap with Xen relocating itself
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |