KVM: SVM: Enable AVIC by default from Zen 4
RFC 1/1 KVM: SVM: Enable AVIC by default from Zen 4
This is early RFC to understand if there are any concerns with enabling AVIC by default from Zen 4. There are a few issues related to irq window inhibits (*) that will need to be addressed before we can enable AVIC, but I wanted to understand if there are other issues that I may not be aware of. I will split up the changes and turn this into a proper patch series once there is agreement on how to proceed.
AVIC (and x2AVIC) is fully functional since Zen 4, and has so far been working well in our tests across various workloads. So, enable AVIC by default from Zen 4.
CPUs prior to Zen 4 are affected by hardware errata related to AVIC and workaround for those (erratum #1235) is only just landing upstream. So, it is unlikely that anyone was using AVIC on those CPUs. Start requiring users on those CPUs to pass force_avic=1 to explicitly enable AVIC going forward. This helps convey that AVIC isn't fully enabled (so users are aware of what they are signing up for), while allowing us to make kvm_amd module parameter 'avic' as an alias for 'enable_apicv' simplifying the code. The only downside is that force_avic taints the kernel, but if this is otherwise agreeable, the taint can be restricted to the AVIC feature bit not being enabled.
Finally, stop complaining that x2AVIC CPUID feature bit is present without basic AVIC feature bit, since that looks to be the way AVIC is being disabled on certain systems and enabling AVIC by default will start printing this warning on systems that have AVIC disabled.
(*) http://lkml.kernel.org/r/[email protected]
--- arch/x86/kvm/svm/avic.c | 11 +++++------ arch/x86/kvm/svm/svm.c | 10 +++------- 2 files changed, 8 insertions(+), 13 deletions(-)
arch/x86/kvm/svm/avic.c +5 -6
@@ -1101,12 +1101,11 @@ bool avic_hardware_setup(void)if (!npt_enabled)return false; -/* AVIC is a prerequisite for x2AVIC. */ -if (!boot_cpu_has (X86_FEATURE_AVIC ) && !force_avic) { -if (boot_cpu_has (X86_FEATURE_X2AVIC )) { -pr_warn (FW_BUG "Cannot support x2AVIC due to AVIC is disabled" ); -pr_warn (FW_BUG "Try enable AVIC using force_avic option" ); - } +if (!boot_cpu_has (X86_FEATURE_AVIC ) && !force_avic) +return false; + +if (!force_avic && (boot_cpu_data.x86 <0x19 ||boot_cpu_has (X86_FEATURE_ZEN3 ))) { +pr_warn ("AVIC disabled due to hardware errata. Use force_avic=1 if you really want to enable AVIC.\n" );return false; }
arch/x86/kvm/svm/svm.c +3 -7
@@ -158,12 +158,7 @@ module_param(lbrv, int, 0444);static int tsc_scaling = true;module_param (tsc_scaling, int,0444 ); -/* -* enable / disable AVIC. Because the defaults differ for APICv -* support between VMX and SVM we cannot use module_param_named. -*/ -static bool avic; -module_param (avic, bool,0444 ); +module_param_named (avic, enable_apicv, bool,0444 );module_param (enable_ipiv, bool,0444 );module_param (enable_device_posted_irqs, bool,0444 );
@@ -5404,7 +5399,8 @@ static __init int svm_hardware_setup(void) goto err; } - enable_apicv = avic = avic &&avic_hardware_setup (); +if (enable_apicv) + enable_apicv =avic_hardware_setup ();if (!enable_apicv) { enable_ipiv = false;
base-commit: 7ee45fdd644b138e7a213c6936474161b28d0e1a
Signature · 1 line
2.49.0
Quoted 22 lines · Naveen N Rao (AMD)
This is early RFC to understand if there are any concerns with enabling AVIC by default from Zen 4. There are a few issues related to irq window inhibits (*) that will need to be addressed before we can enable AVIC, but I wanted to understand if there are other issues that I may not be aware of. I will split up the changes and turn this into a proper patch series once there is agreement on how to proceed.
AVIC (and x2AVIC) is fully functional since Zen 4, and has so far been working well in our tests across various workloads. So, enable AVIC by default from Zen 4.
CPUs prior to Zen 4 are affected by hardware errata related to AVIC and workaround for those (erratum #1235) is only just landing upstream. So, it is unlikely that anyone was using AVIC on those CPUs. Start requiring users on those CPUs to pass force_avic=1 to explicitly enable AVIC going forward. This helps convey that AVIC isn't fully enabled (so users are aware of what they are signing up for), while allowing us to make
kvm_amdmodule parameter 'avic' as an alias for 'enable_apicv' simplifying the code. The only downside is thatforce_avictaints the kernel, but if this is otherwise agreeable, the taint can be restricted to the AVIC feature bit not being enabled.
Quoted 5 lines
Finally, stop complaining that x2AVIC CPUID feature bit is present without basic AVIC feature bit, since that looks to be the way AVIC is being disabled on certain systems and enabling AVIC by default will start printing this warning on systems that have AVIC disabled.
Hi,
IMHO making AVIC default on on Zen4 is a good idea.
About older systems, I don't know if I fully support the idea of hiding the support under force_avic, because AFAIK, other that errata #1235 there are no other significant issues with AVIC.
In fact errata #1235 is not present on Zen3, and I won't be surprised that AVIC was soft-disabled on Zen3 wrongly.
IMHO the cleanest way is probably:
On Zen2 - enable_apicv off by default, when forced to 1, activate the workaround for it. AFAIK with my workaround, there really should not be any issues, but since hardware is quite old, I am OK to keep it disabled.
On Zen3, AFAIK the errata #1235 is not present, so its likely that AVIC is fully functional as well, except that it is also disabled in IOMMU, and that one AFAIK can't be force-enabled.
I won't object if we remove force_avic altogether and just let the user also explicitly enable avic with enable_apicv=1 on Zen3 as well.
And on Zen4, enable_apicv can be true by default.
But if you insist on to have this patch instead I won't object strongly, as long as it can be enabled by the user, it doesn't matter that much.
Best regards,
Maxim Levitsky
Quoted 60 lines
(*) http://lkml.kernel.org/r/[email protected]
Signed-off-by Naveen N Rao (AMD) <[email protected]>---
arch/x86/kvm/svm/avic.c | 11 +++++------
arch/x86/kvm/svm/svm.c | 10 +++-------2 files changed, 8 insertions(+), 13 deletions(-)arch/x86/kvm/svm/avic.c +0
-0@@ -1101,12 +1101,11 @@ bool avic_hardware_setup(void) if (!npt_enabled) return false;arch/x86/kvm/svm/avic.c +5
-6-/* AVIC is a prerequisite for x2AVIC. */ -if (!boot_cpu_has (X86_FEATURE_AVIC ) && !force_avic) { -if (boot_cpu_has (X86_FEATURE_X2AVIC )) { -pr_warn (FW_BUG "Cannot support x2AVIC due to AVIC is disabled" ); -pr_warn (FW_BUG "Try enable AVIC using force_avic option" ); - } +if (!boot_cpu_has (X86_FEATURE_AVIC ) && !force_avic) +return false; + +if (!force_avic && (boot_cpu_data.x86 <0x19 ||boot_cpu_has (X86_FEATURE_ZEN3 ))) { +pr_warn ("AVIC disabled due to hardware errata. Use force_avic=1 if you really want to enable AVIC.\n" );return false;
}arch/x86/kvm/svm/svm.c +0
-0@@ -158,12 +158,7 @@ module_param(lbrv, int, 0444); static int tsc_scaling = true; module_param(tsc_scaling, int, 0444);arch/x86/kvm/svm/svm.c +1
-6-/* -* enable / disable AVIC. Because the defaults differ for APICv -* support between VMX and SVM we cannot use module_param_named. -*/ -static bool avic; -module_param (avic, bool,0444 ); +module_param_named (avic, enable_apicv, bool,0444 );module_param(enable_ipiv, bool, 0444);
module_param(enable_device_posted_irqs, bool, 0444);arch/x86/kvm/svm/svm.c +0
-0@@ -5404,7 +5399,8 @@ static __init int svm_hardware_setup(void) goto err; }arch/x86/kvm/svm/svm.c +2
-1- enable_apicv = avic = avic &&avic_hardware_setup (); +if (enable_apicv) + enable_apicv =avic_hardware_setup ();
if (!enable_apicv) {
enable_ipiv= false;base-commit:
7ee45fdd644b138e7a213c6936474161b28d0e1a
Sean Christopherson
maintainerQuoted 29 lines · On Thu, Jun 26, 2025, [email protected] wrote:
Quoted 22 lines · Naveen N Rao (AMD)
This is early RFC to understand if there are any concerns with enabling AVIC by default from Zen 4. There are a few issues related to irq window inhibits (*) that will need to be addressed before we can enable AVIC, but I wanted to understand if there are other issues that I may not be aware of. I will split up the changes and turn this into a proper patch series once there is agreement on how to proceed.
AVIC (and x2AVIC) is fully functional since Zen 4, and has so far been working well in our tests across various workloads. So, enable AVIC by default from Zen 4.
CPUs prior to Zen 4 are affected by hardware errata related to AVIC and workaround for those (erratum #1235) is only just landing upstream. So, it is unlikely that anyone was using AVIC on those CPUs. Start requiring users on those CPUs to pass force_avic=1 to explicitly enable AVIC going forward. This helps convey that AVIC isn't fully enabled (so users are aware of what they are signing up for), while allowing us to make
kvm_amdmodule parameter 'avic' as an alias for 'enable_apicv' simplifying the code. The only downside is thatforce_avictaints the kernel, but if this is otherwise agreeable, the taint can be restricted to the AVIC feature bit not being enabled.Quoted 5 lines
Finally, stop complaining that x2AVIC CPUID feature bit is present without basic AVIC feature bit, since that looks to be the way AVIC is being disabled on certain systems and enabling AVIC by default will start printing this warning on systems that have AVIC disabled.
Quoted 8 lines
Hi,
IMHO making AVIC default on on Zen4 is a good idea.
About older systems, I don't know if I fully support the idea of hiding the support under
force_avic, because AFAIK, other that errata #1235 there are no other significant issues with AVIC.
Agreed, force_avic should be reserved specifically for the case where AVIC exists in hardware, but is not enumerated in CPUID.
Quoted 2 lines
In fact errata #1235 is not present on Zen3, and I won't be surprised that AVIC was soft-disabled on Zen3 wrongly.
FWIW, the Zen3 systems I have access to don't support AVIC / APIC virtualization in the IOMMU, so it's not just AVIC being soft-disabled in the CPU.
Quoted 6 lines
IMHO the cleanest way is probably:
On Zen2 -
enable_apicvoff by default, when forced to 1, activate the workaround for it. AFAIK with my workaround, there really should not be any issues, but since hardware is quite old, I am OK to keep it disabled.
Quoted 6 lines
On Zen3, AFAIK the errata #1235 is not present, so its likely that AVIC is fully functional as well, except that it is also disabled in IOMMU, and that one AFAIK can't be force-enabled.
I won't object if we remove
force_avicaltogether and just let the user also explicitly enable avic with enable_apicv=1 on Zen3 as well.
I'm not comfortable ignoring lack of enumerated support without tainting the kernel.
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
arch/x86/kvm/svm/svm.c +6 -6
@@ -158,12 +158,9 @@ module_param(lbrv, int, 0444);static int tsc_scaling = true;module_param (tsc_scaling, int,0444 ); -/* -* enable / disable AVIC. Because the defaults differ for APICv -* support between VMX and SVM we cannot use module_param_named. -*/ -static bool avic; -module_param (avic, bool,0444 ); +/* Enable AVIC by default only for Zen4+ (negative value = default/auto). */ +static int avic =-1 ; +module_param (avic, int,0444 );module_param (enable_ipiv, bool,0444 );module_param (enable_device_posted_irqs, bool,0444 );
@@ -5404,6 +5401,9 @@ static __init int svm_hardware_setup(void) goto err; } +if (avic <0 ) + avic = boot_cpu_data.x86 >0x19 ||boot_cpu_has (X86_FEATURE_ZEN4 ); + enable_apicv = avic = avic &&avic_hardware_setup ();if (!enable_apicv) {
Quoted 39 lines · Sean Christopherson
Quoted 29 lines · On Thu, Jun 26, 2025, [email protected] wrote:
Quoted 22 lines · Naveen N Rao (AMD)
This is early RFC to understand if there are any concerns with enabling AVIC by default from Zen 4. There are a few issues related to irq window inhibits (*) that will need to be addressed before we can enable AVIC, but I wanted to understand if there are other issues that I may not be aware of. I will split up the changes and turn this into a proper patch series once there is agreement on how to proceed.
AVIC (and x2AVIC) is fully functional since Zen 4, and has so far been working well in our tests across various workloads. So, enable AVIC by default from Zen 4.
CPUs prior to Zen 4 are affected by hardware errata related to AVIC and workaround for those (erratum #1235) is only just landing upstream. So, it is unlikely that anyone was using AVIC on those CPUs. Start requiring users on those CPUs to pass force_avic=1 to explicitly enable AVIC going forward. This helps convey that AVIC isn't fully enabled (so users are aware of what they are signing up for), while allowing us to make
kvm_amdmodule parameter 'avic' as an alias for 'enable_apicv' simplifying the code. The only downside is thatforce_avictaints the kernel, but if this is otherwise agreeable, the taint can be restricted to the AVIC feature bit not being enabled.Quoted 5 lines
Finally, stop complaining that x2AVIC CPUID feature bit is present without basic AVIC feature bit, since that looks to be the way AVIC is being disabled on certain systems and enabling AVIC by default will start printing this warning on systems that have AVIC disabled.
Quoted 8 lines
Hi,
IMHO making AVIC default on on Zen4 is a good idea.
About older systems, I don't know if I fully support the idea of hiding the support under
force_avic, because AFAIK, other that errata #1235 there are no other significant issues with AVIC.
Quoted 8 lines
Agreed,
force_avicshould be reserved specifically for the case where AVIC exists in hardware, but is not enumerated in CPUID.Quoted 2 lines
In fact errata #1235 is not present on Zen3, and I won't be surprised that AVIC was soft-disabled on Zen3 wrongly.
FWIW, the Zen3 systems I have access to don't support AVIC / APIC virtualization in the IOMMU, so it's not just AVIC being soft-disabled in the CPU.
Yes, I mentioned that, but still practically speaking AVIC on Zen2 is equivalent to APICv on Intel CPUs of the same generation, and on Zen3 AVIC is equavalent to many Intel client systems which do have APICv but not posted interrupts, like my laptop (I hate this).
Quoted 11 lines
Quoted 11 lines
IMHO the cleanest way is probably:
On Zen2 -
enable_apicvoff by default, when forced to 1, activate the workaround for it. AFAIK with my workaround, there really should not be any issues, but since hardware is quite old, I am OK to keep it disabled.On Zen3, AFAIK the errata #1235 is not present, so its likely that AVIC is fully functional as well, except that it is also disabled in IOMMU, and that one AFAIK can't be force-enabled.
Quoted 5 lines
Quoted 2 lines
I won't object if we remove
force_avicaltogether and just let the user also explicitly enable avic with enable_apicv=1 on Zen3 as well.I'm not comfortable ignoring lack of enumerated support without tainting the kernel.
The kernel can still be tainted in this case, just that it is technically possible to drop force_avic, and instead just allow user to pass avic=1 instead, since it is not on by default and KVM can still print the same warning and taint the kernel when user passes avic=1 on Zen3.
Back when I implemented this, I just wanted to be a bit safer, a bit more explicit that this uses an undocumented feature.
It doesn't matter much though.
Quoted 27 lines
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
arch/x86/kvm/svm/svm.c +0
-0@@ -158,12 +158,9 @@ module_param(lbrv, int, 0444); static int tsc_scaling = true; module_param(tsc_scaling, int, 0444);arch/x86/kvm/svm/svm.c +3
-6-/* -* enable / disable AVIC. Because the defaults differ for APICv -* support between VMX and SVM we cannot use module_param_named. -*/ -static bool avic; -module_param (avic, bool,0444 ); +/* Enable AVIC by default only for Zen4+ (negative value = default/auto). */ +static int avic =-1 ; +module_param (avic, int,0444 );module_param(enable_ipiv, bool, 0444);
module_param(enable_device_posted_irqs, bool, 0444);arch/x86/kvm/svm/svm.c +0
-0@@ -5404,6 +5401,9 @@ static __init int svm_hardware_setup(void) goto err; }
Quoted 8 lines
+ if (avic < 0)
+ avic = boot_cpu_data.x86 >0x19||boot_cpu_has(X86_FEATURE_ZEN4); +
enable_apicv= avic = avic &&avic_hardware_setup();
if (!enable_apicv) {
I also have nothing against this to be honest, its OK to keep it as is IMHO.
Best regards,
Maxim Levitsky
Quoted 3 lines · On Thu, Jun 26, 2025 at 12:15 PM <[email protected]> wrote:
I also have nothing against this to be honest, its OK to keep it as is IMHO.
I would like to see it enabled by default (when appropriate) so that we get better coverage. Of course, we should not do this before we feel the code is ready.
Hi Maxim, Sean,
Thanks for the feedback!
Quoted 16 lines · On Thu, Jun 26, 2025 at 03:14:42PM -0400, [email protected] wrote:
Quoted 15 lines · Sean Christopherson
Quoted 13 lines · On Thu, Jun 26, 2025, [email protected] wrote:
On Thu, 2025-06-26 at 20:21 +0530, Naveen N Rao (AMD) wrote:
IMHO the cleanest way is probably:On Zen2 -
enable_apicvoff by default, when forced to 1, activate the workaround for it. AFAIK with my workaround, there really should not be any issues, but since hardware is quite old, I am OK to keep it disabled.On Zen3, AFAIK the errata #1235 is not present, so its likely that AVIC is fully functional as well, except that it is also disabled in IOMMU, and that one AFAIK can't be force-enabled.
I won't object if we remove
force_avicaltogether and just let the user also explicitly enable avic with enable_apicv=1 on Zen3 as well.
Quoted 7 lines
Quoted 2 lines
I'm not comfortable ignoring lack of enumerated support without tainting the kernel.
The kernel can still be tainted in this case, just that it is technically possible to drop
force_avic, and instead just allow user to pass avic=1 instead, since it is not on by default and KVM can still print the same warning and taint the kernel when user passes avic=1 on Zen3.
This will be a problem in scenarios where it is desirable to enable AVIC only if it is enabled on the system, but not otherwise. As an example, there are deployments where the 'avic' kernel module parameter is enabled fleet-wide (across Zen3/Zen4/Zen5), and it is expected that it be only enabled when supported on the system.
Quoted 8 lines
Back when I implemented this, I just wanted to be a bit safer, a bit more explicit that this uses an undocumented feature.
It doesn't matter much though.
Quoted 2 lines
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
I am wary of breaking existing users/deployments on Zen4/Zen5 enabling AVIC by specifying avic=on, or avic=true today. That's primarily the reason I chose not to change 'avic' into an integer. Also, post module load, sysfs reports the value for 'avic' as a 'Y' or 'N' today. So if there are scripts relying on that, those will break if we change 'avic' into an integer.
For Zen1/Zen2, as I mentioned, it is unlikely that anyone today is enabling AVIC and expecting it to work since the workaround is only just hitting upstream. So, I'm hoping requiring force_avic=1 should be ok with the taint removed.
Longer term, once we get wider testing with the workaround on Zen1/Zen2, we can consider relaxing the need for force_avic, at which point AVIC can be default enabled and force_avic can be limited to scenarios where AVIC support is not advertised.
Thanks,
Naveen
Sean Christopherson
maintainerQuoted 6 lines · Naveen N Rao
Quoted 6 lines
Back when I implemented this, I just wanted to be a bit safer, a bit more explicit that this uses an undocumented feature.
It doesn't matter much though.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Quoted 1 line
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
I am wary of breaking existing users/deployments on Zen4/Zen5 enabling AVIC by specifying avic=on, or avic=true today. That's primarily the reason I chose not to change 'avic' into an integer. Also, post module load, sysfs reports the value for 'avic' as a 'Y' or 'N' today. So if there are scripts relying on that, those will break if we change 'avic' into an integer.
That's easy enough to handle, e.g. see nx_huge_pages_ops for a very similar case where KVM has "auto" behavior (and a "never" case too), but otherwise treats the param like a bool.
Quoted 4 lines
For Zen1/Zen2, as I mentioned, it is unlikely that anyone today is enabling AVIC and expecting it to work since the workaround is only just hitting upstream. So, I'm hoping requiring force_avic=1 should be ok with the taint removed.
But if that's the motivation, changing the semantics of force_avic doesn't make any sense. Once the workaround lands, the only reason for force_avic to exist is to allow forcing KVM to enable AVIC even when it's not supported.
Quoted 3 lines
Longer term, once we get wider testing with the workaround on Zen1/Zen2, we can consider relaxing the need for
force_avic, at which point AVIC can be default enabled
I don't see why the default value for "avic" needs to be tied to force_avic. If we're not confident that AVIC is 100% functional and a net positive for the vast majority of setups/workloads on Zen1/Zen2, then simply leave "avic" off by default for those CPUs. If we ever want to enable AVIC by default across the board, we can simply change the default value of "avic".
But to be honest, I don't see any reason to bother trying to enable AVIC by default for Zen1/Zen2. There's a very real risk that doing so would regress existing users that have been running setups for ~6 years, and we can't fudge around AVIC being hidden on Zen3 (and the IOMMU not supporting it at all), i.e. enabling AVIC by default only for Zen4+ provides a cleaner story for end users.
Quoted 7 lines
and
force_aviccan be limited to scenarios where AVIC support is not advertised.Thanks,
Naveen
Quoted 16 lines · Sean Christopherson
Quoted 6 lines · Naveen N Rao
Quoted 6 lines
Back when I implemented this, I just wanted to be a bit safer, a bit more explicit that this uses an undocumented feature.
It doesn't matter much though.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Quoted 1 line
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
I am wary of breaking existing users/deployments on Zen4/Zen5 enabling AVIC by specifying avic=on, or avic=true today. That's primarily the reason I chose not to change 'avic' into an integer. Also, post module load, sysfs reports the value for 'avic' as a 'Y' or 'N' today. So if there are scripts relying on that, those will break if we change 'avic' into an integer.
Quoted 3 lines
That's easy enough to handle, e.g. see
nx_huge_pages_opsfor a very similar case where KVM has "auto" behavior (and a "never" case too), but otherwise treats the param like a bool.
Nice! Looks like I can re-use existing callbacks for this too:
static const struct kernel_param_ops avic_ops = {
.flags = KERNEL_PARAM_OPS_FL_NOARG,
.set = param_set_bint,
.get = param_get_bool,
};
/* enable/disable AVIC (-1 = auto) */
int avic = -1;
module_param_cb(avic, &avic_ops, &avic, 0444);
__MODULE_PARM_TYPE(avic, "bool");Quoted 9 lines
Quoted 5 lines
For Zen1/Zen2, as I mentioned, it is unlikely that anyone today is enabling AVIC and expecting it to work since the workaround is only just hitting upstream. So, I'm hoping requiring force_avic=1 should be ok with the taint removed.
But if that's the motivation, changing the semantics of
force_avicdoesn't make any sense. Once the workaround lands, the only reason forforce_avicto exist is to allow forcing KVM to enable AVIC even when it's not supported.
Indeed.
Quoted 11 lines
Quoted 4 lines
Longer term, once we get wider testing with the workaround on Zen1/Zen2, we can consider relaxing the need for
force_avic, at which point AVIC can be default enabledI don't see why the default value for "avic" needs to be tied to
force_avic. If we're not confident that AVIC is 100% functional and a net positive for the vast majority of setups/workloads on Zen1/Zen2, then simply leave "avic" off by default for those CPUs. If we ever want to enable AVIC by default across the board, we can simply change the default value of "avic".
Quoted 5 lines
But to be honest, I don't see any reason to bother trying to enable AVIC by default for Zen1/Zen2. There's a very real risk that doing so would regress existing users that have been running setups for ~6 years, and we can't fudge around AVIC being hidden on Zen3 (and the IOMMU not supporting it at all), i.e. enabling AVIC by default only for Zen4+ provides a cleaner story for end users.
Works for me. I completely agree with that.
Thanks,
Naveen
Quoted 56 lines · Naveen N Rao
Quoted 16 lines · Sean Christopherson
Quoted 6 lines · Naveen N Rao
Quoted 6 lines
Back when I implemented this, I just wanted to be a bit safer, a bit more explicit that this uses an undocumented feature.
It doesn't matter much though.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Quoted 1 line
I don't see any reason to do major surgery, just give "avic" auto -1/0/1 behavior:
I am wary of breaking existing users/deployments on Zen4/Zen5 enabling AVIC by specifying avic=on, or avic=true today. That's primarily the reason I chose not to change 'avic' into an integer. Also, post module load, sysfs reports the value for 'avic' as a 'Y' or 'N' today. So if there are scripts relying on that, those will break if we change 'avic' into an integer.
Quoted 3 lines
That's easy enough to handle, e.g. see
nx_huge_pages_opsfor a very similar case where KVM has "auto" behavior (and a "never" case too), but otherwise treats the param like a bool.Nice! Looks like I can re-use existing callbacks for this too:
static const struct kernel_param_ops avic_ops = { .flags = KERNEL_PARAM_OPS_FL_NOARG, .set = param_set_bint, .get = param_get_bool, }; /* enable/disable AVIC (-1 = auto) */ int avic = -1; module_param_cb(avic, &avic_ops, &avic, 0444); __MODULE_PARM_TYPE(avic, "bool");Quoted 9 lines
Quoted 5 lines
For Zen1/Zen2, as I mentioned, it is unlikely that anyone today is enabling AVIC and expecting it to work since the workaround is only just hitting upstream. So, I'm hoping requiring force_avic=1 should be ok with the taint removed.
But if that's the motivation, changing the semantics of
force_avicdoesn't make any sense. Once the workaround lands, the only reason forforce_avicto exist is to allow forcing KVM to enable AVIC even when it's not supported.Indeed.
Quoted 11 lines
Quoted 4 lines
Longer term, once we get wider testing with the workaround on Zen1/Zen2, we can consider relaxing the need for
force_avic, at which point AVIC can be default enabledI don't see why the default value for "avic" needs to be tied to
force_avic. If we're not confident that AVIC is 100% functional and a net positive for the vast majority of setups/workloads on Zen1/Zen2, then simply leave "avic" off by default for those CPUs. If we ever want to enable AVIC by default across the board, we can simply change the default value of "avic".
Quoted 7 lines
Quoted 5 lines
But to be honest, I don't see any reason to bother trying to enable AVIC by default for Zen1/Zen2. There's a very real risk that doing so would regress existing users that have been running setups for ~6 years, and we can't fudge around AVIC being hidden on Zen3 (and the IOMMU not supporting it at all), i.e. enabling AVIC by default only for Zen4+ provides a cleaner story for end users.
Works for me. I completely agree with that.
Some Zen3 platforms (at least Ryzen SKUs) *do* enumerate AVIC in CPUID:
Quoted 20 lines
$ cat /proc/cpuinfo | grep -E '(model[[:space:]]{2,})|family|step' | head -n3 cpu family : 25 model : 33 stepping : 2Quoted 1 line
$ cat /proc/cpuinfo | grep avic | head -n1flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxextfxsr_optpdpe1gb rdtscp lmconstant_tscrep_goodnopl xtopologynonstop_tsccpuidextd_apicidaperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16sse4_1sse4_2x2apic movbe popcnt aes xsave avx f16c rdrandlahf_lmcmp_legacysvm extapiccr8_legacyabm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoextperfctr_coreperfctr_nbbpextperfctr_llcmwaitx cpbcat_l3cdp_l3hw_pstatessbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqmrdt_ardseed adx smap clflushopt clwbsha_nixsaveopt xsavec xgetbv1 xsavescqm_llccqm_occup_llccqm_mbm_totalcqm_mbm_localuser_shstkclzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrvsvm_locknrip_savetsc_scalevmcb_cleanflushbyasid
decodeassists pausefilter pfthreshold -> avic <-v_vmsave_vmloadvgifv_spec_ctrlumip pku ospke vaes vpclmulqdq rdpidoverflow_recovsuccor smca fsrmdebug_swap
Quoted 5 lines
$ cat /sys/module/kvm_amd/parameters/force_avic N$ dmesg | grep AVIC kvm_amd: AVIC enabled
As you can see, currently AVIC works there even without force_avic=1 so why now hide it behind that parameter if errata #1235 is supposedly not present on Zen3?
Also, this platform is apparently confident enough that the AVIC silicon is working correctly there to expose it in CPUID - maybe because that's CPU stepping 2 instead of the initial 0?
Quoted 2 lines
Thanks,
Naveen
Thanks,
Maciej
Sean Christopherson
maintainerQuoted 4 lines · Maciej S. Szmigiero
On 18.07.2025 10:19, Naveen N Rao wrote:
As you can see, currently AVIC works there even without force_avic=1 so why now hide it behind that parameter if errata #1235 is supposedly not present on Zen3?
Yeah, I'm aligned with keeping the current semantics for force_avic (and by extension for avic), and I'm pretty sure Naveen is as well.
Quoted 3 lines
Also, this platform is apparently confident enough that the AVIC silicon is working correctly there to expose it in CPUID - maybe because that's CPU stepping 2 instead of the initial 0?
My vote is still to only enable AVIC by default for Zen4+. The story for Zen3 and earlier is just too messy.