Use KVM_CAP_PPC_AIL_MODE_3 to determine cap-ail-mode-3 support for KVM guests. Keep the fallback heuristic for KVM hosts that pre-date this CAP.
This is only proposed the KVM CAP has not yet been allocated. I will ask to merge the new KVM cap when there are no objections on the QEMU side. not-yet-Signed-off-by: Nicholas Piggin <npig...@gmail.com> --- Since v1: - Remove incorrect test for unsupported cap query. Add comment instead. linux-headers/linux/kvm.h | 1 + target/ppc/kvm.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 02c5e7b7bb..d91f578200 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1130,6 +1130,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_BINARY_STATS_FD 203 #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 #define KVM_CAP_ARM_MTE 205 +#define KVM_CAP_PPC_AIL_MODE_3 210 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 1338c41f8f..7f71f78253 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -90,6 +90,7 @@ static int cap_ppc_nested_kvm_hv; static int cap_large_decr; static int cap_fwnmi; static int cap_rpt_invalidate; +static int cap_ail_mode_3; static uint32_t debug_inst_opcode; @@ -154,6 +155,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } cap_rpt_invalidate = kvm_vm_check_extension(s, KVM_CAP_PPC_RPT_INVALIDATE); + cap_ail_mode_3 = kvm_vm_check_extension(s, KVM_CAP_PPC_AIL_MODE_3); kvm_ppc_register_host_cpu_type(); return 0; @@ -2567,6 +2569,17 @@ bool kvmppc_supports_ail_3(void) { PowerPCCPUClass *pcc = kvm_ppc_get_host_cpu_class(); + if (cap_ail_mode_3) { + return 1; + } + + /* + * cap-ail-mode-3 is disabled, but it may be because the KVM host pre-dates + * the cap. Special-case the test because the performance cost for + * disabling the feature unconditionally is prohibitive until updated + * KVM is widely in use. + */ + /* * KVM PR only supports AIL-0 */ @@ -2589,6 +2602,11 @@ bool kvmppc_supports_ail_3(void) return 0; } + /* + * Beyond ISA v3.1 (POWER10), this could return 0, because all KVM + * implementations for such hosts would support the cap. + */ + return 1; } -- 2.23.0