Message ID | 20240109090039.1636383-8-quic_svaddagi@quicinc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Gunyah hypervisor support | expand |
Hi Srivatsa, On 9/1/24 10:00, Srivatsa Vaddagiri wrote: > 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 + > accel/stubs/gunyah-stub.c | 5 +++++ > hw/arm/virt.c | 6 ++++++ > include/sysemu/gunyah.h | 2 ++ > target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++ > target/arm/meson.build | 3 +++ > 6 files changed, 62 insertions(+) > create mode 100644 target/arm/gunyah.c (Please enable scripts/git.orderfile) > diff --git a/include/sysemu/gunyah.h b/include/sysemu/gunyah.h > index 4f26938521..a73d17bfb9 100644 > --- a/include/sysemu/gunyah.h > +++ b/include/sysemu/gunyah.h > @@ -27,4 +27,6 @@ typedef struct GUNYAHState GUNYAHState; > DECLARE_INSTANCE_CHECKER(GUNYAHState, GUNYAH_STATE, > TYPE_GUNYAH_ACCEL) > > +int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); I'm getting: In file included from hw/intc/arm_gicv3_common.c:35: include/sysemu/gunyah.h:30:24: error: unknown type name '__u64' int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); ^ include/sysemu/gunyah.h:30:41: error: unknown type name '__u64' int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); ^ 2 errors generated.
On 9/1/24 10:00, Srivatsa Vaddagiri wrote: > 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 + > accel/stubs/gunyah-stub.c | 5 +++++ > hw/arm/virt.c | 6 ++++++ > include/sysemu/gunyah.h | 2 ++ > target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++ > target/arm/meson.build | 3 +++ > 6 files changed, 62 insertions(+) > create mode 100644 target/arm/gunyah.c > 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" I'm getting on macOS: In file included from ../../target/arm/gunyah.c:13: linux-headers/linux/gunyah.h:13:10: fatal error: 'linux/types.h' file not found #include <linux/types.h> ^~~~~~~~~~~~~~~ 1 error generated. Maybe we need the following change? -- >8 -- diff --git a/meson.build b/meson.build index 6ded60063e..fb20ca04d1 100644 --- a/meson.build +++ b/meson.build @@ -712,5 +712,5 @@ endif gunyah = not_found -if get_option('gunyah').allowed() +if get_option('gunyah').allowed() and host_os == 'linux' accelerators += 'CONFIG_GUNYAH' endif ---
* Philippe Mathieu-Daud? <philmd@linaro.org> [2024-01-09 14:31:03]: > Hi Srivatsa, > > On 9/1/24 10:00, Srivatsa Vaddagiri wrote: > > 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 + > > accel/stubs/gunyah-stub.c | 5 +++++ > > hw/arm/virt.c | 6 ++++++ > > include/sysemu/gunyah.h | 2 ++ > > target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++ > > target/arm/meson.build | 3 +++ > > 6 files changed, 62 insertions(+) > > create mode 100644 target/arm/gunyah.c > > (Please enable scripts/git.orderfile) Sure will do so from the next version! > > > diff --git a/include/sysemu/gunyah.h b/include/sysemu/gunyah.h > > index 4f26938521..a73d17bfb9 100644 > > --- a/include/sysemu/gunyah.h > > +++ b/include/sysemu/gunyah.h > > @@ -27,4 +27,6 @@ typedef struct GUNYAHState GUNYAHState; > > DECLARE_INSTANCE_CHECKER(GUNYAHState, GUNYAH_STATE, > > TYPE_GUNYAH_ACCEL) > > +int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); > I'm getting: > > In file included from hw/intc/arm_gicv3_common.c:35: > include/sysemu/gunyah.h:30:24: error: unknown type name '__u64' > int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); > ^ > include/sysemu/gunyah.h:30:41: error: unknown type name '__u64' > int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); > ^ > 2 errors generated. Hmm I don't get that error when compiling on Linux. I think uint64_t will work better for all platforms where Qemu can get compiled? - vatsa
* Philippe Mathieu-Daud? <philmd@linaro.org> [2024-01-09 14:36:12]: > > +#include "qemu/osdep.h" > > +#include "qemu/error-report.h" > > +#include "sysemu/gunyah.h" > > +#include "sysemu/gunyah_int.h" > > +#include "linux-headers/linux/gunyah.h" > I'm getting on macOS: > > In file included from ../../target/arm/gunyah.c:13: > linux-headers/linux/gunyah.h:13:10: fatal error: 'linux/types.h' file not > found > #include <linux/types.h> > ^~~~~~~~~~~~~~~ > 1 error generated. > > Maybe we need the following change? > > -- >8 -- > diff --git a/meson.build b/meson.build > index 6ded60063e..fb20ca04d1 100644 > --- a/meson.build > +++ b/meson.build > @@ -712,5 +712,5 @@ endif > > gunyah = not_found > -if get_option('gunyah').allowed() > +if get_option('gunyah').allowed() and host_os == 'linux' > accelerators += 'CONFIG_GUNYAH' > endif Ok sure will include that change in my next version. - vatsa
Srivatsa Vaddagiri <quic_svaddagi@quicinc.com> writes: > * Philippe Mathieu-Daud? <philmd@linaro.org> [2024-01-09 14:31:03]: > >> Hi Srivatsa, >> >> On 9/1/24 10:00, Srivatsa Vaddagiri wrote: >> > 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 + >> > accel/stubs/gunyah-stub.c | 5 +++++ >> > hw/arm/virt.c | 6 ++++++ >> > include/sysemu/gunyah.h | 2 ++ >> > target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++ >> > target/arm/meson.build | 3 +++ >> > 6 files changed, 62 insertions(+) >> > create mode 100644 target/arm/gunyah.c >> >> (Please enable scripts/git.orderfile) > > Sure will do so from the next version! > >> >> > diff --git a/include/sysemu/gunyah.h b/include/sysemu/gunyah.h >> > index 4f26938521..a73d17bfb9 100644 >> > --- a/include/sysemu/gunyah.h >> > +++ b/include/sysemu/gunyah.h >> > @@ -27,4 +27,6 @@ typedef struct GUNYAHState GUNYAHState; >> > DECLARE_INSTANCE_CHECKER(GUNYAHState, GUNYAH_STATE, >> > TYPE_GUNYAH_ACCEL) >> > +int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); >> I'm getting: >> >> In file included from hw/intc/arm_gicv3_common.c:35: >> include/sysemu/gunyah.h:30:24: error: unknown type name '__u64' >> int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); >> ^ >> include/sysemu/gunyah.h:30:41: error: unknown type name '__u64' >> int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); >> ^ >> 2 errors generated. > > Hmm I don't get that error when compiling on Linux. I think uint64_t will work > better for all platforms where Qemu can get compiled? Yes, aside from imported headers we state: In the event that you require a specific width, use a standard type like int32_t, uint32_t, uint64_t, etc. The specific types are mandatory for VMState fields. Don't use Linux kernel internal types like u32, __u32 or __le32. in style.rst > > - vatsa
diff --git a/MAINTAINERS b/MAINTAINERS index b90a4558a1..171713bedc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -541,6 +541,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: include/sysemu/gunyah_int.h F: target/arm/arm_gicv3_gunyah.c diff --git a/accel/stubs/gunyah-stub.c b/accel/stubs/gunyah-stub.c index 1edbe1433e..faeb2af915 100644 --- a/accel/stubs/gunyah-stub.c +++ b/accel/stubs/gunyah-stub.c @@ -11,3 +11,8 @@ #include "sysemu/gunyah.h" bool gunyah_allowed; + +int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size) +{ + return -1; +} diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4f4e10c234..60fbe2f7c4 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1656,6 +1656,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 4f26938521..a73d17bfb9 100644 --- a/include/sysemu/gunyah.h +++ b/include/sysemu/gunyah.h @@ -27,4 +27,6 @@ typedef struct GUNYAHState GUNYAHState; DECLARE_INSTANCE_CHECKER(GUNYAHState, GUNYAH_STATE, TYPE_GUNYAH_ACCEL) +int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size); + #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 46b5a21eb3..797df04717 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -36,3 +36,6 @@ endif target_arch += {'arm': arm_ss} target_system_arch += {'arm': arm_system_ss} +arm_system_ss.add(when: 'CONFIG_GUNYAH', if_true: files( + 'gunyah.c', +))
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 + accel/stubs/gunyah-stub.c | 5 +++++ hw/arm/virt.c | 6 ++++++ include/sysemu/gunyah.h | 2 ++ target/arm/gunyah.c | 45 +++++++++++++++++++++++++++++++++++++++ target/arm/meson.build | 3 +++ 6 files changed, 62 insertions(+) create mode 100644 target/arm/gunyah.c