summary refs log tree commit diff stats
path: root/hw/uefi (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hw/uefi: open json file in binary modeGerd Hoffmann2025-08-121-1/+1
| | | | | | | | | | Fixes file length discrepancies due to line ending conversions on windows hosts. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3058 Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250811130110.820958-4-kraxel@redhat.com>
* hw/uefi: check access for first variableGerd Hoffmann2025-08-121-0/+3
| | | | | | | | | | When listing variables (via get-next-variable-name) only the names of variables which can be accessed will be returned. That check was missing for the first variable though. Add it. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250811130110.820958-3-kraxel@redhat.com>
* hw/uefi: return success for notificationsGerd Hoffmann2025-08-121-0/+2
| | | | | | | | | Set status to SUCCESS for ready-to-boot and exit-boot-services notification calls. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250811130110.820958-2-kraxel@redhat.com>
* hw/uefi: clear uefi-vars buffer in uefi_vars_write callbackMauro Matteo Cascella2025-08-121-2/+2
| | | | | | | | | | | | | | | | | | | When the guest writes to register UEFI_VARS_REG_BUFFER_SIZE, the .write callback `uefi_vars_write` is invoked. The function allocates a heap buffer without zeroing the memory, leaving the buffer filled with residual data from prior allocations. When the guest later reads from register UEFI_VARS_REG_PIO_BUFFER_TRANSFER, the .read callback `uefi_vars_read` returns leftover metadata or other sensitive process memory from the previously allocated buffer, leading to an information disclosure vulnerability. Fixes: CVE-2025-8860 Fixes: 90ca4e03c27d ("hw/uefi: add var-service-core.c") Reported-by: ZDI <zdi-disclosures@trendmicro.com> Suggested-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com> Message-ID: <20250811101128.17661-1-mcascell@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* hw/uefi: Create and use trace.h wrapper headerPeter Maydell2025-07-135-4/+6
| | | | | | | | | | | | | | | The documentation of the trace subsystem (docs/devel/tracing.rst) says that each subdirectory which uses trace events should create a wrapper trace.h file which includes the trace/trace-foo.h generated header, and that .c files then #include "trace.h". We didn't follow this pattern in hw/uefi/. Correct this by creating and using the trace.h wrapper header. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qom: Have class_init() take a const data argumentPhilippe Mathieu-Daudé2025-04-251-2/+2
| | | | | | | | | | Mechanical change using gsed, then style manually adapted to pass checkpatch.pl script. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250424194905.82506-4-philmd@linaro.org>
* hw/uefi-vars-sysbus: allow for loongarch virtGerd Hoffmann2025-03-211-1/+1
| | | | | | | | Allow the device being added to loongarch virt VMs. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250319141159.1461621-6-kraxel@redhat.com>
* hw/uefi-vars-sysbus: allow for riscv virtGerd Hoffmann2025-03-211-1/+1
| | | | | | | | | Allow the device being added to riscv virt VMs. Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250319141159.1461621-5-kraxel@redhat.com>
* hw/uefi: fix error handling in uefi_vars_json_loadGerd Hoffmann2025-03-211-1/+8
| | | | | | | | | | Catch lseek errors. Return on read errors. Fixes: CID 1593154 Fixes: CID 1593157 Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250319141159.1461621-4-kraxel@redhat.com>
* hw/uefi: fix error handling in uefi_vars_json_saveGerd Hoffmann2025-03-211-4/+11
| | | | | | | | | Catch lseek errors. Return on errors. Use autoptr for the GString to simplify cleanup. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250319141159.1461621-3-kraxel@redhat.com>
* hw/uefi: flush variable store to disk in post loadGerd Hoffmann2025-03-211-0/+1
| | | | | | | | | | | Make live migration more robust. Commit 4c0cfc72b31a ("pflash_cfi01: write flash contents to bdrv on incoming migration") elaborates in detail on the motivation. Cc: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250319141159.1461621-2-kraxel@redhat.com>
* docs: add uefi variable service documentationGerd Hoffmann2025-03-041-0/+7
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-25-kraxel@redhat.com>
* hw/uefi-vars-sysbus: add x64 variantGerd Hoffmann2025-03-041-0/+32
| | | | | | | | | | The x86 variant of the device is mapped on the fixed address 0xfef10000 and uses etc/hardware-info instead of FDT to pass the mapping location to the edk2 firmware. The latter allows to move the device to a different location should that turn out to be necessary in the future. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-21-kraxel@redhat.com>
* hw/uefi-vars-sysbus: qemu platform bus supportGerd Hoffmann2025-03-041-0/+1
| | | | | | | | Add and register function to create an device tree entry when the device is added to the qemu platform bus. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-20-kraxel@redhat.com>
* hw/uefi: add uefi-vars-sysbus deviceGerd Hoffmann2025-03-042-1/+93
| | | | | | | This adds sysbus bindings for the variable service. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-19-kraxel@redhat.com>
* hw/uefi: add to mesonGerd Hoffmann2025-03-041-0/+19
| | | | | | | Wire up uefi-vars in the build system. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-18-kraxel@redhat.com>
* hw/uefi: add UEFI_VARS to KconfigGerd Hoffmann2025-03-041-0/+3
| | | | | | | Add UEFI_VARS config option, enable by default for x86_64 and aarch64. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-17-kraxel@redhat.com>
* hw/uefi: add trace-eventsGerd Hoffmann2025-03-041-0/+17
| | | | | | | Add trace events for debugging and trouble shooting. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-16-kraxel@redhat.com>
* hw/uefi: add var-service-json.c + qapi for NV vars.Gerd Hoffmann2025-03-041-0/+243
| | | | | | | | | | | | | Define qapi schema for the uefi variable store state. Use it and the generated visitor helper functions to store persistent (EFI_VARIABLE_NON_VOLATILE) variables in JSON format on disk. Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-15-kraxel@redhat.com> [ incremental fix squashed in ] Message-ID: <pji24p6oag7cn2rovus7rquo7q2c6tokuquobfro2sqorky7vu@tk7cxud6jw7f>
* hw/uefi: add var-service-siglist.cGerd Hoffmann2025-03-041-0/+212
| | | | | | | | | | Functions to serialize and de-serialize EFI signature databases. This is needed to merge signature databases (happens in practice when appending dbx updates) and also to extract the certificates for pkcs7 signature verification. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-14-kraxel@redhat.com>
* hw/uefi: add var-service-pkcs7-stub.cGerd Hoffmann2025-03-041-0/+16
| | | | | | | | | | pkcs7 stub which is used in case gnutls is not available. It throws EFI_WRITE_PROTECTED errors unconditionally, so all authenticated variables are readonly for the guest. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-13-kraxel@redhat.com>
* hw/uefi: add var-service-pkcs7.cGerd Hoffmann2025-03-041-0/+436
| | | | | | | | This implements pkcs7 signature verification using gnutls. Needed to check authenticated variable updates. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-12-kraxel@redhat.com>
* hw/uefi: add var-service-core.cGerd Hoffmann2025-03-041-0/+321
| | | | | | | | | This is the core code for guest <-> host communication. This accepts request messages from the guest, dispatches them to the service called, and sends back the response message. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-11-kraxel@redhat.com>
* hw/uefi: add var-service-policy.cGerd Hoffmann2025-03-041-0/+370
| | | | | | | | | | Implement variable policies (Edk2VariablePolicyProtocol). This EFI protocol allows to define restrictions for variables. It also allows to lock down variables (disallow write access). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-10-kraxel@redhat.com>
* hw/uefi: add var-service-auth.cGerd Hoffmann2025-03-041-0/+361
| | | | | | | | | | | | | This implements authenticated variable handling (see AuthVariableLib in edk2). The by far most common use case for auth variables is secure boot. The secure boot certificate databases ('PK', 'KEK', 'db' and 'dbx') are authenticated variables, with update rules being specified in the UEFI specification. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-9-kraxel@redhat.com>
* hw/uefi: add var-service-vars.cGerd Hoffmann2025-03-041-0/+725
| | | | | | | | This is the uefi variable service (EfiSmmVariableProtocol), providing functions for listing, reading and updating variables. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-8-kraxel@redhat.com>
* hw/uefi: add var-service-utils.cGerd Hoffmann2025-03-041-0/+241
| | | | | | | | Add utility functions. Helpers for UEFI (ucs2) string handling. Helpers for readable trace messages. Compare UEFI time stamps. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-7-kraxel@redhat.com>
* hw/uefi: add var-service-guid.cGerd Hoffmann2025-03-041-0/+99
| | | | | | | Add variables for a bunch of UEFI GUIDs we will need. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-6-kraxel@redhat.com>
* Add support for etc/hardware-info fw_cfg fileGerd Hoffmann2025-03-042-0/+32
edk2 looks for the etc/hardware-info fw_cfg file to discover hardware which can not easily be found in other ways. Entries consist of a header with hardware type and entry size (HARDWARE_INFO_HEADER), followed by the actual hardware description (which is type specific). The file can have multiple entries. This patch adds the infrastructure to add entries to the file and an entry struct for simple devices (HARDWARE_INFO_SIMPLE_DEVICE) which have an mmio address only. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-ID: <20250225163031.1409078-2-kraxel@redhat.com>