linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Shuah Khan <skhan@linuxfoundation.org>, <shuah@kernel.org>,
	<linux-kselftest@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Ram Pai <linuxram@us.ibm.com>,
	Sandipan Das <sandipan@linux.ibm.com>,
	"Florian Weimer" <fweimer@redhat.com>,
	"Desnes A. Nunes do Rosario" <desnesn@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	"Thiago Jung Bauermann" <bauerman@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Michal Suchanek <msuchanek@suse.de>, <linux-mm@kvack.org>,
	"Chang S . Bae" <chang.seok.bae@intel.com>,
	Borislav Petkov <bp@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	<x86@kernel.org>, Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH 0/3] selftests: Remove duplicate CPUID wrappers
Date: Mon, 7 Feb 2022 11:13:04 -0800	[thread overview]
Message-ID: <58794e0e-43f5-f6cb-6b34-ad299ddac69f@intel.com> (raw)
In-Reply-To: <3787aee3-064a-dce7-1ab1-0dcabd56a100@linuxfoundation.org>

Hi Shuah,

On 2/7/2022 10:00 AM, Shuah Khan wrote:

> 
> This will work fine on newer versions of gcc/clang. However this could
> fail when mainline kselftest is used on stable releases on test rings
> and so on, especially if they have older versions of gcc/clang.

Indeed. It thus seems that kselftest has a minimal required version for
gcc/clang that is not the current mainline minimal version but the
minimal version of the oldest supported stable kernel, which is v4.9.

__cpuid_count() was added to gcc in commit:
cb0dee885cb30b4e9beeef070cf000baa7d09abe and thus available since
gcc 4.4.

Looking at Documentation/Changes or later Documentation/process/changes.rst
kernels v4.9 and v4.14 have the minimal required version of
gcc of 3.2. So this change would encounter an issue if mainline
kselftest is used to test a v4.9 or v4.14 kernel on a system that only
supports its minimal gcc.

Kernel v4.19 moved the gcc minimal required version to 4.6 that does
contain this macro.

There does not seem to be a minimum required version of clang/LLVM
in v4.19. The first time I see a minimal version for Clang/LLVM
for a stable kernel is in kernel v5.10 with Clang/LLVM minimal
version 10.0.1 and from what I can tell the __cpuid_count() macro
was added to Clang/LLVM in version 3.4.0 
(commit 4dcb5dbb53ea4fbeab48bc6bc3c4d392361dabc1).

> 
> We will have to find a solution for this. Instead of deleting the local
> define, let's keep it under ifndef __cpuid_count
> 
> /usr/lib/gcc/x86_64-linux-gnu/11/include/cpuid.h
> 
> #define __cpuid_count(level, count, a, b, c, d)                         \
>   __asm__ __volatile__ ("cpuid\n\t"                                     \
>                         : "=a" (a), "=b" (b), "=c" (c), "=d" (d)        \
>                         : "0" (level), "2" (count))
> 

Will do. I see that gcc obtained the volatile qualifier in v11.1 so I can use
the most recent macro as you have here.

Reinette


      reply	other threads:[~2022-02-07 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 19:17 Reinette Chatre
2022-02-04 19:17 ` [PATCH 1/3] selftests/vm/pkeys: Use existing __cpuid_count() macro Reinette Chatre
2022-02-04 23:39 ` [PATCH 0/3] selftests: Remove duplicate CPUID wrappers Shuah Khan
2022-02-05  0:11   ` Reinette Chatre
2022-02-07 18:00     ` Shuah Khan
2022-02-07 19:13       ` Reinette Chatre [this message]

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=58794e0e-43f5-f6cb-6b34-ad299ddac69f@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=bauerman@linux.ibm.com \
    --cc=bp@suse.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=desnesn@linux.vnet.ibm.com \
    --cc=fweimer@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxram@us.ibm.com \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=msuchanek@suse.de \
    --cc=sandipan@linux.ibm.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