summaryrefslogtreecommitdiff
path: root/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
AgeCommit message (Collapse)AuthorFilesLines
2025-05-26[QemuLoadImageLib] Prefix initrd=initrd in cmdlineMiguel Flores Ruiz de Eguino1-4/+4
The current implementation causes issues when the command line contains arguments to be passed to /init after "--". Instead we can prepend that at the beginning of the cmdline. From: https://www.kernel.org/doc/html/v6.12/admin-guide/kernel-parameters.html > Everything after “--” is passed as an argument to init. Example of problematic case: ``` Kernel command line: panic=0 init=/init console=ttyS0 earlyprintk=ttyS0 -- echo hello | nc -l -p 8080 initrd=initrd [init] running command echo hello | nc -l -p 8080 initrd=initrd ... [init] running command echo hello | nc -l -p 8080 initrd=initrd nc: exec initrd=initrd: No such file or directory ``` Signed-off-by: Miguel Flores Ruiz de Eguino <miguelfrde@google.com>
2025-01-29OvmfPkg: fix warning about uninitialized variableMike Maslenkin1-0/+1
GenericQemuLoadImageLib.c: In function 'QemuLoadKernelImage': GenericQemuLoadImageLib.c:323:5: error: 'CommandLine' may be used uninitialized in this function [-Werror=maybe-uninitialized] UnicodeSPrintAsciiFormat ( ^~~~~~~~~~~~~~~~~~~~~~~~~~ KernelLoadedImage->LoadOptions, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ KernelLoadedImage->LoadOptionsSize, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%a%a", ~~~~~~~ (CommandLineSize == 0) ? "" : CommandLine, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (InitrdSize == 0) ? "" : " initrd=initrd" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ); ~ cc1: all warnings being treated as errors Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2025-01-24OvmfPkg/GenericQemuLoadImageLib: fix cmdline + initrd handlingGerd Hoffmann1-2/+10
Commit 459f5ffa24ae ("OvmfPkg/QemuKernelLoaderFsDxe: rework direct kernel boot filesystem") has a small change in behavior: In case there is no data the file is not created and attempts to open file return EFI_NOT_FOUND. Old behavior was to add a zero-length file to the filesystem. Fix GenericQemuLoadImageLib to handle EFI_NOT_FOUND correctly for 'initrd' and 'cmdline'. Reported-by: Srikanth Aithal <sraithal@amd.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2025-01-21OvmfPkg/GenericQemuLoadImageLib: support booting via shimGerd Hoffmann1-2/+54
Try load shim first. In case that succeeded update the command line to list 'kernel' first so shim will fetch the kernel from the kernel loader file system. This allows to use direct kernel boot with distro kernels and secure boot enabled. Usually distro kernels can only be verified by distro shim using the distro keys compiled into the shim binary. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2023-04-10OvmfPkg: Update code to be more C11 compliant by using __func__Rebecca Cran1-3/+3
__FUNCTION__ is a pre-standard extension that gcc and Visual C++ among others support, while __func__ was standardized in C99. Since it's more standard, replace __FUNCTION__ with __func__ throughout OvmfPkg. Signed-off-by: Rebecca Cran <rebecca@bsdio.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
2021-12-07OvmfPkg: Apply uncrustify changesMichael Kubacki1-73/+97
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the OvmfPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
2021-06-29OvmfPkg/GenericQemuLoadImageLib: Read cmdline from QemuKernelLoaderFsDov Murik1-14/+137
Remove the QemuFwCfgLib interface used to read the QEMU cmdline (-append argument) and the initrd size. Instead, use the synthetic filesystem QemuKernelLoaderFs which has three files: "kernel", "initrd", and "cmdline". Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Tobin Feldman-Fitzthum <tobin@linux.ibm.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3457 Signed-off-by: Dov Murik <dovmurik@linux.ibm.com> Message-Id: <20210628105110.379951-5-dovmurik@linux.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
2021-06-29OvmfPkg/GenericQemuLoadImageLib: plug cmdline blob leak on successDov Murik1-2/+4
When QemuLoadKernelImage() ends successfully, the command-line blob is not freed, even though it is not used elsewhere (its content is already copied to KernelLoadedImage->LoadOptions). The memory leak bug was introduced in commit ddd2be6b0026 ("OvmfPkg: provide a generic implementation of QemuLoadImageLib", 2020-03-05). Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Tobin Feldman-Fitzthum <tobin@linux.ibm.com> Reported-by: Laszlo Ersek <lersek@redhat.com> Fixes: ddd2be6b0026abcd0f819b3915fc80c3de81dd62 Signed-off-by: Dov Murik <dovmurik@linux.ibm.com> Message-Id: <20210628105110.379951-2-dovmurik@linux.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
2020-06-10OvmfPkg/GenericQemuLoadImageLib: log "Not Found" at INFO levelLaszlo Ersek1-1/+2
gBS->LoadImage() returning EFI_NOT_FOUND is an expected condition; it means that QEMU wasn't started with "-kernel". Log this status code as INFO rather than ERROR. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200609105414.12474-1-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
2020-03-30OvmfPkg/GenericQemuLoadImageLib: Fix VS2019 UINT32 conversion errorArd Biesheuvel1-1/+1
Building OVMF for X64 with secure boot enabled on VS2019 results in the following error: d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154): error C2220: the following warning is treated as an error d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154): warning C4244: '=': conversion from 'UINTN' to 'UINT32', possible loss of data Suppress the error by making the cast explicit. Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2636 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2020-03-05OvmfPkg: provide a generic implementation of QemuLoadImageLibArd Biesheuvel1-0/+276
Implement QemuLoadImageLib, and make it load the image provided by the QEMU_EFI_LOADER_FS_MEDIA_GUID/kernel device path that we implemented in a preceding patch in a separate DXE driver, using only the standard LoadImage and StartImage boot services. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2566 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Laszlo Ersek <lersek@redhat.com>