From: Sean Christopherson <seanjc@google.com>
To: Naveen N Rao <naveen@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>,
Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
Joao Martins <joao.m.martins@oracle.com>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
Subject: Re: [RFC PATCH v2 5/5] KVM: SVM: Enable AVIC by default from Zen 4
Date: Tue, 16 Sep 2025 07:27:48 -0700 [thread overview]
Message-ID: <aMlz5NTt_YA9foOc@google.com> (raw)
In-Reply-To: <p4gvfidvfrfpwy6p6cmua3pnm7efigjrbwipsoga7swpz3nmyl@t3ojdu4qx3w6>
On Tue, Sep 16, 2025, Naveen N Rao wrote:
> On Mon, Sep 15, 2025 at 03:53:18PM -0700, Sean Christopherson wrote:
> > On Thu, Sep 04, 2025, Naveen N Rao (AMD) wrote:
> > > Users who specifically care about AVIC
> >
> > Which we're trying to make "everyone" by enabling AVIC by default (even though
> > it's conditional). The only thing that should care about the "auto" behavior is
> > the code that needs to resolve "auto", everything else should act as if "avic" is
> > a pure boolean.
>
> This was again about preventing a warning in the default case since
> there is nothing that the user can do here.
Yes, there is. The user can disable SNP, either in firmware or in their kernel.
> I think this will trigger on most Zen 4 systems if SNP is enabled.
Which is working as intended. Even if the user couldn't resolve the issue (by
disabling SNP), I would still want KVM to print a message. My goal isn't to
provide a pristine kernel log, it's to provide a good experience for end users.
In my very strong opinion, for this case that means providing the user with as
much information as possible, at a loglevel that will alert them to an unexpected
and/or incompatible setup.
> By "users who specifically care about AVIC", I mean those users who want
> to ensure it is enabled and have been loading kvm_amd with "avic=on".
> For them, it is important to print a warning if there are missing
> dependencies. For everyone else, I am not sure it is useful to print a
> warning since there is nothing they can do.
As above, the user absolutely can resolve the SNP issue.
> > > diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
> > > index 9fe1fd709458..6bd5079a01f1 100644
> > > --- a/arch/x86/kvm/svm/avic.c
> > > +++ b/arch/x86/kvm/svm/avic.c
> > > @@ -1095,8 +1095,13 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu)
> > > */
> > > void avic_hardware_setup(bool force_avic)
> > > {
> > > + bool default_avic = (avic == -1);
> >
> > We should treat any negative value as "auto", otherwise I think the semantics get
> > a bit weird, e.g. -1 == auto, but -2 == on, which isn't very intuitive.
>
> Agree. The reason I hard-coded the check to -1 is because 'avic' is
> being exposed as a boolean and there is no way for a user to set it to a
> negative value.
Gah, I misread param_set_bint(). That's a fortunate goof though, because looking
at this again, we can actually do better than accepting a magic value. Similar
to nx_huge_pages, KVM can explicitly look for "auto" before parsing the value as
a boolean. That way KVM's internal value for "auto" isn't user visible.
#define AVIC_AUTO_MODE -1
static int avic_param_set(const char *val, const struct kernel_param *kp)
{
if (val && sysfs_streq(val, "auto")) {
*(int *)kp->arg = AVIC_AUTO_MODE;
return 0;
}
return param_set_bint(val, kp);
}
static const struct kernel_param_ops avic_ops = {
.flags = KERNEL_PARAM_OPS_FL_NOARG,
.set = avic_param_set,
.get = param_get_bool,
};
/*
* Enable / disable AVIC. In "auto" mode (default behavior), AVIC is enabled
* for Zen4+ CPUs with x2AVIC (and all other criteria for enablement are met).
*/
static int avic = AVIC_AUTO_MODE;
module_param_cb(avic, &avic_ops, &avic, 0444);
__MODULE_PARM_TYPE(avic, "bool");
next prev parent reply other threads:[~2025-09-16 14:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 18:00 [RFC PATCH v2 0/5] KVM: SVM: Enable AVIC by default on Zen 4+ Naveen N Rao (AMD)
2025-09-04 18:00 ` [RFC PATCH v2 1/5] KVM: SVM: Stop warning if x2AVIC feature bit alone is enabled Naveen N Rao (AMD)
2025-09-15 20:04 ` Sean Christopherson
2025-09-16 7:14 ` Naveen N Rao
2025-09-16 13:40 ` Mario Limonciello
2025-09-16 13:51 ` Sean Christopherson
2025-09-16 18:37 ` Naveen N Rao
2025-09-16 19:26 ` Mario Limonciello
2025-09-17 0:44 ` Sean Christopherson
2025-09-04 18:00 ` [RFC PATCH v2 2/5] KVM: SVM: Simplify the message printed with 'force_avic' Naveen N Rao (AMD)
2025-09-15 22:42 ` Sean Christopherson
2025-09-04 18:00 ` [RFC PATCH v2 3/5] KVM: SVM: Move all AVIC setup to avic_hardware_setup() Naveen N Rao (AMD)
2025-09-15 19:59 ` Sean Christopherson
2025-09-04 18:00 ` [RFC PATCH v2 4/5] KVM: SVM: Move 'force_avic' module parameter to svm.c Naveen N Rao (AMD)
2025-09-15 22:43 ` Sean Christopherson
2025-09-04 18:00 ` [RFC PATCH v2 5/5] KVM: SVM: Enable AVIC by default from Zen 4 Naveen N Rao (AMD)
2025-09-15 22:53 ` Sean Christopherson
2025-09-16 7:39 ` Naveen N Rao
2025-09-16 14:27 ` Sean Christopherson [this message]
2025-09-16 18:53 ` Naveen N Rao
2025-09-15 23:17 ` Sean Christopherson
2025-09-16 10:17 ` Naveen N Rao
2025-09-15 23:23 ` [RFC PATCH v2 0/5] KVM: SVM: Enable AVIC by default on Zen 4+ Sean Christopherson
2025-09-16 10:31 ` Naveen N Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aMlz5NTt_YA9foOc@google.com \
--to=seanjc@google.com \
--cc=alejandro.j.jimenez@oracle.com \
--cc=jmattson@google.com \
--cc=joao.m.martins@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=maciej.szmigiero@oracle.com \
--cc=mlevitsk@redhat.com \
--cc=naveen@kernel.org \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox