Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions tools/testing/selftests/x86/amx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding explicit parentheses around '(features & XFEATURE_MASK_XTILE)' for clarity, e.g., 'if (rc || ((features & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE))'.

Suggested change
if (rc || (features & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE) {
if (rc || ((features & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE)) {

Copilot uses AI. Check for mistakes.
ksft_print_msg("no AMX support\n");
return KSFT_SKIP;
}

check_cpuid_xtiledata();

init_stashed_xsave();
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/x86/lam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading