* [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled
@ 2024-03-14 11:44 Muhammad Usama Anjum
2024-03-14 23:37 ` Chang S. Bae
2024-03-26 20:51 ` Shuah Khan
0 siblings, 2 replies; 5+ messages in thread
From: Muhammad Usama Anjum @ 2024-03-14 11:44 UTC (permalink / raw)
To: Shuah Khan, Kirill A. Shutemov, Chang S. Bae,
Muhammad Usama Anjum, Dave Hansen, Binbin Wu,
Peter Zijlstra (Intel), Weihong Zhang, angquan yu
Cc: kernel, linux-kselftest, linux-kernel
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/selftests/ 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
...
Cc: Chang S. Bae <chang.seok.bae@intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
Changes since v1:
- Use arch_prctl to check if amx is supported
---
tools/testing/selftests/x86/amx.c | 27 ++++++++++-----------------
tools/testing/selftests/x86/lam.c | 2 +-
2 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
index d884fd69dd510..95aad6d8849be 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -103,21 +103,6 @@ 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)
-{
- uint32_t eax, ebx, ecx, edx;
-
- /*
- * CPUID.1:ECX.XSAVE[bit 26] enumerates general
- * support for the XSAVE feature set, including
- * 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");
-}
static uint32_t xbuf_size;
@@ -350,6 +335,7 @@ enum expected_result { FAIL_EXPECTED, SUCCESS_EXPECTED };
/* arch_prctl() and sigaltstack() test */
+#define ARCH_GET_XCOMP_SUPP 0x1021
#define ARCH_GET_XCOMP_PERM 0x1022
#define ARCH_REQ_XCOMP_PERM 0x1023
@@ -928,8 +914,15 @@ static void test_ptrace(void)
int main(void)
{
- /* Check hardware availability at first */
- check_cpuid_xsave();
+ unsigned long features;
+ long rc;
+
+ rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_SUPP, &features);
+ if (rc || (features & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE) {
+ ksft_print_msg("no AMX support\n");
+ return KSFT_SKIP;
+ }
+
check_cpuid_xtiledata();
init_stashed_xsave();
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled
2024-03-14 11:44 [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled Muhammad Usama Anjum
@ 2024-03-14 23:37 ` Chang S. Bae
2024-03-26 20:51 ` Shuah Khan
1 sibling, 0 replies; 5+ messages in thread
From: Chang S. Bae @ 2024-03-14 23:37 UTC (permalink / raw)
To: Muhammad Usama Anjum, Shuah Khan, Kirill A. Shutemov, Dave Hansen,
Binbin Wu, Peter Zijlstra (Intel), Weihong Zhang, angquan yu
Cc: kernel, linux-kselftest, linux-kernel
On 3/14/2024 4:44 AM, Muhammad Usama Anjum wrote:
> 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/selftests/ 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
> ...
>
> Cc: Chang S. Bae <chang.seok.bae@intel.com>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> Changes since v1:
> - Use arch_prctl to check if amx is supported
> ---
> tools/testing/selftests/x86/amx.c | 27 ++++++++++-----------------
> tools/testing/selftests/x86/lam.c | 2 +-
> 2 files changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
> index d884fd69dd510..95aad6d8849be 100644
> --- a/tools/testing/selftests/x86/amx.c
> +++ b/tools/testing/selftests/x86/amx.c
> @@ -103,21 +103,6 @@ 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)
> -{
> - uint32_t eax, ebx, ecx, edx;
> -
> - /*
> - * CPUID.1:ECX.XSAVE[bit 26] enumerates general
> - * support for the XSAVE feature set, including
> - * 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");
> -}
>
> static uint32_t xbuf_size;
>
> @@ -350,6 +335,7 @@ enum expected_result { FAIL_EXPECTED, SUCCESS_EXPECTED };
>
> /* arch_prctl() and sigaltstack() test */
>
> +#define ARCH_GET_XCOMP_SUPP 0x1021
> #define ARCH_GET_XCOMP_PERM 0x1022
> #define ARCH_REQ_XCOMP_PERM 0x1023
>
> @@ -928,8 +914,15 @@ static void test_ptrace(void)
>
> int main(void)
> {
> - /* Check hardware availability at first */
> - check_cpuid_xsave();
> + unsigned long features;
> + long rc;
> +
> + rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_SUPP, &features);
> + if (rc || (features & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE) {
> + ksft_print_msg("no AMX support\n");
> + return KSFT_SKIP;
> + }
> +
Reviewed-by: Chang S. Bae <chang.seok.bae@intel.com>
Thanks,
Chang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled
2024-03-14 11:44 [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled Muhammad Usama Anjum
2024-03-14 23:37 ` Chang S. Bae
@ 2024-03-26 20:51 ` Shuah Khan
2024-03-26 21:20 ` Chang S. Bae
1 sibling, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2024-03-26 20:51 UTC (permalink / raw)
To: Muhammad Usama Anjum, Shuah Khan, Kirill A. Shutemov,
Chang S. Bae, Dave Hansen, Binbin Wu, Peter Zijlstra (Intel),
Weihong Zhang, angquan yu
Cc: kernel, linux-kselftest, linux-kernel, Shuah Khan
On 3/14/24 05:44, Muhammad Usama Anjum wrote:
> 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/selftests/ 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
> ...
>
> Cc: Chang S. Bae <chang.seok.bae@intel.com>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> Changes since v1:
> - Use arch_prctl to check if amx is supported
This should be mentioned in the changelog and also
show that there are bo backwards compatibility issues.
> ---
> tools/testing/selftests/x86/amx.c | 27 ++++++++++-----------------
> tools/testing/selftests/x86/lam.c | 2 +-
> 2 files changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
> index d884fd69dd510..95aad6d8849be 100644
> --- a/tools/testing/selftests/x86/amx.c
> +++ b/tools/testing/selftests/x86/amx.c
> @@ -103,21 +103,6 @@ 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)
> -{
> - uint32_t eax, ebx, ecx, edx;
> -
> - /*
> - * CPUID.1:ECX.XSAVE[bit 26] enumerates general
> - * support for the XSAVE feature set, including
> - * 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");
> -}
>
Why doesn't the changelog mention the code removal?
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled
2024-03-26 20:51 ` Shuah Khan
@ 2024-03-26 21:20 ` Chang S. Bae
2024-03-27 16:18 ` Shuah Khan
0 siblings, 1 reply; 5+ messages in thread
From: Chang S. Bae @ 2024-03-26 21:20 UTC (permalink / raw)
To: Shuah Khan, Muhammad Usama Anjum, Shuah Khan, Kirill A. Shutemov,
Dave Hansen, Binbin Wu, Peter Zijlstra (Intel), Weihong Zhang,
angquan yu
Cc: kernel, linux-kselftest, linux-kernel
On 3/26/2024 1:51 PM, Shuah Khan wrote:
>
> show that there are bo backwards compatibility issues
In older kernels lacking AMX support [1], arch_prctl() returns EINVAL.
With AMX support, the kernel will properly set 'features'.
It is also worth noting that this simplification was previously
acknowledged [2], albeit some time ago.
Thanks,
Chang
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=db8268df0983adc2bb1fb48c9e5f7bfbb5f617f3
[2]
https://lore.kernel.org/lkml/de61ffdb-638a-ca84-31b5-55f6a8616597@linuxfoundation.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled
2024-03-26 21:20 ` Chang S. Bae
@ 2024-03-27 16:18 ` Shuah Khan
0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2024-03-27 16:18 UTC (permalink / raw)
To: Chang S. Bae, Muhammad Usama Anjum, Shuah Khan,
Kirill A. Shutemov, Dave Hansen, Binbin Wu,
Peter Zijlstra (Intel), Weihong Zhang, angquan yu
Cc: kernel, linux-kselftest, linux-kernel, Shuah Khan
On 3/26/24 15:20, Chang S. Bae wrote:
> On 3/26/2024 1:51 PM, Shuah Khan wrote:
>>
>> show that there are bo backwards compatibility issues
> In older kernels lacking AMX support [1], arch_prctl() returns EINVAL. With AMX support, the kernel will properly set 'features'.
>
> It is also worth noting that this simplification was previously acknowledged [2], albeit some time ago.
>
> Thanks,
> Chang
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=db8268df0983adc2bb1fb48c9e5f7bfbb5f617f3
> [2] https://lore.kernel.org/lkml/de61ffdb-638a-ca84-31b5-55f6a8616597@linuxfoundation.org/
>
>
Thanks. This can be included in the change log so it is
clear.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-27 16:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-14 11:44 [PATCH v2] selftests: x86: skip the tests if prerequisites aren't fulfilled Muhammad Usama Anjum
2024-03-14 23:37 ` Chang S. Bae
2024-03-26 20:51 ` Shuah Khan
2024-03-26 21:20 ` Chang S. Bae
2024-03-27 16:18 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox