From: Jean-Philippe Brucker <[email protected]> When a Realm is requested, create a scratch Realm VM by setting bit 30 of the argument given to the KVM_CREATE_VM ioctl(). Bit 7-0 are reserved for the guest PA size.
Signed-off-by: Jean-Philippe Brucker <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> --- target/arm/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 941951a9bc05..63a3e78efd53 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -110,6 +110,8 @@ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, struct kvm_vcpu_init *init, Error **errp) { int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1; + MachineState *ms = MACHINE(qdev_get_machine()); + int vm_type = ms->cgs ? KVM_VM_TYPE_ARM_REALM : KVM_VM_TYPE_ARM_NORMAL; int max_vm_pa_size; kvmfd = qemu_open_old("/dev/kvm", O_RDWR); @@ -122,7 +124,7 @@ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, max_vm_pa_size = 0; } do { - vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size); + vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size | vm_type); } while (vmfd == -1 && errno == EINTR); if (vmfd < 0) { error_setg_errno(errp, errno, "Failed to create the scratch VM"); -- 2.53.0
