Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@linux.intel.com>
Cc: Sandipan Das <sandipan@linux.ibm.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: "Desnes A. Nunes do Rosario" <desnesn@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thiago Jung Bauermann <bauerman@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Suchanek <msuchanek@suse.de>
Cc: linux-mm@kvack.org
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Reinette Chatre and committed by
Shuah Khan
0dba8dae a23039c7

+2 -19
+2 -19
tools/testing/selftests/vm/pkey-x86.h
··· 80 80 assert(pkey_reg == __read_pkey_reg()); 81 81 } 82 82 83 - static inline void __cpuid(unsigned int *eax, unsigned int *ebx, 84 - unsigned int *ecx, unsigned int *edx) 85 - { 86 - /* ecx is often an input as well as an output. */ 87 - asm volatile( 88 - "cpuid;" 89 - : "=a" (*eax), 90 - "=b" (*ebx), 91 - "=c" (*ecx), 92 - "=d" (*edx) 93 - : "0" (*eax), "2" (*ecx)); 94 - } 95 - 96 83 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */ 97 84 #define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */ 98 85 #define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */ ··· 91 104 unsigned int ecx; 92 105 unsigned int edx; 93 106 94 - eax = 0x7; 95 - ecx = 0x0; 96 - __cpuid(&eax, &ebx, &ecx, &edx); 107 + __cpuid_count(0x7, 0x0, eax, ebx, ecx, edx); 97 108 98 109 if (!(ecx & X86_FEATURE_PKU)) { 99 110 dprintf2("cpu does not have PKU\n"); ··· 127 142 /* assume that XSTATE_PKEY is set in XCR0 */ 128 143 leaf = XSTATE_PKEY_BIT; 129 144 { 130 - eax = XSTATE_CPUID; 131 - ecx = leaf; 132 - __cpuid(&eax, &ebx, &ecx, &edx); 145 + __cpuid_count(XSTATE_CPUID, leaf, eax, ebx, ecx, edx); 133 146 134 147 if (leaf == XSTATE_PKEY_BIT) { 135 148 xstate_offset = ebx;