Hi Mathieu,
On 7/8/26 8:42 AM, Mathieu Poirier wrote:
From: Jean-Philippe Brucker <[email protected]>
Initialise the Realm's initial physical address space based on
the VM's configuration.
Signed-off-by: Jean-Philippe Brucker <[email protected]>
Signed-off-by: Mathieu Poirier <[email protected]>
---
hw/arm/boot.c | 4 ++++
target/arm/kvm-rme.c | 18 ++++++++++++++++++
target/arm/kvm-stub.c | 4 ++++
target/arm/kvm_arm.h | 10 ++++++++++
4 files changed, 36 insertions(+)
Thanks for the posting.
If RmeGuest::init_ram isn't needed in the future, this patch can be dropped.
There is no API exposed from (v14) host series to initialize RIPAS for the
specified IPA range, as we did in the earlier revisions. So this patch was
added for the earlier host serieses, not for (v14) host series any more?
Thanks,
Gavin
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 9b7553dde5e1..bcab21d349b4 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -32,6 +32,7 @@
#include "qemu/option.h"
#include "qemu/units.h"
#include "qemu/bswap.h"
+#include "kvm_arm.h"
/* Kernel boot protocol is specified in the kernel docs
* Documentation/arm/Booting and Documentation/arm64/booting.txt
@@ -1210,6 +1211,9 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms,
struct arm_boot_info *info)
/* We assume the CPU passed as argument is the primary CPU. */
info->primary_cpu = cpu;
+ /* Mark all Realm memory as RAM */
+ kvm_arm_rme_init_guest_ram(info->loader_start, info->ram_size);
+
/* Load the kernel. */
if (!info->kernel_filename || info->firmware_loaded) {
arm_setup_firmware_boot(cpu, info);
diff --git a/target/arm/kvm-rme.c b/target/arm/kvm-rme.c
index f763d5ed6199..697e7d507f0d 100644
--- a/target/arm/kvm-rme.c
+++ b/target/arm/kvm-rme.c
@@ -22,8 +22,16 @@
#define TYPE_RME_GUEST "rme-guest"
OBJECT_DECLARE_SIMPLE_TYPE(RmeGuest, RME_GUEST)
+#define RME_PAGE_SIZE qemu_real_host_page_size()
+
+typedef struct {
+ hwaddr base;
+ hwaddr size;
+} RmeRamRegion;
+
struct RmeGuest {
ConfidentialGuestSupport parent_obj;
+ RmeRamRegion init_ram;
};
OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(RmeGuest, rme_guest, RME_GUEST,
@@ -91,6 +99,16 @@ int kvm_arm_rme_init(MachineState *ms, KVMState *s)
return 0;
}
+void kvm_arm_rme_init_guest_ram(hwaddr base, size_t size)
+{
+ if (!rme_guest) {
+ return;
+ }
+
+ rme_guest->init_ram.base = base;
+ rme_guest->init_ram.size = size;
+}
+
void kvm_arm_rme_vcpu_init(ARMCPU *cpu)
{
if (!rme_guest) {
diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c
index 6d52f172c5df..790e1940fd8a 100644
--- a/target/arm/kvm-stub.c
+++ b/target/arm/kvm-stub.c
@@ -42,6 +42,10 @@ bool kvm_arm_el2_supported(void)
return false;
}
+void kvm_arm_rme_init_guest_ram(hwaddr base, size_t size)
+{
+}
+
/*
* These functions should never actually be called without KVM support.
*/
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index 65ec1b970606..c7dc45595159 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -267,4 +267,14 @@ void kvm_arm_rme_vcpu_init(ARMCPU *cpu);
*/
int kvm_arm_rme_vm_type(void);
+/*
+ * kvm_arm_rme_init_guest_ram
+ * @base: base address of RAM
+ * @size: size of RAM
+ *
+ * If the user requested a Realm, set the base and size of guest RAM, in order
+ * to initialize the Realm IPA space.
+ */
+void kvm_arm_rme_init_guest_ram(hwaddr base, size_t size);
+
#endif