diff mbox series

[RFC,15/16] target/arm/kvm: Disable Realm reboot

Message ID 20230127150727.612594-16-jean-philippe@linaro.org
State New
Headers show
Series arm: Run Arm CCA VMs with KVM | expand

Commit Message

Jean-Philippe Brucker Jan. 27, 2023, 3:07 p.m. UTC
A realm cannot be reset, it must be recreated from scratch. The RMM
specification defines states of a Realm as NEW -> ACTIVE -> SYSTEM_OFF,
after which the Realm can only be destroyed. A PCSI_SYSTEM_RESET call,
which normally reboots the system, puts the Realm in SYSTEM_OFF state.

QEMU does not support recreating a VM. Normally, a reboot request by the
guest causes all devices to reset, which cannot work for a Realm.
Indeed, loading images into Realm memory and changing the PC is only
allowed for a Realm in NEW state. Resetting the images for a Realm in
SYSTEM_OFF state will cause QEMU to crash with a bus error.

Handle reboot requests by the guest more gracefully, by indicating to
runstate.c that the vCPUs of a Realm are not resettable, and that QEMU
should exit.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 target/arm/kvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Richard Henderson Jan. 28, 2023, 12:35 a.m. UTC | #1
On 1/27/23 05:07, Jean-Philippe Brucker wrote:
> A realm cannot be reset, it must be recreated from scratch. The RMM
> specification defines states of a Realm as NEW -> ACTIVE -> SYSTEM_OFF,
> after which the Realm can only be destroyed. A PCSI_SYSTEM_RESET call,
> which normally reboots the system, puts the Realm in SYSTEM_OFF state.
> 
> QEMU does not support recreating a VM. Normally, a reboot request by the
> guest causes all devices to reset, which cannot work for a Realm.
> Indeed, loading images into Realm memory and changing the PC is only
> allowed for a Realm in NEW state. Resetting the images for a Realm in
> SYSTEM_OFF state will cause QEMU to crash with a bus error.
> 
> Handle reboot requests by the guest more gracefully, by indicating to
> runstate.c that the vCPUs of a Realm are not resettable, and that QEMU
> should exit.
> 
> Signed-off-by: Jean-Philippe Brucker<jean-philippe@linaro.org>
> ---
>   target/arm/kvm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index d8655d9041..02b5e8009f 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -1071,7 +1071,8 @@  int kvm_arch_msi_data_to_gsi(uint32_t data)
 
 bool kvm_arch_cpu_check_are_resettable(void)
 {
-    return true;
+    /* A Realm cannot be reset */
+    return !kvm_arm_rme_enabled();
 }
 
 void kvm_arch_accel_class_init(ObjectClass *oc)