From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Dapeng Mi <dapeng1.mi@linux.intel.com>,
Sean Christopherson <seanjc@google.com>,
Liam Merwick <liam.merwick@oracle.com>
Subject: [kvm-unit-tests PATCH v2 10/14] x86/sev: Skip the AMD SEV test if SEV is unsupported/disabled
Date: Tue, 10 Jun 2025 12:54:11 -0700 [thread overview]
Message-ID: <20250610195415.115404-11-seanjc@google.com> (raw)
In-Reply-To: <20250610195415.115404-1-seanjc@google.com>
Skip the AMD SEV test if SEV is unsupported, as KVM-Unit-Tests typically
don't report failures if feature is missing.
Opportunistically use amd_sev_enabled() instead of duplicating all of its
functionality.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/amd_sev.c | 51 +++++++--------------------------------------------
1 file changed, 7 insertions(+), 44 deletions(-)
diff --git a/x86/amd_sev.c b/x86/amd_sev.c
index 7757d4f8..4ec45543 100644
--- a/x86/amd_sev.c
+++ b/x86/amd_sev.c
@@ -15,51 +15,10 @@
#include "x86/amd_sev.h"
#include "msr.h"
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-
#define TESTDEV_IO_PORT 0xe0
static char st1[] = "abcdefghijklmnop";
-static int test_sev_activation(void)
-{
- struct cpuid cpuid_out;
- u64 msr_out;
-
- printf("SEV activation test is loaded.\n");
-
- /* Tests if CPUID function to check SEV is implemented */
- cpuid_out = cpuid(CPUID_FN_LARGEST_EXT_FUNC_NUM);
- printf("CPUID Fn8000_0000[EAX]: 0x%08x\n", cpuid_out.a);
- if (cpuid_out.a < CPUID_FN_ENCRYPT_MEM_CAPAB) {
- printf("CPUID does not support FN%08x\n",
- CPUID_FN_ENCRYPT_MEM_CAPAB);
- return EXIT_FAILURE;
- }
-
- /* Tests if SEV is supported */
- cpuid_out = cpuid(CPUID_FN_ENCRYPT_MEM_CAPAB);
- printf("CPUID Fn8000_001F[EAX]: 0x%08x\n", cpuid_out.a);
- printf("CPUID Fn8000_001F[EBX]: 0x%08x\n", cpuid_out.b);
- if (!(cpuid_out.a & SEV_SUPPORT_MASK)) {
- printf("SEV is not supported.\n");
- return EXIT_FAILURE;
- }
- printf("SEV is supported\n");
-
- /* Tests if SEV is enabled */
- msr_out = rdmsr(MSR_SEV_STATUS);
- printf("MSR C001_0131[EAX]: 0x%08lx\n", msr_out & 0xffffffff);
- if (!(msr_out & SEV_ENABLED_MASK)) {
- printf("SEV is not enabled.\n");
- return EXIT_FAILURE;
- }
- printf("SEV is enabled\n");
-
- return EXIT_SUCCESS;
-}
-
static void test_sev_es_activation(void)
{
if (rdmsr(MSR_SEV_STATUS) & SEV_ES_ENABLED_MASK) {
@@ -88,10 +47,14 @@ static void test_stringio(void)
int main(void)
{
- int rtn;
- rtn = test_sev_activation();
- report(rtn == EXIT_SUCCESS, "SEV activation test.");
+ if (!amd_sev_enabled()) {
+ report_skip("AMD SEV not enabled\n");
+ goto out;
+ }
+
test_sev_es_activation();
test_stringio();
+
+out:
return report_summary();
}
--
2.50.0.rc0.642.g800a2b2222-goog
next prev parent reply other threads:[~2025-06-10 19:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 19:54 [kvm-unit-tests PATCH v2 00/14] x86: Add CPUID properties, clean up related code Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 01/14] x86: Encode X86_FEATURE_* definitions using a structure Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 02/14] x86: Add X86_PROPERTY_* framework to retrieve CPUID values Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 03/14] x86: Use X86_PROPERTY_MAX_VIRT_ADDR in is_canonical() Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 04/14] x86: Implement get_supported_xcr0() using X86_PROPERTY_SUPPORTED_XCR0_{LO,HI} Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 05/14] x86: Add and use X86_PROPERTY_INTEL_PT_NR_RANGES Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 06/14] x86/pmu: Mark all arch events as available on AMD, and rename fields Sean Christopherson
2025-06-11 1:32 ` Mi, Dapeng
2025-06-11 12:02 ` Liam Merwick
2025-06-13 6:24 ` Sandipan Das
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 07/14] x86/pmu: Mark Intel architectural event available iff X <= CPUID.0xA.EAX[31:24] Sean Christopherson
2025-06-11 1:35 ` Mi, Dapeng
2025-06-11 12:10 ` Liam Merwick
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 08/14] x86/pmu: Use X86_PROPERTY_PMU_* macros to retrieve PMU information Sean Christopherson
2025-06-13 6:25 ` Sandipan Das
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 09/14] x86/sev: Use VC_VECTOR from processor.h Sean Christopherson
2025-06-10 19:54 ` Sean Christopherson [this message]
2025-06-11 12:28 ` [kvm-unit-tests PATCH v2 10/14] x86/sev: Skip the AMD SEV test if SEV is unsupported/disabled Liam Merwick
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 11/14] x86/sev: Define and use X86_FEATURE_* flags for CPUID 0x8000001F Sean Christopherson
2025-06-11 12:38 ` Liam Merwick
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 12/14] x86/sev: Use X86_PROPERTY_SEV_C_BIT to get the AMD SEV C-bit location Sean Christopherson
2025-06-11 12:58 ` Liam Merwick
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 13/14] x86/sev: Use amd_sev_es_enabled() to detect if SEV-ES is enabled Sean Christopherson
2025-06-10 19:54 ` [kvm-unit-tests PATCH v2 14/14] x86: Move SEV MSR definitions to msr.h Sean Christopherson
2025-06-11 15:41 ` Liam Merwick
2025-06-25 22:25 ` [kvm-unit-tests PATCH v2 00/14] x86: Add CPUID properties, clean up related code 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=20250610195415.115404-11-seanjc@google.com \
--to=seanjc@google.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=liam.merwick@oracle.com \
--cc=pbonzini@redhat.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