Re: [PATCH v2 00/10] efi/libstub: Avoid UTF-16 conversion busywork

From: Vincent Mailhol

Date: Tue Sep 15 2026 - 14:41:49 EST


On 09/09/2026 at 13:55, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@xxxxxxxxxx>
>
> The EFI libstub performs some redundant conversions between UTF-16 and
> UTF-8 and back again, which includes dealing with surrogate pairs, which
> UEFI implementations themselves simply ignore.
>
> So drop all the homegrown code, and use the existing UCS-2 (== UTF-16
> without surrogate pairs) library code where conversion to UTF-8 is
> actually needed (the kernel command line).
>
> The remaining handling involves the EFI console, which supports wide
> characters natively, so just use those directly.
>
> Changes since v1 [0]:
> - drop size limit from ucs2_strscpy() instead of just the WARN()
> - suppress modinfo sections from ucs2_string when __DISABLE_EXPORTS is
> defined
> - allow the input limit and max output size to be passed separately to
> ucs2_to_utf8()
> - reimplement efi_convert_cmdline() to optimize the common case, and
> only process the input character by character if its size exceeds
> COMMAND_LINE_SIZE
> - use memcpy() to avoid strscpy() semantics in handling of %ls
> - incorporate Vincent's patch (which inspired this work) for
> completeness
>
> Cc: Vincent Mailhol <mailhol@xxxxxxxxxx>

Sorry for the late feedback. I just finished my review. Aside from the
few comments I left, the runtime tests were all OK. My BLI patch works
fine on top of your changes.

Thanks again for the time spent to accommodate for my patch!


Yours sincerely,
Vincent Mailhol