Skip to contentSkip to conversation

KVM: SVM: Fix an off-by-one typo in the comment for enabling AVIC by default

PATCH Superseded Sean Christopherson 2 participants 3 messages Jan 7 – Jan 8

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

PATCH 1/1 KVM: SVM: Fix an off-by-one typo in the comment for enabling AVIC by default

Fix a goof in the comment that documents KVM's logic for enabling AVIC by default to reference Zen5+ as family 0x1A (Zen5), not family 0x19 (Zen4). The code is correct (checks for _greater_ than 0x19), only the comment is flawed.

Fixes ca2967de5a5b ("KVM: SVM: Enable AVIC by default for Zen4+ if x2AVIC is support")
Cc Naveen N Rao (AMD) <[email protected]>
---
 arch/x86/kvm/svm/avic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/avic.c +1 -1
index 6b77b2033208..7e62d05c2136 100644
@@ -1224,7 +1224,7 @@ static bool __init avic_want_avic_enabled(void)
 	 * In "auto" mode, enable AVIC by default for Zen4+ if x2AVIC is
 	 * supported (to avoid enabling partial support by default, and because
 	 * x2AVIC should be supported by all Zen4+ CPUs).  Explicitly check for
-	 * family 0x19 and later (Zen5+), as the kernel's synthetic ZenX flags
+	 * family 0x1A and later (Zen5+), as the kernel's synthetic ZenX flags
 	 * aren't inclusive of previous generations, i.e. the kernel will set
 	 * at most one ZenX feature flag.
 	 */

base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578

Signature · 1 line
2.52.0.351.gbe84eed79e-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Sean Christopherson

Fix a goof in the comment that documents KVM's logic for enabling AVIC by default to reference Zen5+ as family 0x1A (Zen5), not family 0x19 (Zen4). The code is correct (checks for _greater_ than 0x19), only the comment is flawed.

I had thought that the comment was correct and that you wanted to reference Zen4 there. That is:

	family 0x19 (Zen4) and later (Zen5+),

Though family 0x19 also includes Zen3 :/

I think it would be better to update the code as well, just so it is easier to correlate the comment and the code?

        if (avic == AVIC_AUTO_MODE)
                avic = boot_cpu_has(X86_FEATURE_X2AVIC) &&

- (boot_cpu_data.x86 > 0x19 || cpu_feature_enabled(X86_FEATURE_ZEN4));
+ (cpu_feature_enabled(X86_FEATURE_ZEN4) || boot_cpu_data.x86 >= 0x1A);

        if (!avic || !npt_enabled)
		return false;
Quoted 7 lines
Fixes ca2967de5a5b ("KVM: SVM: Enable AVIC by default for Zen4+ if x2AVIC is support")
Cc Naveen N Rao (AMD) <[email protected]>
---
 arch/x86/kvm/svm/avic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regardless of that, this change is accurate:

Quoted 15 lines
arch/x86/kvm/svm/avic.c +1 -1
index 6b77b2033208..7e62d05c2136 100644
@@ -1224,7 +1224,7 @@ static bool __init avic_want_avic_enabled(void)
 	 * In "auto" mode, enable AVIC by default for Zen4+ if x2AVIC is
 	 * supported (to avoid enabling partial support by default, and because
 	 * x2AVIC should be supported by all Zen4+ CPUs).  Explicitly check for
-	 * family 0x19 and later (Zen5+), as the kernel's synthetic ZenX flags
+	 * family 0x1A and later (Zen5+), as the kernel's synthetic ZenX flags
 	 * aren't inclusive of previous generations, i.e. the kernel will set
 	 * at most one ZenX feature flag.
 	 */
Quoted 4 lines

base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578

Signature · 1 line
2.52.0.351.gbe84eed79e-goog

- Naveen

author maintainer
#2 lore raw
Quoted 17 lines · Naveen N Rao
Quoted 4 lines · Sean Christopherson

Fix a goof in the comment that documents KVM's logic for enabling AVIC by default to reference Zen5+ as family 0x1A (Zen5), not family 0x19 (Zen4). The code is correct (checks for _greater_ than 0x19), only the comment is flawed.

I had thought that the comment was correct and that you wanted to reference Zen4 there. That is:

	family 0x19 (Zen4) and later (Zen5+),

Though family 0x19 also includes Zen3 :/

I think it would be better to update the code as well, just so it is easier to correlate the comment and the code?

        if (avic == AVIC_AUTO_MODE)
                avic = boot_cpu_has(X86_FEATURE_X2AVIC) &&

Review

Quoted 2 lines
(quoted diff) +1 -1
-                      (boot_cpu_data.x86 > 0x19 || cpu_feature_enabled(X86_FEATURE_ZEN4));
+                      (cpu_feature_enabled(X86_FEATURE_ZEN4) || boot_cpu_data.x86 >= 0x1A);

This thought crossed my mind as well. I'll send a v2 with this, I especially like the idea of swapping the ordering so that the checks are "ascending".