[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240307183730.2858264-1-usama.anjum@collabora.com>
Date: Thu, 7 Mar 2024 23:37:22 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Shuah Khan <shuah@...nel.org>,
Muhammad Usama Anjum <usama.anjum@...labora.com>,
"Chang S. Bae" <chang.seok.bae@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Weihong Zhang <weihong.zhang@...el.com>,
Binbin Wu <binbin.wu@...ux.intel.com>,
angquan yu <angquan21@...il.com>
Cc: kernel@...labora.com,
linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] selftests: x86: skip the tests if prerequisites aren't fulfilled
Skip instead of failing when prerequisite conditions aren't fulfilled,
such as invalid xstate values etc. This patch would make the tests show
as skip when run by:
make -C tools/testing/selftest/ TARGETS=x86 run_tests
...
# timeout set to 45
# selftests: x86: amx_64
# # xstate cpuid: invalid tile data size/offset: 0/0
ok 42 selftests: x86: amx_64 # SKIP
# timeout set to 45
# selftests: x86: lam_64
# # Unsupported LAM feature!
ok 43 selftests: x86: lam_64 # SKIP
...
Signed-off-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
---
I'm not sure if xstate values should be correct on all the x86
processors. If the xstate is invalid on a CPU, the test should be
skipped instead of failing.
---
tools/testing/selftests/x86/amx.c | 33 ++++++++++++++++++++-----------
tools/testing/selftests/x86/lam.c | 2 +-
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
index d884fd69dd510..5d1ca0bbaaae7 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -103,9 +103,10 @@ static void clearhandler(int sig)
#define CPUID_LEAF1_ECX_XSAVE_MASK (1 << 26)
#define CPUID_LEAF1_ECX_OSXSAVE_MASK (1 << 27)
-static inline void check_cpuid_xsave(void)
+static inline int check_cpuid_xsave(void)
{
uint32_t eax, ebx, ecx, edx;
+ int ret = 0;
/*
* CPUID.1:ECX.XSAVE[bit 26] enumerates general
@@ -113,10 +114,16 @@ static inline void check_cpuid_xsave(void)
* XGETBV.
*/
__cpuid_count(1, 0, eax, ebx, ecx, edx);
- if (!(ecx & CPUID_LEAF1_ECX_XSAVE_MASK))
- fatal_error("cpuid: no CPU xsave support");
- if (!(ecx & CPUID_LEAF1_ECX_OSXSAVE_MASK))
- fatal_error("cpuid: no OS xsave support");
+ if (!(ecx & CPUID_LEAF1_ECX_XSAVE_MASK)) {
+ ksft_print_msg("cpuid: no CPU xsave support\n");
+ ret = -1;
+ }
+ if (!(ecx & CPUID_LEAF1_ECX_OSXSAVE_MASK)) {
+ ksft_print_msg("cpuid: no OS xsave support\n");
+ ret = -1;
+ }
+
+ return ret;
}
static uint32_t xbuf_size;
@@ -131,7 +138,7 @@ static struct {
#define TILE_CPUID 0x1d
#define TILE_PALETTE_ID 0x1
-static void check_cpuid_xtiledata(void)
+static int check_cpuid_xtiledata(void)
{
uint32_t eax, ebx, ecx, edx;
@@ -153,12 +160,16 @@ static void check_cpuid_xtiledata(void)
* eax: XTILEDATA state component size
* ebx: XTILEDATA state component offset in user buffer
*/
- if (!eax || !ebx)
- fatal_error("xstate cpuid: invalid tile data size/offset: %d/%d",
- eax, ebx);
+ if (!eax || !ebx) {
+ ksft_print_msg("xstate cpuid: invalid tile data size/offset: %d/%d\n",
+ eax, ebx);
+ return -1;
+ }
xtiledata.size = eax;
xtiledata.xbuf_offset = ebx;
+
+ return 0;
}
/* The helpers for managing XSAVE buffer and tile states: */
@@ -929,8 +940,8 @@ static void test_ptrace(void)
int main(void)
{
/* Check hardware availability at first */
- check_cpuid_xsave();
- check_cpuid_xtiledata();
+ if (check_cpuid_xsave() || check_cpuid_xtiledata())
+ return KSFT_SKIP;
init_stashed_xsave();
sethandler(SIGILL, handle_noperm, 0);
diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
index 215b8150b7cca..c0f016f45ee17 100644
--- a/tools/testing/selftests/x86/lam.c
+++ b/tools/testing/selftests/x86/lam.c
@@ -1183,7 +1183,7 @@ int main(int argc, char **argv)
if (!cpu_has_lam()) {
ksft_print_msg("Unsupported LAM feature!\n");
- return -1;
+ return KSFT_SKIP;
}
while ((c = getopt(argc, argv, "ht:")) != -1) {
--
2.39.2
Powered by blists - more mailing lists