Commit graph

18 commits

Author SHA1 Message Date
Gerd Hoffmann
2bc10b15de docs: add uefi variable service documentation
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250225163031.1409078-25-kraxel@redhat.com>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
69392de913 hw/uefi-vars-sysbus: add x64 variant
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>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
03223b665c hw/uefi-vars-sysbus: qemu platform bus support
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>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
5bb89df2e3 hw/uefi: add uefi-vars-sysbus device
This adds sysbus bindings for the variable service.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250225163031.1409078-19-kraxel@redhat.com>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
736ca80cdd hw/uefi: add to meson
Wire up uefi-vars in the build system.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250225163031.1409078-18-kraxel@redhat.com>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
e8371973d7 hw/uefi: add UEFI_VARS to Kconfig
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>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
9282bed590 hw/uefi: add trace-events
Add trace events for debugging and trouble shooting.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250225163031.1409078-16-kraxel@redhat.com>
2025-03-04 12:07:05 +01:00
Gerd Hoffmann
12058948ab hw/uefi: add var-service-json.c + qapi for NV vars.
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>
2025-03-04 12:02:50 +01:00
Gerd Hoffmann
f903e88306 hw/uefi: add var-service-siglist.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
4ec89b00d5 hw/uefi: add var-service-pkcs7-stub.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
3e33af2cb3 hw/uefi: add var-service-pkcs7.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
90ca4e03c2 hw/uefi: add var-service-core.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
034cb968ca hw/uefi: add var-service-policy.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
f1488fac05 hw/uefi: add var-service-auth.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
db1ecfb473 hw/uefi: add var-service-vars.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
1ebc319c8c hw/uefi: add var-service-utils.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
231b6c9ee8 hw/uefi: add var-service-guid.c
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>
2025-03-04 12:01:42 +01:00
Gerd Hoffmann
8d127aa866 Add support for etc/hardware-info fw_cfg file
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>
2025-03-04 12:01:42 +01:00