On 9/13/21 1:07 AM, Alexander Graf wrote:
> Now that we have working system register sync, we push more target CPU
> properties into the virtual machine. That might be useful in some
> situations, but is not the typical case that users want.
>
> So let's add a -cpu host option that allows them to explicitly pass all
> CPU capabilities of their host CPU into the guest.
>
> Signed-off-by: Alexander Graf <[email protected]>
> Acked-by: Roman Bolshakov <[email protected]>
> Reviewed-by: Sergio Lopez <[email protected]>
> ---
> target/arm/cpu.c | 9 ++++--
> target/arm/cpu.h | 2 ++
> target/arm/hvf/hvf.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
> target/arm/hvf_arm.h | 19 +++++++++++
> target/arm/kvm_arm.h | 2 --
> 5 files changed, 104 insertions(+), 4 deletions(-)
> create mode 100644 target/arm/hvf_arm.h
>
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> @@ -2058,15 +2059,19 @@ static void arm_cpu_class_init(ObjectClass *oc, void
> *data)
> #endif /* CONFIG_TCG */
> }
>
> -#ifdef CONFIG_KVM
> +#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
> static void arm_host_initfn(Object *obj)
> {
> ARMCPU *cpu = ARM_CPU(obj);
>
> +#ifdef CONFIG_KVM
> kvm_arm_set_cpu_features_from_host(cpu);
> if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> aarch64_add_sve_properties(obj);
> }
> +#else
> + hvf_arm_set_cpu_features_from_host(cpu);
> +#endif
Could be cleaner as ARMCPUClass::set_cpu_features_from_host()?