From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Cathy Avery <cavery@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
pbonzini@redhat.com, vkuznets@redhat.com, wei.huang2@amd.com,
mlevitsk@redhat.com
Subject: Re: [PATCH v2 1/2] KVM: SVM: Move asid to vcpu_svm
Date: Mon, 12 Oct 2020 18:29:37 -0700 [thread overview]
Message-ID: <20201013012937.GA10366@linux.intel.com> (raw)
In-Reply-To: <20201011184818.3609-2-cavery@redhat.com>
On Sun, Oct 11, 2020 at 02:48:17PM -0400, Cathy Avery wrote:
> Move asid to svm->asid to allow for vmcb assignment
This is misleading. The asid isn't being moved, it's being copied/tracked.
The "to allow" wording also confused me; I though this was just a prep patch
and the actual assignment was in a follow-up patch.
> during svm_vcpu_run without regard to which level
> guest is running.
> Signed-off-by: Cathy Avery <cavery@redhat.com>
> ---
> arch/x86/kvm/svm/svm.c | 4 +++-
> arch/x86/kvm/svm/svm.h | 1 +
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index d4e18bda19c7..619980a5d540 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1101,6 +1101,7 @@ static void init_vmcb(struct vcpu_svm *svm)
> save->cr4 = 0;
> }
> svm->asid_generation = 0;
> + svm->asid = 0;
>
> svm->nested.vmcb = 0;
> svm->vcpu.arch.hflags = 0;
> @@ -1663,7 +1664,7 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
> }
>
> svm->asid_generation = sd->asid_generation;
> - svm->vmcb->control.asid = sd->next_asid++;
> + svm->asid = sd->next_asid++;
> vmcb_mark_dirty(svm->vmcb, VMCB_ASID);
I know very little (ok, nothing) about SVM VMCB caching rules, but I strongly
suspect this is broken. The existing code explicitly marks VMCB_ASID dirty,
but there is no equivalent code for the case where there are multiple VMCBs,
e.g. if new_asid() is called while vmcb01 is active, then vmcb02 will pick up
the new ASID but will not mark it dirty.
> }
> @@ -3446,6 +3447,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
>
> sync_lapic_to_cr8(vcpu);
>
> + svm->vmcb->control.asid = svm->asid;
Related to the above, handling this in vcpu_run() feels wrong. There really
shouldn't be a need to track the ASID. vmcb01 will always exist if vmcb02
exits, e.g. the ASID can be copied and marked dirty when loading vmcb02.
For new_asid(), it can unconditionally update vmcb01 and conditionally update
vmcb02.
> svm->vmcb->save.cr2 = vcpu->arch.cr2;
>
> /*
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index a798e1731709..862f0d2405e8 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -104,6 +104,7 @@ struct vcpu_svm {
> struct vmcb *vmcb;
> unsigned long vmcb_pa;
> struct svm_cpu_data *svm_data;
> + u32 asid;
> uint64_t asid_generation;
> uint64_t sysenter_esp;
> uint64_t sysenter_eip;
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-10-13 2:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 18:48 [PATCH v2 0/2] KVM: SVM: Create separate vmcbs for L1 and L2 Cathy Avery
2020-10-11 18:48 ` [PATCH v2 1/2] KVM: SVM: Move asid to vcpu_svm Cathy Avery
2020-10-13 1:29 ` Sean Christopherson [this message]
2020-11-13 17:03 ` Paolo Bonzini
2020-11-13 16:57 ` Paolo Bonzini
2020-11-29 9:41 ` Ashish Kalra
2020-11-30 14:41 ` Paolo Bonzini
2020-11-30 21:06 ` Ashish Kalra
2020-10-11 18:48 ` [PATCH v2 2/2] KVM: SVM: Use a separate vmcb for the nested L2 guest Cathy Avery
2020-10-13 1:33 ` Sean Christopherson
2020-11-13 17:36 ` Paolo Bonzini
2020-11-13 17:58 ` Paolo Bonzini
2020-11-13 20:38 ` Paolo Bonzini
2020-11-17 11:03 ` [PATCH v2 0/2] KVM: SVM: Create separate vmcbs for L1 and L2 Paolo Bonzini
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=20201013012937.GA10366@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=cavery@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wei.huang2@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;
as well as URLs for NNTP newsgroup(s).