[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <66785246406c40e173fe7ce1470dd6d5292d1499.1647360971.git.reinette.chatre@intel.com>
Date: Tue, 15 Mar 2022 09:44:26 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: shuah@...nel.org, linux-kselftest@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, dave.hansen@...ux.intel.com,
sandipan@...ux.ibm.com, fweimer@...hat.com,
desnesn@...ux.vnet.ibm.com, mingo@...nel.org,
bauerman@...ux.ibm.com, mpe@...erman.id.au, msuchanek@...e.de,
linux-mm@...ck.org, chang.seok.bae@...el.com, bp@...e.de,
tglx@...utronix.de, hpa@...or.com, x86@...nel.org, luto@...nel.org
Subject: [PATCH V2 2/4] selftests/vm/pkeys: Use provided __cpuid_count() macro
kselftest.h makes the __cpuid_count() macro available
to conveniently call the CPUID instruction.
Remove the local CPUID wrapper and use __cpuid_count()
from already included kselftest.h instead.
__cpuid_count() from kselftest.h is used instead of the
macro provided by the compiler since gcc v4.4 (via cpuid.h)
because the selftest needs to be compiled with gcc v3.2,
the minimal required version for stable kernels.
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Sandipan Das <sandipan@...ux.ibm.com>
Cc: Florian Weimer <fweimer@...hat.com>
Cc: "Desnes A. Nunes do Rosario" <desnesn@...ux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Thiago Jung Bauermann <bauerman@...ux.ibm.com>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Michal Suchanek <msuchanek@...e.de>
Cc: linux-mm@...ck.org
Signed-off-by: Reinette Chatre <reinette.chatre@...el.com>
---
Changes since V1:
- Update changelog
- Remove Ram Pai from cc list (email address no longer valid)
- No longer include cpuid.h but obtain __cpuid_count() from
kselftest.h.
tools/testing/selftests/vm/pkey-x86.h | 21 ++-------------------
1 file changed, 2 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/vm/pkey-x86.h b/tools/testing/selftests/vm/pkey-x86.h
index e4a4ce2b826d..b078ce9c6d2a 100644
--- a/tools/testing/selftests/vm/pkey-x86.h
+++ b/tools/testing/selftests/vm/pkey-x86.h
@@ -80,19 +80,6 @@ static inline void __write_pkey_reg(u64 pkey_reg)
assert(pkey_reg == __read_pkey_reg());
}
-static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- /* ecx is often an input as well as an output. */
- asm volatile(
- "cpuid;"
- : "=a" (*eax),
- "=b" (*ebx),
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx));
-}
-
/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */
#define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */
#define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */
@@ -104,9 +91,7 @@ static inline int cpu_has_pkeys(void)
unsigned int ecx;
unsigned int edx;
- eax = 0x7;
- ecx = 0x0;
- __cpuid(&eax, &ebx, &ecx, &edx);
+ __cpuid_count(0x7, 0x0, eax, ebx, ecx, edx);
if (!(ecx & X86_FEATURE_PKU)) {
dprintf2("cpu does not have PKU\n");
@@ -142,9 +127,7 @@ int pkey_reg_xstate_offset(void)
/* assume that XSTATE_PKEY is set in XCR0 */
leaf = XSTATE_PKEY_BIT;
{
- eax = XSTATE_CPUID;
- ecx = leaf;
- __cpuid(&eax, &ebx, &ecx, &edx);
+ __cpuid_count(XSTATE_CPUID, leaf, eax, ebx, ecx, edx);
if (leaf == XSTATE_PKEY_BIT) {
xstate_offset = ebx;
--
2.25.1
Powered by blists - more mailing lists