From: Atish Patra <atish.patra@linux.dev>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Peter Gonda <pgonda@google.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Youngjae Lee <youngjaelee@meta.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Michael Roth <michael.roth@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>
Cc: clm@meta.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-crypto@vger.kernel.org, stable@vger.kernel.org,
Atish Patra <atishp@meta.com>
Subject: Re: [PATCH v3 2/4] KVM: selftests: Verify SNP VMs are rejected from migration and mirroring
Date: Sun, 14 Jun 2026 23:46:16 -0700 [thread overview]
Message-ID: <a1960092-f444-47fb-9358-aab0d4f43ce2@linux.dev> (raw)
In-Reply-To: <20260602-sev_snp_fixes-v3-2-585e4783a42f@meta.com>
On 6/2/26 3:11 PM, Atish Patra wrote:
> From: Atish Patra <atishp@meta.com>
>
> Migration and mirroring of SEV-SNP VMs are not supported yet.
>
> Add two selftests that verify KVM rejects intra-host migration and
> mirroring when the source VM is an SNP VM, so the restriction stays enforced
> until proper SNP state transfer is implemented.
>
> Signed-off-by: Atish Patra <atishp@meta.com>
> ---
> .../testing/selftests/kvm/x86/sev_migrate_tests.c | 47 ++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/x86/sev_migrate_tests.c b/tools/testing/selftests/kvm/x86/sev_migrate_tests.c
> index 6b0928e69051..acef6ab26d3d 100644
> --- a/tools/testing/selftests/kvm/x86/sev_migrate_tests.c
> +++ b/tools/testing/selftests/kvm/x86/sev_migrate_tests.c
> @@ -313,6 +313,49 @@ static void test_sev_mirror_parameters(void)
> kvm_vm_free(vm_no_vcpu);
> }
>
> +static void test_sev_snp_migrate_reject(void)
> +{
> + struct kvm_vm *src_vm, *dst_vm;
> + int ret;
> +
> + src_vm = vm_create_barebones_type(KVM_X86_SNP_VM);
> + snp_vm_init(src_vm);
> + __vm_vcpu_add(src_vm, 0);
> + vm_sev_launch(src_vm, snp_default_policy(), NULL);
> +
> + dst_vm = vm_create_barebones_type(KVM_X86_SNP_VM);
> + __vm_vcpu_add(dst_vm, 0);
> +
> + ret = __sev_migrate_from(dst_vm, src_vm);
> + TEST_ASSERT(ret == -1 && errno == EINVAL,
> + "SNP VM migration should be rejected. ret: %d, errno: %d",
> + ret, errno);
> +
> + kvm_vm_free(src_vm);
> + kvm_vm_free(dst_vm);
> +}
> +
> +static void test_sev_snp_mirror_reject(void)
> +{
> + struct kvm_vm *src_vm, *dst_vm;
> + int ret;
> +
> + src_vm = vm_create_barebones_type(KVM_X86_SNP_VM);
> + snp_vm_init(src_vm);
> + __vm_vcpu_add(src_vm, 0);
> + vm_sev_launch(src_vm, snp_default_policy(), NULL);
> +
> + dst_vm = aux_vm_create(false);
> +
> + ret = __sev_mirror_create(dst_vm, src_vm);
> + TEST_ASSERT(ret == -1 && errno == EINVAL,
> + "SNP VM mirroring should be rejected. ret: %d, errno: %d",
> + ret, errno);
> +
> + kvm_vm_free(src_vm);
> + kvm_vm_free(dst_vm);
> +}
> +
> static void test_sev_move_copy(void)
> {
> struct kvm_vm *dst_vm, *dst2_vm, *dst3_vm, *sev_vm, *mirror_vm,
> @@ -384,12 +427,16 @@ int main(int argc, char *argv[])
> test_sev_migrate_parameters();
> if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM))
> test_sev_move_copy();
> + if (kvm_cpu_has(X86_FEATURE_SEV_SNP))
> + test_sev_snp_migrate_reject();
> }
> if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) {
> test_sev_mirror(/* es= */ false);
> if (have_sev_es)
> test_sev_mirror(/* es= */ true);
> test_sev_mirror_parameters();
> + if (kvm_cpu_has(X86_FEATURE_SEV_SNP))
> + test_sev_snp_mirror_reject();
> }
> return 0;
> }
>
gentle ping for any feedback on this patch ?
next parent reply other threads:[~2026-06-15 6:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260602-sev_snp_fixes-v3-0-585e4783a42f@meta.com>
[not found] ` <20260602-sev_snp_fixes-v3-2-585e4783a42f@meta.com>
2026-06-15 6:46 ` Atish Patra [this message]
2026-06-02 22:36 [PATCH v3 0/4] KVM: Miscellaneous SEV/SNP related fixes Atish Patra
2026-06-02 22:36 ` [PATCH v3 2/4] KVM: selftests: Verify SNP VMs are rejected from migration and mirroring Atish Patra
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=a1960092-f444-47fb-9358-aab0d4f43ce2@linux.dev \
--to=atish.patra@linux.dev \
--cc=ashish.kalra@amd.com \
--cc=atishp@meta.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=clm@meta.com \
--cc=dave.hansen@linux.intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=pgonda@google.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
--cc=youngjaelee@meta.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