From patchwork Tue Mar 15 16:44:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 12781658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2242C433EF for ; Tue, 15 Mar 2022 16:44:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 567058D0006; Tue, 15 Mar 2022 12:44:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F1288D0001; Tue, 15 Mar 2022 12:44:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 343448D0006; Tue, 15 Mar 2022 12:44:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 0EA978D0001 for ; Tue, 15 Mar 2022 12:44:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D11FC23F3D for ; Tue, 15 Mar 2022 16:44:53 +0000 (UTC) X-FDA: 79247194866.02.0137B54 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf04.hostedemail.com (Postfix) with ESMTP id 624064000E for ; Tue, 15 Mar 2022 16:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647362692; x=1678898692; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PoCY1b2mtOop0l56GUUK95GUNFxvSin6gRz+vAzCjS0=; b=iyzrLq6CA7qDdmpifTGb4rPMsW/uMZAOcBlWKTEEQiz//Iys0c3Ul7/U ll77hrjU8Ddw9QK4Sfs4zSw4lC2SPfdJDY/oZpqhyNrYlHOrn3RT52koA W2H+ngoUAsJy/EEAPqsKYa5uMlfpiuiPrRv/kEyx1B4digIjpTgVIwI8R K/HG/AIpKjMb5hvakri2tv48EOBdXaKCM15nMALXIHqVpb40/tEMCJcfl wpoPqVHhYSgaEZL0ipHcvoXawTOOq08cOTeZn4IWSji/ZGUwEQQ+9MmqE RghPy6ZL5f/j0PgcasZjBvgmsE8pYFanETLbwWFpEkr61ylSn5OS2EFb0 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="256081587" X-IronPort-AV: E=Sophos;i="5.90,184,1643702400"; d="scan'208";a="256081587" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2022 09:44:48 -0700 X-IronPort-AV: E=Sophos;i="5.90,184,1643702400"; d="scan'208";a="714236358" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2022 09:44:47 -0700 From: Reinette Chatre To: shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, sandipan@linux.ibm.com, fweimer@redhat.com, desnesn@linux.vnet.ibm.com, mingo@kernel.org, bauerman@linux.ibm.com, mpe@ellerman.id.au, msuchanek@suse.de, linux-mm@kvack.org, chang.seok.bae@intel.com, bp@suse.de, tglx@linutronix.de, hpa@zytor.com, x86@kernel.org, luto@kernel.org Subject: [PATCH V2 4/4] selftests/x86/corrupt_xstate_header: Use provided __cpuid_count() macro Date: Tue, 15 Mar 2022 09:44:28 -0700 Message-Id: <80ebe8386496e4cc266637fe1d84b7f083f8788f.1647360971.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 624064000E X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iyzrLq6C; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf04.hostedemail.com: domain of reinette.chatre@intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=reinette.chatre@intel.com X-Stat-Signature: cz3p5hrydeq16z3t54hm8q3r8p34otix X-Rspamd-Server: rspam04 X-HE-Tag: 1647362692-262046 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: kselftest.h makes the __cpuid_count() macro available to conveniently call the CPUID instruction. Remove the local CPUID wrapper and use __cpuid_count() from 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 supported with gcc v3.2, the minimal required version for stable kernels. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: x86@kernel.org Signed-off-by: Reinette Chatre --- Changes since V1: - Update changelog - No longer include cpuid.h but obtain __cpuid_count() from kselftest.h. .../selftests/x86/corrupt_xstate_header.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/x86/corrupt_xstate_header.c b/tools/testing/selftests/x86/corrupt_xstate_header.c index ab8599c10ce5..cf9ce8fbb656 100644 --- a/tools/testing/selftests/x86/corrupt_xstate_header.c +++ b/tools/testing/selftests/x86/corrupt_xstate_header.c @@ -17,25 +17,13 @@ #include #include -static inline void __cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) -{ - asm volatile( - "cpuid;" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (*eax), "2" (*ecx)); -} +#include "../kselftest.h" /* For __cpuid_count() */ static inline int xsave_enabled(void) { unsigned int eax, ebx, ecx, edx; - eax = 0x1; - ecx = 0x0; - __cpuid(&eax, &ebx, &ecx, &edx); + __cpuid_count(0x1, 0x0, eax, ebx, ecx, edx); /* Is CR4.OSXSAVE enabled ? */ return ecx & (1U << 27);