Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
	shuah@kernel.org, hpa@zytor.com, x86@kernel.org,
	dave.hansen@linux.intel.com, bp@alien8.de, mingo@redhat.com,
	tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kirill@shutemov.name,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v5 1/3] selftests/lam: Move cpu_has_la57() to use cpuinfo flag
Date: Fri, 24 Jan 2025 08:14:41 -0800	[thread overview]
Message-ID: <e1aefeca-8f85-48c9-8972-1c23b34aea7b@intel.com> (raw)
In-Reply-To: <63f8fa8ac016f9f294230657e9069a616bce6141.1732728879.git.maciej.wieczor-retman@intel.com>

On 11/27/24 09:35, Maciej Wieczor-Retman wrote:
> -/* Check 5-level page table feature in CPUID.(EAX=07H, ECX=00H):ECX.[bit 16] */
>  static inline int cpu_has_la57(void)
>  {
> -	unsigned int cpuinfo[4];
> -
> -	__cpuid_count(0x7, 0, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]);
> -
> -	return (cpuinfo[2] & (1 << 16));
> +	return !system("grep -wq la57 /proc/cpuinfo");
>  }

I would rather we find another way.

First, we've documented the behavior a bit in here:

	https://docs.kernel.org/arch/x86/cpuinfo.html

The important part is:

	"The absence of a flag in /proc/cpuinfo by itself means almost
	nothing to an end user."

Even worse, let's say there's a CPU bug and we say define a bug bit:

	bugs		: spectre_v1 spectre_v2 ... la57_is_broken

How is that grep going to work out? ;)

Could you poke around and see if there is any existing ABI that we can
use to query LA57 support? Maybe one of the things KVM exports, or some
TASK_SIZE_MAX comparisons?


  reply	other threads:[~2025-01-24 16:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 17:35 [PATCH v5 0/3] selftests/lam: get_user additions and LAM enabled check Maciej Wieczor-Retman
2024-11-27 17:35 ` [PATCH v5 1/3] selftests/lam: Move cpu_has_la57() to use cpuinfo flag Maciej Wieczor-Retman
2025-01-24 16:14   ` Dave Hansen [this message]
2025-01-24 20:17     ` Maciej Wieczor-Retman
2025-01-24 20:24       ` Dave Hansen
2025-01-24 20:29       ` Maciej Wieczor-Retman
2024-11-27 17:35 ` [PATCH v5 2/3] selftests/lam: Skip test if LAM is disabled Maciej Wieczor-Retman
2025-01-24 16:23   ` Dave Hansen
2025-01-24 20:09     ` Maciej Wieczor-Retman
2024-11-27 17:35 ` [PATCH v5 3/3] selftests/lam: Test get_user() LAM pointer handling Maciej Wieczor-Retman
2025-01-24 16:32   ` Dave Hansen
2025-01-24 20:19     ` Maciej Wieczor-Retman
2025-01-15  9:06 ` [PATCH v5 0/3] selftests/lam: get_user additions and LAM enabled check Maciej Wieczor-Retman
2025-01-23 21:52   ` Shuah Khan

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=e1aefeca-8f85-48c9-8972-1c23b34aea7b@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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