Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: "Sampat, Pratik Rajesh" <pratikrajesh.sampat@amd.com>
To: Peter Gonda <pgonda@google.com>, <kvm@vger.kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Alper Gun <alpergun@google.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Michael Roth <michael.roth@amd.com>,
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH] KVM: selftests: Add SEV-ES shutdown test
Date: Thu, 11 Jul 2024 11:19:58 -0500	[thread overview]
Message-ID: <c0faf3d7-2589-4c51-a3c7-4e4a33c3baf5@amd.com> (raw)
In-Reply-To: <20240709182936.146487-1-pgonda@google.com>

Hi Peter,

On 7/9/2024 1:29 PM, Peter Gonda wrote:
> Regression test for ae20eef5 ("KVM: SVM: Update SEV-ES shutdown intercepts
> with more metadata"). Test confirms userspace is correctly indicated of
> a guest shutdown not previous behavior of an EINVAL from KVM_RUN.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Alper Gun <alpergun@google.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Michael Roth <michael.roth@amd.com>
> Cc: kvm@vger.kernel.org
> Cc: linux-kselftest@vger.kernel.org
> Signed-off-by: Peter Gonda <pgonda@google.com>

Tested-by: Pratik R. Sampat <pratikrajesh.sampat@amd.com>

> 
> ---
>  .../selftests/kvm/x86_64/sev_smoke_test.c     | 26 +++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c b/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
> index 7c70c0da4fb74..04f24d5f09877 100644
> --- a/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
> @@ -160,6 +160,30 @@ static void test_sev(void *guest_code, uint64_t policy)
>  	kvm_vm_free(vm);
>  }
>  
> +static void guest_shutdown_code(void)
> +{
> +	__asm__ __volatile__("ud2");
> +}
> +
> +static void test_sev_es_shutdown(void)
> +{
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +
> +	uint32_t type = KVM_X86_SEV_ES_VM;
> +
> +	vm = vm_sev_create_with_one_vcpu(type, guest_shutdown_code, &vcpu);
> +
> +	vm_sev_launch(vm, SEV_POLICY_ES, NULL);
> +
> +	vcpu_run(vcpu);
> +	TEST_ASSERT(vcpu->run->exit_reason == KVM_EXIT_SHUTDOWN,
> +		    "Wanted SHUTDOWN, got %s",
> +		    exit_reason_str(vcpu->run->exit_reason));
> +
> +	kvm_vm_free(vm);
> +}
> +

I guess this case also applies to SNP. So maybe once this patch is
queued up I could spin another patch in my SNP kselftest patch series
that parameterizes this function to test SNP as well.

Thanks!
Pratik

>  int main(int argc, char *argv[])
>  {
>  	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
> @@ -171,6 +195,8 @@ int main(int argc, char *argv[])
>  		test_sev(guest_sev_es_code, SEV_POLICY_ES | SEV_POLICY_NO_DBG);
>  		test_sev(guest_sev_es_code, SEV_POLICY_ES);
>  
> +		test_sev_es_shutdown();
> +
>  		if (kvm_has_cap(KVM_CAP_XCRS) &&
>  		    (xgetbv(0) & XFEATURE_MASK_X87_AVX) == XFEATURE_MASK_X87_AVX) {
>  			test_sync_vmsa(0);

  reply	other threads:[~2024-07-11 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 18:29 [PATCH] KVM: selftests: Add SEV-ES shutdown test Peter Gonda
2024-07-11 16:19 ` Sampat, Pratik Rajesh [this message]
2024-07-11 16:37   ` Peter Gonda
2024-08-30  2:36 ` Sean Christopherson
2024-08-31  0:20 ` 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=c0faf3d7-2589-4c51-a3c7-4e4a33c3baf5@amd.com \
    --to=pratikrajesh.sampat@amd.com \
    --cc=alpergun@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@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