From: "Huang, Kai" <kai.huang@intel.com>
To: Sean Christopherson <seanjc@google.com>,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Anup Patel <anup@brainfault.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Cc: <linux-arm-kernel@lists.infradead.org>, <kvmarm@lists.linux.dev>,
<kvm@vger.kernel.org>, <loongarch@lists.linux.dev>,
<linux-mips@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
<kvm-riscv@lists.infradead.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 5/6] KVM: x86: Unconditionally set l1tf_flush_l1d during vCPU load
Date: Fri, 24 May 2024 10:42:50 +1200 [thread overview]
Message-ID: <7a7a94db-9019-44bb-95b0-dd3ef3560178@intel.com> (raw)
In-Reply-To: <20240522014013.1672962-6-seanjc@google.com>
On 22/05/2024 1:40 pm, Sean Christopherson wrote:
> Always set l1tf_flush_l1d during kvm_arch_vcpu_load() instead of setting
> it only when the vCPU is being scheduled back in. The flag is processed
> only when VM-Enter is imminent, and KVM obviously needs to load the vCPU
> before VM-Enter, so attempting to precisely set l1tf_flush_l1d provides no
> meaningful value. I.e. the flag _will_ be set either way, it's simply a
> matter of when.
Seems reasonable.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
Acked-by: Kai Huang <kai.huang@intel.com>
> arch/x86/kvm/x86.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 59aa772af755..60fea297f91f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5006,12 +5006,11 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> {
> struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
>
> - if (vcpu->scheduled_out) {
> - vcpu->arch.l1tf_flush_l1d = true;
> - if (pmu->version && unlikely(pmu->event_count)) {
> - pmu->need_cleanup = true;
> - kvm_make_request(KVM_REQ_PMU, vcpu);
> - }
> + vcpu->arch.l1tf_flush_l1d = true;
> +
> + if (vcpu->scheduled_out && pmu->version && pmu->event_count) {
> + pmu->need_cleanup = true;
> + kvm_make_request(KVM_REQ_PMU, vcpu);
> }
Nit, the unlikely() is lost, but I guess it is OK?
next prev parent reply other threads:[~2024-05-23 22:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 1:40 [PATCH v2 0/6] KVM: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 1/6] KVM: Add a flag to track if a loaded vCPU is scheduled out Sean Christopherson
2024-05-22 15:16 ` Oliver Upton
2024-05-22 1:40 ` [PATCH v2 2/6] KVM: VMX: Move PLE grow/shrink helpers above vmx_vcpu_load() Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Sean Christopherson
2024-05-23 22:47 ` Huang, Kai
2024-05-28 19:16 ` Sean Christopherson
2024-05-29 10:50 ` Huang, Kai
2024-05-29 12:54 ` Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 4/6] KVM: Delete the now unused kvm_arch_sched_in() Sean Christopherson
2024-05-24 1:50 ` maobibo
2024-05-22 1:40 ` [PATCH v2 5/6] KVM: x86: Unconditionally set l1tf_flush_l1d during vCPU load Sean Christopherson
2024-05-23 22:42 ` Huang, Kai [this message]
2024-05-22 1:40 ` [PATCH v2 6/6] KVM: x86: Drop now-superflous setting of l1tf_flush_l1d in vcpu_run() Sean Christopherson
2024-05-23 22:48 ` [PATCH v2 0/6] KVM: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Huang, Kai
2024-06-12 1:18 ` 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=7a7a94db-9019-44bb-95b0-dd3ef3560178@intel.com \
--to=kai.huang@intel.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=borntraeger@linux.ibm.com \
--cc=chenhuacai@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=maz@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=oliver.upton@linux.dev \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=zhaotianrui@loongson.cn \
/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).