From: Shameer Kolothum <shameerali.kolothum.th...@huawei.com> Introduce a QAPI‐defined struct (and its array) for target implementation CPUs. This enables specifying target implementation CPU parameters via -machine, for example:
-M virt, \ impl-cpu.0.midr=1,impl-cpu.0.revidr=1,impl-cpu.0.aidr=1, \ impl-cpu.1.midr=2,impl-cpu.1.revidr=2,impl-cpu.1.aidr=0 Subsequent patch will make use of this by using object_property_add(), allowing users to configure each target CPU’s midr, revidr, and aidr fields directly from the command line. While at it, also provide a helper function to set the target CPUs. Signed-off-by: Shameer Kolothum <shameerali.kolothum.th...@huawei.com> --- qapi/machine.json | 34 ++++++++++++++++++++++++++++++++++ target/arm/kvm.c | 16 ++++++++++++++++ target/arm/kvm_arm.h | 8 ++++++++ 3 files changed, 58 insertions(+) diff --git a/qapi/machine.json b/qapi/machine.json index a6b8795b09..d6e0e3b2e3 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1898,3 +1898,37 @@ { 'command': 'x-query-interrupt-controllers', 'returns': 'HumanReadableText', 'features': [ 'unstable' ]} + +## +# @ArmTargetImplCPU: +# +# Info for a single target implementation CPU. +# +# @midr: MIDR value +# @revidr: REVIDR value +# @aidr: AIDR value +# +# Since: 10.2 +## +{ 'struct': 'ArmTargetImplCPU', + 'data': { + 'midr': 'uint64', + 'revidr': 'uint64', + 'aidr': 'uint64' + } +} + +## +# @ArmTargetImplCPUs: +# +# List of target implementation CPUs. +# +# @target-cpus: List of ArmTargetImplCPU entries. +# +# Since: 10.2 +## +{ 'struct': 'ArmTargetImplCPUs', + 'data': { + 'target-cpus': ['ArmTargetImplCPU'] + } +} diff --git a/target/arm/kvm.c b/target/arm/kvm.c index eb04640b50..8f325c4ca4 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -66,6 +66,9 @@ typedef struct ARMHostCPUFeatures { static ARMHostCPUFeatures arm_host_cpu_features; +static uint64_t target_impl_cpus_num; +static ArmTargetImplCPU *target_impl_cpus; + /** * kvm_arm_vcpu_init: * @cpu: ARMCPU @@ -2816,3 +2819,16 @@ void kvm_arm_enable_mte(Object *cpuobj, Error **errp) cpu->kvm_mte = true; } } + +bool kvm_arm_set_target_impl_cpus(uint64_t num, ArmTargetImplCPU *cpus) +{ + + if (target_impl_cpus_num) { + return false; + } + + target_impl_cpus_num = num; + target_impl_cpus = cpus; + + return true; +} diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 3cd6447901..8754302333 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -244,6 +244,8 @@ void kvm_arm_enable_mte(Object *cpuobj, Error **errp); int kvm_arm_get_writable_id_regs(ARMCPU *cpu, IdRegMap *idregmap); +bool kvm_arm_set_target_impl_cpus(uint64_t num, ArmTargetImplCPU *cpus); + #else /* @@ -280,6 +282,12 @@ static inline int kvm_arm_get_writable_id_regs(ARMCPU *cpu, IdRegMap *idregmap) return -ENOSYS; } +static inline +bool kvm_arm_set_target_impl_cpus(uint64_t num, ArmTargetImplCPU *cpus) +{ + return false; +} + /* * These functions should never actually be called without KVM support. */ -- 2.34.1