From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v4 1/3] KVM: x86: Replace growing set of *_in_guest bools with a u64
Date: Tue, 24 Jun 2025 14:25:41 -0700 [thread overview]
Message-ID: <aFsX1anrZGWFsbF-@google.com> (raw)
In-Reply-To: <20250530185239.2335185-2-jmattson@google.com>
On Fri, May 30, 2025, Jim Mattson wrote:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 570e7f8cbf64..8c20afda4398 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6605,13 +6605,13 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
> pr_warn_once(SMT_RSB_MSG);
>
> if (cap->args[0] & KVM_X86_DISABLE_EXITS_PAUSE)
> - kvm->arch.pause_in_guest = true;
> + kvm_disable_exits(kvm, KVM_X86_DISABLE_EXITS_PAUSE);
> if (cap->args[0] & KVM_X86_DISABLE_EXITS_MWAIT)
> - kvm->arch.mwait_in_guest = true;
> + kvm_disable_exits(kvm, KVM_X86_DISABLE_EXITS_MWAIT);
> if (cap->args[0] & KVM_X86_DISABLE_EXITS_HLT)
> - kvm->arch.hlt_in_guest = true;
> + kvm_disable_exits(kvm, KVM_X86_DISABLE_EXITS_HLT);
> if (cap->args[0] & KVM_X86_DISABLE_EXITS_CSTATE)
> - kvm->arch.cstate_in_guest = true;
> + kvm_disable_exits(kvm, KVM_X86_DISABLE_EXITS_CSTATE);
> r = 0;
> disable_exits_unlock:
> mutex_unlock(&kvm->lock);
Can't this simply be? The set of capabilities to disable has already been vetted,
so I don't see any reason to manually process each flag.
mutex_lock(&kvm->lock);
if (kvm->created_vcpus)
goto disable_exits_unlock;
#define SMT_RSB_MSG "This processor is affected by the Cross-Thread Return Predictions vulnerability. " \
"KVM_CAP_X86_DISABLE_EXITS should only be used with SMT disabled or trusted guests."
if (!mitigate_smt_rsb && boot_cpu_has_bug(X86_BUG_SMT_RSB) &&
cpu_smt_possible() &&
(cap->args[0] & ~(KVM_X86_DISABLE_EXITS_PAUSE |
KVM_X86_DISABLE_EXITS_APERFMPERF)))
pr_warn_once(SMT_RSB_MSG);
kvm_disable_exits(kvm, cap->args[0]);
r = 0;
disable_exits_unlock:
mutex_unlock(&kvm->lock);
break;
next prev parent reply other threads:[~2025-06-24 21:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 18:52 [PATCH v4 0/3] KVM: x86: Provide a capability to disable APERF/MPERF read intercepts Jim Mattson
2025-05-30 18:52 ` [PATCH v4 1/3] KVM: x86: Replace growing set of *_in_guest bools with a u64 Jim Mattson
2025-06-24 21:25 ` Sean Christopherson [this message]
2025-06-24 22:34 ` Jim Mattson
2025-05-30 18:52 ` [PATCH v4 2/3] KVM: x86: Provide a capability to disable APERF/MPERF read intercepts Jim Mattson
2025-06-24 21:35 ` Sean Christopherson
2025-06-24 22:37 ` Jim Mattson
2025-06-24 23:31 ` Sean Christopherson
2025-06-25 0:11 ` Jim Mattson
2025-05-30 18:52 ` [PATCH v4 3/3] KVM: selftests: Test behavior of KVM_X86_DISABLE_EXITS_APERFMPERF Jim Mattson
2025-06-10 8:42 ` Mi, Dapeng
2025-06-10 16:59 ` Jim Mattson
2025-06-11 1:47 ` Mi, Dapeng
2025-06-24 22:24 ` Sean Christopherson
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=aFsX1anrZGWFsbF-@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.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;
as well as URLs for NNTP newsgroup(s).