From: Tycho Andersen <tycho@kernel.org>
To: 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>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH 4/4] selftests/kvm: smoke test support for RAPL_DIS
Date: Mon, 23 Feb 2026 09:29:00 -0700 [thread overview]
Message-ID: <20260223162900.772669-5-tycho@kernel.org> (raw)
In-Reply-To: <20260223162900.772669-1-tycho@kernel.org>
From: "Tycho Andersen (AMD)" <tycho@kernel.org>
If the hardware supports the RAPL_DIS policy bit and the ccp has been
loaded with the RAPL_DIS bit set, make sure a VM can
actually start using it.
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
tools/testing/selftests/kvm/include/x86/sev.h | 1 +
.../selftests/kvm/x86/sev_smoke_test.c | 24 ++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/include/x86/sev.h b/tools/testing/selftests/kvm/include/x86/sev.h
index fd11f4222ec2..e9a566ff6df1 100644
--- a/tools/testing/selftests/kvm/include/x86/sev.h
+++ b/tools/testing/selftests/kvm/include/x86/sev.h
@@ -28,6 +28,7 @@ enum sev_guest_state {
#define SNP_POLICY_SMT (1ULL << 16)
#define SNP_POLICY_RSVD_MBO (1ULL << 17)
#define SNP_POLICY_DBG (1ULL << 19)
+#define SNP_POLICY_RAPL_DIS (1ULL << 23)
#define GHCB_MSR_TERM_REQ 0x100
diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
index c7fda9fc324b..e4cf5b99b19a 100644
--- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
+++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
@@ -248,6 +248,18 @@ static bool sev_es_allowed(void)
return supported;
}
+static u64 supported_policy_mask(void)
+{
+ int kvm_fd = open_kvm_dev_path_or_exit();
+ u64 policy_mask = 0;
+
+ kvm_device_attr_get(kvm_fd, KVM_X86_GRP_SEV,
+ KVM_X86_SNP_POLICY_BITS,
+ &policy_mask);
+ close(kvm_fd);
+ return policy_mask;
+}
+
int main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
@@ -257,8 +269,18 @@ int main(int argc, char *argv[])
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))
+ if (kvm_cpu_has(X86_FEATURE_SEV_SNP)) {
+ int supported_policy = supported_policy_mask();
+
test_sev_smoke(guest_snp_code, KVM_X86_SNP_VM, snp_default_policy());
+ if (supported_policy & SNP_POLICY_RAPL_DIS &&
+ kvm_get_module_param_bool("ccp", "rapl_disable")) {
+ uint32_t policy = snp_default_policy() | SNP_POLICY_RAPL_DIS;
+
+ test_sev_smoke(guest_snp_code, KVM_X86_SNP_VM, policy);
+ }
+ }
+
return 0;
}
--
2.53.0
prev parent reply other threads:[~2026-02-23 16:31 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
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 ` Tycho Andersen [this message]
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=20260223162900.772669-5-tycho@kernel.org \
--to=tycho@kernel.org \
--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=seanjc@google.com \
--cc=shuah@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.