[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC/PATCH v0 08/12] gunyah: Specific device-tree location
From: |
Srivatsa Vaddagiri |
Subject: |
[RFC/PATCH v0 08/12] gunyah: Specific device-tree location |
Date: |
Wed, 11 Oct 2023 16:52:30 +0000 |
Specify the location of device-tree and its size, as Gunyah requires the
device-tree to be parsed before VM can begin its execution.
Signed-off-by: Srivatsa Vaddagiri <quic_svaddagi@quicinc.com>
---
MAINTAINERS | 1 +
hw/arm/virt.c | 6 ++++++
include/sysemu/gunyah.h | 7 +++++++
target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++++
target/arm/meson.build | 4 ++++
5 files changed, 63 insertions(+)
create mode 100644 target/arm/gunyah.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 368ba02dce..5a51633d11 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ GUNYAH
M: Srivatsa Vaddagiri <quic_svaddagi@quicinc.com>
S: Maintained
F: accel/gunyah
+F: target/arm/gunyah.c
F: include/sysemu/gunyah.h
F: target/arm/arm_gicv3_gunyah.c
F: include/sysemu/gunyah_int.h
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0d4c5aa819..4293e01383 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1676,6 +1676,12 @@ void virt_machine_done(Notifier *notifier, void *data)
exit(1);
}
+ if (gunyah_enabled()) {
+ if (gunyah_arm_set_dtb(info->dtb_start, vms->fdt_size)) {
+ exit(1);
+ }
+ }
+
fw_cfg_add_extra_pci_roots(vms->bus, vms->fw_cfg);
virt_acpi_setup(vms);
diff --git a/include/sysemu/gunyah.h b/include/sysemu/gunyah.h
index aded49cdf6..101e190619 100644
--- a/include/sysemu/gunyah.h
+++ b/include/sysemu/gunyah.h
@@ -34,10 +34,17 @@ typedef struct GUNYAHState GUNYAHState;
DECLARE_INSTANCE_CHECKER(GUNYAHState, GUNYAH_STATE,
TYPE_GUNYAH_ACCEL)
+int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size);
+
#else /* CONFIG_GUNYAH_IS_POSSIBLE */
#define gunyah_enabled() 0
+static inline int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size)
+{
+ return -1;
+}
+
#endif /* CONFIG_GUNYAH_IS_POSSIBLE */
#endif /* QEMU_GUNYAH_H */
diff --git a/target/arm/gunyah.c b/target/arm/gunyah.c
new file mode 100644
index 0000000000..73c1c2a88a
--- /dev/null
+++ b/target/arm/gunyah.c
@@ -0,0 +1,45 @@
+/*
+ * QEMU Gunyah hypervisor support
+ *
+ * Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "sysemu/gunyah.h"
+#include "sysemu/gunyah_int.h"
+#include "linux-headers/linux/gunyah.h"
+
+/*
+ * Specify location of device-tree in guest address space.
+ *
+ * @dtb_start - Guest physical address where VM's device-tree is found
+ * @dtb_size - Size of device-tree (and any free space after it).
+ *
+ * RM or Resource Manager VM is a trusted and privileged VM that works in
+ * collaboration with Gunyah hypevisor to setup resources for a VM before it
can
+ * begin execution. One of its functions includes inspection/modification of a
+ * VM's device-tree before VM begins its execution. Modification can
+ * include specification of runtime resources allocated by hypervisor,
+ * details of which needs to be visible to VM. VM's device-tree is modified
+ * "inline" making use of "free" space that could exist at the end of device
+ * tree.
+ */
+int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size)
+{
+ int ret;
+ struct gh_vm_dtb_config dtb;
+
+ dtb.guest_phys_addr = dtb_start;
+ dtb.size = dtb_size;
+
+ ret = gunyah_vm_ioctl(GH_VM_SET_DTB_CONFIG, &dtb);
+ if (ret != 0) {
+ error_report("GH_VM_SET_DTB_CONFIG failed: %s", strerror(errno));
+ exit(1);
+ }
+
+ return 0;
+}
diff --git a/target/arm/meson.build b/target/arm/meson.build
index e645e456da..c7da15ca89 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -36,3 +36,7 @@ endif
target_arch += {'arm': arm_ss}
target_softmmu_arch += {'arm': arm_system_ss}
+
+arm_system_ss.add(when: 'CONFIG_GUNYAH', if_true: files(
+ 'gunyah.c',
+))
--
2.25.1
- [RFC/PATCH v0 00/12] Gunyah hypervisor support, Srivatsa Vaddagiri, 2023/10/11
- [RFC/PATCH v0 08/12] gunyah: Specific device-tree location,
Srivatsa Vaddagiri <=
- [RFC/PATCH v0 09/12] gunyah: Customize device-tree, Srivatsa Vaddagiri, 2023/10/11
- [RFC/PATCH v0 10/12] gunyah: CPU execution loop, Srivatsa Vaddagiri, 2023/10/11
- [RFC/PATCH v0 11/12] gunyah: Workarounds (NOT FOR MERGE), Srivatsa Vaddagiri, 2023/10/11
- [RFC/PATCH v0 02/12] update-linux-headers: Include gunyah.h, Srivatsa Vaddagiri, 2023/10/11
- [RFC/PATCH v0 03/12] gunyah: Basic support, Srivatsa Vaddagiri, 2023/10/11