From: Peter Gonda <pgonda@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Marc Orr <marcorr@google.com>,
Nathan Tempelman <natet@google.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Tom Lendacky <Thomas.Lendacky@amd.com>
Subject: Re: [PATCH 1/6] KVM: SEV: Disallow COPY_ENC_CONTEXT_FROM if target has created vCPUs
Date: Mon, 15 Nov 2021 12:51:19 -0700 [thread overview]
Message-ID: <CAMkAt6qLVLsP6_0X_u+zdRT99rutphZ11y-1-hEUQ8KZOUU8tA@mail.gmail.com> (raw)
In-Reply-To: <20211109215101.2211373-2-seanjc@google.com>
On Tue, Nov 9, 2021 at 2:53 PM Sean Christopherson <seanjc@google.com> wrote:
>
> Reject COPY_ENC_CONTEXT_FROM if the destination VM has created vCPUs.
> KVM relies on SEV activation to occur before vCPUs are created, e.g. to
> set VMCB flags and intercepts correctly.
>
> Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context")
> Cc: stable@vger.kernel.org
> Cc: Peter Gonda <pgonda@google.com>
> Cc: Marc Orr <marcorr@google.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Nathan Tempelman <natet@google.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/svm/sev.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 3e2769855e51..eeec499e4372 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1775,7 +1775,12 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
> mutex_unlock(&source_kvm->lock);
> mutex_lock(&kvm->lock);
>
> - if (sev_guest(kvm)) {
> + /*
> + * Disallow out-of-band SEV/SEV-ES init if the target is already an
> + * SEV guest, or if vCPUs have been created. KVM relies on vCPUs being
> + * created after SEV/SEV-ES initialization, e.g. to init intercepts.
> + */
> + if (sev_guest(kvm) || kvm->created_vcpus) {
> ret = -EINVAL;
> goto e_mirror_unlock;
> }
Now that we have some framework for running SEV related selftests, do
you mind adding a regression test for this change?
> --
> 2.34.0.rc0.344.g81b53c2807-goog
>
next prev parent reply other threads:[~2021-11-16 0:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 21:50 [PATCH 0/6] KVM: SEV: Bug fix, cleanups and enhancements Sean Christopherson
2021-11-09 21:50 ` [PATCH 1/6] KVM: SEV: Disallow COPY_ENC_CONTEXT_FROM if target has created vCPUs Sean Christopherson
2021-11-15 19:51 ` Peter Gonda [this message]
2021-11-15 23:35 ` Sean Christopherson
2021-11-09 21:50 ` [PATCH 2/6] KVM: SEV: Explicitly document that there are no TOCTOU races in copy ASID Sean Christopherson
2021-11-16 11:38 ` Paolo Bonzini
2021-11-09 21:50 ` [PATCH 3/6] KVM: SEV: Set sev_info.active after initial checks in sev_guest_init() Sean Christopherson
2021-11-09 21:50 ` [PATCH 4/6] KVM: SEV: WARN if SEV-ES is marked active but SEV is not Sean Christopherson
2021-11-09 21:51 ` [PATCH 5/6] KVM: SEV: Drop a redundant setting of sev->asid during initialization Sean Christopherson
2021-11-09 21:51 ` [PATCH 6/6] KVM: SEV: Fix typo in and tweak name of cmd_allowed_from_miror() Sean Christopherson
2021-11-16 12:35 ` [PATCH 0/6] KVM: SEV: Bug fix, cleanups and enhancements 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=CAMkAt6qLVLsP6_0X_u+zdRT99rutphZ11y-1-hEUQ8KZOUU8tA@mail.gmail.com \
--to=pgonda@google.com \
--cc=Thomas.Lendacky@amd.com \
--cc=brijesh.singh@amd.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcorr@google.com \
--cc=natet@google.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).