From: Yan Zhao <yan.y.zhao@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: <linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
<seanjc@google.com>
Subject: Re: [PATCH 1/4] KVM: x86: Allow vendor code to disable quirks
Date: Tue, 4 Mar 2025 14:46:40 +0800 [thread overview]
Message-ID: <Z8ah0PmLQRk/AgFE@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <ad542d2a-f4f3-449f-a2b9-3c0dc1d4905f@redhat.com>
On Mon, Mar 03, 2025 at 05:04:40PM +0100, Paolo Bonzini wrote:
> On 3/3/25 02:15, Yan Zhao wrote:
> > On Sat, Mar 01, 2025 at 02:34:25AM -0500, Paolo Bonzini wrote:
> > > In some cases, the handling of quirks is split between platform-specific
> > > code and generic code, or it is done entirely in generic code, but the
> > > relevant bug does not trigger on some platforms; for example,
> > > KVM_X86_QUIRK_CD_NW_CLEARED is only applicable to AMD systems. In that
> > > case, allow unaffected vendor modules to disable handling of the quirk.
> > >
> > > The quirk remains available in KVM_CAP_DISABLE_QUIRKS2, because that API
> > > tells userspace that KVM *knows* that some of its past behavior was bogus
> > > or just undesirable. In other words, it's plausible for userspace to
> > > refuse to run if a quirk is not listed by KVM_CAP_DISABLE_QUIRKS2.
> > >
> > > In kvm_check_has_quirk(), in addition to checking if a quirk is not
> > > explicitly disabled by the user, also verify if the quirk applies to
> > > the hardware.
> > >
> > > Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
> > > Message-ID: <20250224070832.31394-1-yan.y.zhao@intel.com>
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > > ---
> > > arch/x86/kvm/vmx/vmx.c | 1 +
> > > arch/x86/kvm/x86.c | 1 +
> > > arch/x86/kvm/x86.h | 12 +++++++-----
> > > 3 files changed, 9 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > > index 486fbdb4365c..75df4caea2f7 100644
> > > --- a/arch/x86/kvm/vmx/vmx.c
> > > +++ b/arch/x86/kvm/vmx/vmx.c
> > > @@ -8506,6 +8506,7 @@ __init int vmx_hardware_setup(void)
> > > kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);
> > > + kvm_caps.inapplicable_quirks = KVM_X86_QUIRK_CD_NW_CLEARED;
> >
> > As you mentioned, KVM_X86_QUIRK_CD_NW_CLEARED has no effect on Intel's
> > platforms, no matter kvm_check_has_quirk() returns true or false.
> > So, what's the purpose to introduce kvm_caps.inapplicable_quirks?
>
> The purpose is to later mark IGNORE_GUEST_PAT as inapplicable, so that the
> relevant code does not run on AMD. However you have a point here:
Or naming it kvm_caps.platform_disabled_quirks?
>
> > One concern is that since KVM_X86_QUIRK_CD_NW_CLEARED is not for Intel
> > platforms, it's unnatural for Intel's code to add it into the
> > kvm_caps.inapplicable_quirks.
>
> So let's instead have kvm-amd.ko clear it from inapplicable_quirks. And
> likewise kvm-intel.ko can clear IGNORE_GUEST_PAT.
Sounds good.
next prev parent reply other threads:[~2025-03-04 6:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 7:34 [PATCH v2 0/4] KVM: x86: Introduce quirk KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT Paolo Bonzini
2025-03-01 7:34 ` [PATCH 1/4] KVM: x86: Allow vendor code to disable quirks Paolo Bonzini
2025-03-02 17:11 ` Xiaoyao Li
2025-03-03 1:15 ` Yan Zhao
2025-03-03 16:04 ` Paolo Bonzini
2025-03-04 6:46 ` Yan Zhao [this message]
2025-03-01 7:34 ` [PATCH 2/4] KVM: x86: Introduce supported_quirks to block disabling quirks Paolo Bonzini
2025-03-02 17:13 ` Xiaoyao Li
2025-03-03 1:23 ` Yan Zhao
2025-03-03 16:11 ` Paolo Bonzini
2025-03-04 4:21 ` Yan Zhao
2025-03-01 7:34 ` [PATCH 3/4] KVM: x86: Introduce Intel specific quirk KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT Paolo Bonzini
2025-03-02 17:30 ` Xiaoyao Li
2025-03-03 1:25 ` Yan Zhao
2025-03-01 7:34 ` [PATCH 4/4] KVM: TDX: Always honor guest PAT on TDX enabled platforms Paolo Bonzini
2025-03-02 17:03 ` Xiaoyao Li
2025-03-03 1:30 ` Yan Zhao
2025-03-03 16:14 ` Paolo Bonzini
2025-03-04 6:20 ` Yan Zhao
2025-03-03 1:47 ` [PATCH v2 0/4] KVM: x86: Introduce quirk KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT Yan Zhao
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=Z8ah0PmLQRk/AgFE@yzhao56-desk.sh.intel.com \
--to=yan.y.zhao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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