On Tue, Oct 13, 2026 at 05:46:21PM +0100, Peter Maydell wrote: > On Thu, 1 Oct 2026 at 11:52, Aastha Rawat > <[email protected]> wrote: > > > > Replace the compile-time #if/#elif preprocessor ladder in > > aarch64_host_initfn() with runtime calls and add mshv_enabled() to it. > > This ensures the correct accelerator is selected at runtime when > > multiple accelerators are compiled in. > > > > Add CONFIG_MSHV to the aarch64_cpus[] guard so that mshv accelerator can > > register the "host" CPU type. > > Don't do two things in one commit, please.
Sure, this will be split into two commits in the next revision. > > Signed-off-by: Aastha Rawat <[email protected]> > > --- > > target/arm/cpu64.c | 25 +++++++++++++++---------- > > 1 file changed, 15 insertions(+), 10 deletions(-) > > > > diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c > > index dcd0d698b3..a9e346049d 100644 > > --- a/target/arm/cpu64.c > > +++ b/target/arm/cpu64.c > > @@ -811,17 +811,21 @@ void aarch64_host_initfn(Object *obj) > > } > > #endif > > > > + if (mshv_enabled()) { > > + mshv_arm_set_cpu_features_from_host(cpu); > > + } else if (kvm_enabled()) { > > #if defined(CONFIG_KVM) > > - kvm_arm_set_cpreg_mig_tolerances(cpu); > > - kvm_arm_set_cpu_features_from_host(cpu); > > - aarch64_add_sve_properties(obj); > > -#elif defined(CONFIG_HVF) > > - hvf_arm_set_cpu_features_from_host(cpu); > > -#elif defined(CONFIG_WHPX) > > - whpx_arm_set_cpu_features_from_host(cpu); > > -#else > > - g_assert_not_reached(); > > + kvm_arm_set_cpreg_mig_tolerances(cpu); > > #endif > > + kvm_arm_set_cpu_features_from_host(cpu); > > + aarch64_add_sve_properties(obj); > > + } else if (hvf_enabled()) { > > + hvf_arm_set_cpu_features_from_host(cpu); > > + } else if (whpx_enabled()) { > > + whpx_arm_set_cpu_features_from_host(cpu); > > + } else { > > + g_assert_not_reached(); > > + } > > The reason for the ifdefs is that if CONFIG_HVF etc aren't > set then the functions hvf_arm_set_cpu_features_from_host() > don't exist... Yeah, the compile guards should continue to exist. The old ladder was valid for one relevant accelerator backend per host build. MSHV can be built alongside KVM on Linux, so this can be something like: #if defined(CONFIG_MSHV) if (mshv_enabled()) { mshv_arm_set_cpu_features_from_host(cpu); goto add_common_properties; } #endif #if defined(CONFIG_KVM) if (kvm_enabled()) { kvm_arm_set_cpreg_mig_tolerances(cpu); kvm_arm_set_cpu_features_from_host(cpu); aarch64_add_sve_properties(obj); goto add_common_properties; } #endif #if defined(CONFIG_HVF) if (hvf_enabled()) { hvf_arm_set_cpu_features_from_host(cpu); goto add_common_properties; } #endif #if defined(CONFIG_WHPX) if (whpx_enabled()) { whpx_arm_set_cpu_features_from_host(cpu); goto add_common_properties; } #endif g_assert_not_reached(); #if defined(CONFIG_KVM) || defined(CONFIG_HVF) || \ defined(CONFIG_WHPX) || defined(CONFIG_MSHV) add_common_properties: #endif if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { aarch64_add_pauth_properties(obj); } The runtime checks will select the accelerator actually chosen for the VM when multiple accelerators, such as KVM and MSHV, are compiled together. Thanks, Aastha
