public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Tycho Andersen <tycho@kernel.org>
Cc: Ashish Kalra <ashish.kalra@amd.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	 John Allen <john.allen@amd.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	 "David S. Miller" <davem@davemloft.net>,
	linux-crypto@vger.kernel.org,  linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org,  linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/4] selftests/kvm: check that SEV-ES VMs are allowed in SEV-SNP mode
Date: Mon, 23 Feb 2026 08:36:32 -0800	[thread overview]
Message-ID: <aZyCEBo07EHw2Prk@google.com> (raw)
In-Reply-To: <20260223162900.772669-3-tycho@kernel.org>

On Mon, Feb 23, 2026, Tycho Andersen wrote:
> diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> index 86ad1c7d068f..c7fda9fc324b 100644
> --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> @@ -213,13 +213,48 @@ static void test_sev_smoke(void *guest, uint32_t type, uint64_t policy)
>  	}
>  }
>  
> +static bool sev_es_allowed(void)
> +{
> +	struct kvm_sev_launch_start launch_start = {
> +		.policy = SEV_POLICY_ES,
> +	};
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int firmware_error, ret;
> +	bool supported = true;
> +
> +	if (!kvm_cpu_has(X86_FEATURE_SEV_ES))
> +		return false;
> +
> +	if (!kvm_cpu_has(X86_FEATURE_SEV_SNP))
> +		return true;
> +
> +	/*
> +	 * In some cases when SEV-SNP is enabled, firmware disallows starting
> +	 * an SEV-ES VM. When SEV-SNP is enabled try to launch an SEV-ES, and
> +	 * check the underlying firmware error for this case.
> +	 */
> +	vm = vm_sev_create_with_one_vcpu(KVM_X86_SEV_ES_VM, guest_sev_es_code,
> +					 &vcpu);

If there's a legimate reason why an SEV-ES VM can't be created, then that needs
to be explicitly enumerated in some way by the kernel.  E.g. is this due to lack
of ASIDs due to CipherTextHiding or something?  Throwing a noodle to see if it
sticks is not an option.

> +
> +	ret = __vm_sev_ioctl(vm, KVM_SEV_LAUNCH_START, &launch_start,
> +			     &firmware_error);
> +	if (ret == -1 && firmware_error == SEV_RET_UNSUPPORTED) {
> +		pr_info("SEV-ES not supported with SNP\n");
> +		supported = false;
> +	}
> +
> +	kvm_vm_free(vm);
> +	return supported;
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
>  
>  	test_sev_smoke(guest_sev_code, KVM_X86_SEV_VM, 0);
>  
> -	if (kvm_cpu_has(X86_FEATURE_SEV_ES))
> +	if (sev_es_allowed())
>  		test_sev_smoke(guest_sev_es_code, KVM_X86_SEV_ES_VM, SEV_POLICY_ES);
>  
>  	if (kvm_cpu_has(X86_FEATURE_SEV_SNP))
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-02-23 16:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 16:28 [PATCH 0/4] Allow setting RAPL_DIS during SNP_INIT_EX Tycho Andersen
2026-02-23 16:28 ` [PATCH 1/4] selftests/kvm: allow retrieving underlying SEV firmware error Tycho Andersen
2026-02-23 16:28 ` [PATCH 2/4] selftests/kvm: check that SEV-ES VMs are allowed in SEV-SNP mode Tycho Andersen
2026-02-23 16:36   ` Sean Christopherson [this message]
2026-02-23 16:48     ` Tycho Andersen
2026-02-23 17:15       ` Sean Christopherson
2026-02-23 22:12         ` Tycho Andersen
2026-02-24 18:02           ` Sean Christopherson
2026-02-25 17:29             ` Tycho Andersen
2026-02-25 17:44               ` Sean Christopherson
2026-02-26 20:59                 ` Tycho Andersen
2026-02-26 22:28                   ` Sean Christopherson
2026-02-23 16:28 ` [PATCH 3/4] crypto/ccp: support setting RAPL_DIS in SNP_INIT_EX Tycho Andersen
2026-02-23 16:40   ` Sean Christopherson
2026-02-23 22:14     ` Tycho Andersen
2026-02-24 17:50       ` Sean Christopherson
2026-02-25 18:05         ` Tycho Andersen
2026-02-23 16:29 ` [PATCH 4/4] selftests/kvm: smoke test support for RAPL_DIS Tycho Andersen

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=aZyCEBo07EHw2Prk@google.com \
    --to=seanjc@google.com \
    --cc=ashish.kalra@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=john.allen@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=tycho@kernel.org \
    /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