@@ -945,6 +945,9 @@ struct ArchCPU {
OnOffAuto kvm_steal_time;
#endif /* CONFIG_KVM */
+ /* Realm Management Extension */
+ bool kvm_rme;
+
/* Uniprocessor system with MP extensions */
bool mp_is_up;
@@ -220,6 +220,7 @@ int kvm_arm_rme_init(MachineState *ms);
int kvm_arm_rme_vm_type(MachineState *ms);
bool kvm_arm_rme_enabled(void);
+int kvm_arm_rme_vcpu_init(CPUState *cs);
#else
@@ -106,6 +106,16 @@ int kvm_arm_rme_init(MachineState *ms)
return 0;
}
+int kvm_arm_rme_vcpu_init(CPUState *cs)
+{
+ ARMCPU *cpu = ARM_CPU(cs);
+
+ if (rme_guest) {
+ cpu->kvm_rme = true;
+ }
+ return 0;
+}
+
int kvm_arm_rme_vm_type(MachineState *ms)
{
if (rme_guest) {
@@ -1920,6 +1920,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
return ret;
}
+ ret = kvm_arm_rme_vcpu_init(cs);
+ if (ret) {
+ return ret;
+ }
+
if (cpu_isar_feature(aa64_sve, cpu)) {
ret = kvm_arm_sve_set_vls(cpu);
if (ret) {
@@ -2056,6 +2061,35 @@ static int kvm_arch_put_sve(CPUState *cs)
return 0;
}
+static int kvm_arm_rme_put_core_regs(CPUState *cs)
+{
+ int i, ret;
+ struct kvm_one_reg reg;
+ ARMCPU *cpu = ARM_CPU(cs);
+ CPUARMState *env = &cpu->env;
+
+ /*
+ * The RME ABI only allows us to set 8 GPRs and the PC
+ */
+ for (i = 0; i < 8; i++) {
+ reg.id = AARCH64_CORE_REG(regs.regs[i]);
+ reg.addr = (uintptr_t) &env->xregs[i];
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ reg.id = AARCH64_CORE_REG(regs.pc);
+ reg.addr = (uintptr_t) &env->pc;
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
+ if (ret) {
+ return ret;
+ }
+
+ return 0;
+}
+
static int kvm_arm_put_core_regs(CPUState *cs, int level)
{
uint64_t val;
@@ -2066,6 +2100,10 @@ static int kvm_arm_put_core_regs(CPUState *cs, int level)
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
+ if (cpu->kvm_rme) {
+ return kvm_arm_rme_put_core_regs(cs);
+ }
+
/* If we are in AArch32 mode then we need to copy the AArch32 regs to the
* AArch64 registers before pushing them out to 64-bit KVM.
*/
@@ -2253,6 +2291,25 @@ static int kvm_arch_get_sve(CPUState *cs)
return 0;
}
+static int kvm_arm_rme_get_core_regs(CPUState *cs)
+{
+ int i, ret;
+ struct kvm_one_reg reg;
+ ARMCPU *cpu = ARM_CPU(cs);
+ CPUARMState *env = &cpu->env;
+
+ for (i = 0; i < 8; i++) {
+ reg.id = AARCH64_CORE_REG(regs.regs[i]);
+ reg.addr = (uintptr_t) &env->xregs[i];
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static int kvm_arm_get_core_regs(CPUState *cs)
{
uint64_t val;
@@ -2263,6 +2320,10 @@ static int kvm_arm_get_core_regs(CPUState *cs)
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
+ if (cpu->kvm_rme) {
+ return kvm_arm_rme_get_core_regs(cs);
+ }
+
for (i = 0; i < 31; i++) {
ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]),
&env->xregs[i]);
The target code calls kvm_arm_vcpu_init() to mark the vCPU as part of a Realm. For a Realm vCPU, only x0-x7 can be set at runtime. Before boot, the PC can also be set, and is ignored at runtime. KVM also accepts a few system register changes during initial configuration, as returned by KVM_GET_REG_LIST. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> --- v1->v2: only do the GP regs, since they are sync'd explicitly. Other registers use the existing reglist facility. --- target/arm/cpu.h | 3 +++ target/arm/kvm_arm.h | 1 + target/arm/kvm-rme.c | 10 ++++++++ target/arm/kvm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+)