On Mon, 18 May 2020 at 21:07, Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote: > > This series (on top of efi/next) adds a basic printf implementation for > the EFI stub to use. > > Patches 1-2 are minor cleanup. > > Patch 3 adds an on-stack buffer for efi_puts to do the char to UTF-16 > conversion, to avoid calling into the firmware for each character. > > Patches 4-16 copy the simple printf implementation from > arch/x86/boot/printf.c and spruce it up. The main enhancements are > support for 64-bit integers and conversion to vsnprintf. There are small > fixes to correct the behavior for edge cases (detailed in the individual > patches). > > Patch 17 changes efi_info/efi_err to actually use efi_printk, and > introduces a loglevel into the EFI stub instead of just quiet/non-quiet. > The loglevels are reused from the main kernel. An efi_debug macro is > also added, but is currently unused. As an aside, we chose efi_info over > efi_pr_info, but I'm wondering whether we should make it efi_pr_info > after all: there is already an efi_info symbol (structure type and field > name) so it might lead to some confusion. > > Patch 18-19 add an option to list the available modes from the GOP, > which should make using the new video=efifb parameters easier. > > Patches 20-24 incorporate UTF-16 support into the new printf function > and use it in a couple of places. > > Arvind Sankar (24): > efi/libstub: Include dependencies of efistub.h > efi/libstub: Rename efi_[char16_]printk to efi_[char16_]puts > efi/libstub: Buffer output of efi_puts > efi/libstub: Add a basic printf implementation > efi/libstub: Optimize for size instead of speed > efi/printf: Drop %n format and L qualifier > efi/printf: Add 64-bit and 8-bit integer support > efi/printf: Factor out flags parsing and handle '%' earlier > efi/printf: Fix minor bug in precision handling > efi/printf: Merge 'p' with the integer formats > efi/printf: Factor out width/precision parsing > efi/printf: Factor out integer argument retrieval > efi/printf: Handle null string input > efi/printf: Refactor code to consolidate padding and output > efi/printf: Abort on invalid format > efi/printf: Turn vsprintf into vsnprintf > efi/libstub: Implement printk-style logging > efi/libstub: Add definitions for console input and events > efi/gop: Add an option to list out the available GOP modes > efi/printf: Add support for wchar_t (UTF-16) > efi/libstub: Add UTF-8 decoding to efi_puts > efi/libstub: Use %ls for filename > efi/libstub: Get the exact UTF-8 length > efi/libstub: Use snprintf with %ls to convert the command line > Thanks Arvind, this is looking really good! Did you use any test code for the printf() parsing? Given that the kernel command line is not covered by secure boot signing (or the initrd, come to think of it), I'd hate to open up a security hole here. > Documentation/fb/efifb.rst | 5 + > arch/x86/include/asm/efi.h | 10 + > arch/x86/xen/efi.c | 2 +- > drivers/firmware/efi/libstub/Makefile | 6 +- > .../firmware/efi/libstub/efi-stub-helper.c | 275 ++++++--- > drivers/firmware/efi/libstub/efistub.h | 107 +++- > drivers/firmware/efi/libstub/file.c | 4 +- > drivers/firmware/efi/libstub/gop.c | 97 ++- > drivers/firmware/efi/libstub/vsprintf.c | 563 ++++++++++++++++++ > include/linux/efi.h | 4 +- > 10 files changed, 968 insertions(+), 105 deletions(-) > create mode 100644 drivers/firmware/efi/libstub/vsprintf.c > > -- > 2.26.2 >