On 6/4/21 8:52 AM, Alex Bennée wrote:
DECLARE_BITMAP(kvm_supported, ARM_MAX_VQ);
- DECLARE_BITMAP(tmp, ARM_MAX_VQ);
- uint32_t vq, max_vq = 0;
-
- /* Collect the set of vector lengths supported by KVM. */
- bitmap_zero(kvm_supported, ARM_MAX_VQ);
- if (kvm_enabled() && kvm_arm_sve_supported()) {
- kvm_arm_sve_get_vls(CPU(cpu), kvm_supported);
- } else if (kvm_enabled()) {
- assert(!cpu_isar_feature(aa64_sve, cpu));
- }
+ uint32_t max_vq = 0;
+ if (kvm_enabled()) {
+ kvm_sve_get_supported_lens(cpu, kvm_supported);
+ }
Previously, kvm_supported was always initialized.
I guess this is sort-of a cleanup. But we've got 4 different checks for kvm
and tcg. I think we can actually tidy this up with a set of callbacks.
static bool do_sve_finalize(ARMCPU *cpu, Error **errp,
void (*get_supported_lens)(ARMCPU *, unsigned long *),
void (*enable_lens)(unsigned long *vq_map,
unsigned long *vq_init,
uint32_t max_vq,
unsigned long *supported),
void (*disable_lens)(unsigned long *vq_map,
unsigned long *vq_init,
unsigned long *supported,
Error **errp),
void (*validate_lens)(unsigned long *vq_map,
unsigned long *vq_init,
unsigned long *supported,
Error **errp, uint32_t max_vq))
{
...
}
bool cpu_sve_finalize_features(ARMCPU *cpu, Error **errp)
{
if (kvm_enabled()) {
return do_sve_finalize(cpu, errp,
kvm_sve_get_supported_lens,
kvm_sve_enable_lens,
kvm_sve_disable_lens,
kvm_sve_validate_lens);
} else if (tcg_enabled()) {
return do_sve_finalize(cpu, errp,
tcg_sve_get_supported_lens,
tcg_sve_enable_lens,
tcg_sve_disable_lens,
tcg_sve_validate_lens);
} else {
g_assert_not_reached(); /* ??? */
}
}
with
void tcg_sve_get_supported_lens(ARMCPU *cpu,
unsigned long *supported)
{
bitmap_fill(supported, ARM_MAX_VQ);
}
which we can later adjust for, e.g. -cpu a64fx and neoverse-v1, etc, which
don't support all vq sizes.
r~