Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>,
	Shuah Khan <shuah@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Weihong Zhang <weihong.zhang@intel.com>,
	Binbin Wu <binbin.wu@linux.intel.com>,
	angquan yu <angquan21@gmail.com>
Cc: <kernel@collabora.com>, <linux-kselftest@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] selftests: x86: skip the tests if prerequisites aren't fulfilled
Date: Tue, 12 Mar 2024 09:07:15 -0700	[thread overview]
Message-ID: <ad272dc1-1b85-41ef-8454-4888a5ab95ee@intel.com> (raw)
In-Reply-To: <21f8dbe3-9de2-41ad-a8bd-61d66cb38e90@collabora.com>

On 3/12/2024 2:26 AM, Muhammad Usama Anjum wrote:
 >
> How can we check if AMX is available or not?

After a successful check_cpuid_xsave(), examining CPUID(eax=0xd, ecx=0) 
EDX: EAX, which reports the support bits of XCR0, can give assurance of 
AMX availability. Perhaps, this change is considerable on top of your patch:

static int check_cpuid_xtiledata(void)
{
         uint32_t eax, ebx, ecx, edx;
+       uint64_t xfeatures;

         __cpuid_count(CPUID_LEAF_XSTATE, CPUID_SUBLEAF_XSTATE_USER,
                       eax, ebx, ecx, edx);

+       xfeatures = eax + ((uint64_t)edx << 32);
+       if ((xfeatures & XFEATURE_MASK_XTILE) != XFEATURE_MASK_XTILE) {
+               ksft_print_msg("no AMX support\n");
+               return -1;
+       }

Nevertheless, I still believe that using arch_prctl(ARCH_GET_XCOMP_SUPP, 
...) remains a simple and legitimate approach for directly checking 
dynamic feature support from the kernel: 
https://docs.kernel.org/arch/x86/xstate.html

Thanks,
Chang

  reply	other threads:[~2024-03-12 16:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 18:37 [PATCH] selftests: x86: skip the tests if prerequisites aren't fulfilled Muhammad Usama Anjum
2024-03-09  1:06 ` Chang S. Bae
2024-03-11 17:02   ` Muhammad Usama Anjum
2024-03-11 17:39     ` Chang S. Bae
2024-03-12  9:26       ` Muhammad Usama Anjum
2024-03-12 16:07         ` Chang S. Bae [this message]
2024-03-12 17:28           ` Muhammad Usama Anjum
2024-03-11 12:39 ` Kirill A. Shutemov
2024-03-12  0:10 ` Binbin Wu

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=ad272dc1-1b85-41ef-8454-4888a5ab95ee@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=angquan21@gmail.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kernel@collabora.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=shuah@kernel.org \
    --cc=usama.anjum@collabora.com \
    --cc=weihong.zhang@intel.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