[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 08/26] hw/core/loader: Add ROM loader notifier
From: |
Jean-Philippe Brucker |
Subject: |
[PATCH v3 08/26] hw/core/loader: Add ROM loader notifier |
Date: |
Mon, 25 Nov 2024 19:56:07 +0000 |
Add a function to register a notifier, that is invoked after a ROM gets
loaded into guest memory.
It will be used by Arm confidential guest support, in order to register
all blobs loaded into memory with KVM, so that their content is moved
into Realm state and measured into the initial VM state.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
include/hw/loader.h | 15 +++++++++++++++
hw/core/loader.c | 15 +++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 7f6d06b956..0cd9905f97 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -353,6 +353,21 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t
size);
ssize_t rom_add_vga(const char *file);
ssize_t rom_add_option(const char *file, int32_t bootindex);
+typedef struct RomLoaderNotify {
+ /* Parameters passed to rom_add_blob() */
+ hwaddr addr;
+ size_t len;
+ size_t max_len;
+} RomLoaderNotify;
+
+/**
+ * rom_add_load_notifier - Add a notifier for loaded images
+ *
+ * Add a notifier that will be invoked with a RomLoaderNotify structure for
each
+ * blob loaded into guest memory, after the blob is loaded.
+ */
+void rom_add_load_notifier(Notifier *notifier);
+
/* This is the usual maximum in uboot, so if a uImage overflows this, it would
* overflow on real hardware too. */
#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 31593a1171..759a62cf58 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -67,6 +67,8 @@
#include <zlib.h>
static int roms_loaded;
+static NotifierList rom_loader_notifier =
+ NOTIFIER_LIST_INITIALIZER(rom_loader_notifier);
/* return the size or -1 if error */
int64_t get_image_size(const char *filename)
@@ -1179,6 +1181,11 @@ MemoryRegion *rom_add_blob(const char *name, const void
*blob, size_t len,
return mr;
}
+void rom_add_load_notifier(Notifier *notifier)
+{
+ notifier_list_add(&rom_loader_notifier, notifier);
+}
+
/* This function is specific for elf program because we don't need to allocate
* all the rom. We just allocate the first part and the rest is just zeros.
This
* is why romsize and datasize are different. Also, this function takes its own
@@ -1220,6 +1227,7 @@ ssize_t rom_add_option(const char *file, int32_t
bootindex)
static void rom_reset(void *unused)
{
Rom *rom;
+ RomLoaderNotify notify;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
@@ -1268,6 +1276,13 @@ static void rom_reset(void *unused)
cpu_flush_icache_range(rom->addr, rom->datasize);
trace_loader_write_rom(rom->name, rom->addr, rom->datasize,
rom->isrom);
+
+ notify = (RomLoaderNotify) {
+ .addr = rom->addr,
+ .len = rom->datasize,
+ .max_len = rom->romsize,
+ };
+ notifier_list_notify(&rom_loader_notifier, ¬ify);
}
}
--
2.47.0
- [PATCH v3 07/26] target/arm/kvm: Create scratch VM as Realm if necessary, (continued)
- [PATCH v3 07/26] target/arm/kvm: Create scratch VM as Realm if necessary, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 06/26] target/arm/kvm-rme: Initialize vCPU, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 04/26] target/arm/kvm-rme: Initialize realm, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 10/26] target/arm/kvm-rme: Add Realm Personalization Value parameter, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 09/26] target/arm/kvm-rme: Initialize Realm memory, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 11/26] target/arm/kvm-rme: Add measurement algorithm property, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 12/26] target/arm/cpu: Set number of breakpoints and watchpoints in KVM, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 13/26] target/arm/cpu: Set number of PMU counters in KVM, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 14/26] target/arm/cpu: Inform about reading confidential CPU registers, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 16/26] hw/arm/virt: Disable DTB randomness for confidential VMs, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 08/26] hw/core/loader: Add ROM loader notifier,
Jean-Philippe Brucker <=
- [PATCH v3 19/26] hw/arm/virt: Move virt_flash_create() to machvirt_init(), Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 15/26] hw/arm/virt: Add support for Arm RME, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 17/26] hw/arm/virt: Reserve one bit of guest-physical address for RME, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 18/26] hw/arm/boot: Mark all guest memory as RIPAS_RAM., Jean-Philippe Brucker, 2024/11/25
- [RFC PATCH v3 21/26] hw/arm/boot: Load DTB as is for confidential VMs, Jean-Philippe Brucker, 2024/11/25
- [RFC PATCH v3 22/26] hw/arm/boot: Skip bootloader for confidential guests, Jean-Philippe Brucker, 2024/11/25
- [RFC PATCH v3 24/26] hw/core/loader: Add fields to RomLoaderNotify, Jean-Philippe Brucker, 2024/11/25
- [RFC PATCH v3 26/26] hw/arm/virt: Add measurement log for confidential boot, Jean-Philippe Brucker, 2024/11/25
- [RFC PATCH v3 23/26] hw/tpm: Add TPM event log, Jean-Philippe Brucker, 2024/11/25
- [PATCH v3 20/26] hw/arm/virt: Use RAM instead of flash for confidential guest firmware, Jean-Philippe Brucker, 2024/11/25