From patchwork Mon Apr 25 21:01:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 12826257 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 0A0DFC433EF for ; Mon, 25 Apr 2022 21:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC7BE6B00B6; Mon, 25 Apr 2022 17:01:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D79396B00B7; Mon, 25 Apr 2022 17:01:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B544F6B00B8; Mon, 25 Apr 2022 17:01:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id A23866B00B6 for ; Mon, 25 Apr 2022 17:01:24 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 80F4C121C4F for ; Mon, 25 Apr 2022 21:01:24 +0000 (UTC) X-FDA: 79396622088.14.31DDF77 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf19.hostedemail.com (Postfix) with ESMTP id 5A4BC1A004E for ; Mon, 25 Apr 2022 21:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650920483; x=1682456483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iSiLdTbg02IHLCZytLXHOYjcwvRsrkoy2ujNkUnkHVM=; b=g44QPv7UyThtA1bvl2yFxQWMP3iOp39uoCB2V1UOLM74R/n2P/YKqG9T B5OheGhUyy2EiLVlhjIGMO+ZW//IUxjBB6j20ElVu7o7XpTMC+GIkdV0T 2mJdgBHpmhmPewJ1on3aFE33YJZ3B3E+V1TYi4di7QATZbl3DNQWzMpQ3 ZIo5yobPWCXq3xNXCbH4+Eck++JRwKhJrv/1i1hHhPxAQMIqsYN6LAh53 CBRQSrNpBrirME9KrUd+BYSNbHium94ehosJN26aXsMwXPo0aeZjmmyiu x+xWjodsWGrC8kpH1utolVYU7xNV2cDOKEBrNvJ9X2IolY1yGvFwmeC1X g==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="328304052" X-IronPort-AV: E=Sophos;i="5.90,289,1643702400"; d="scan'208";a="328304052" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 14:01:19 -0700 X-IronPort-AV: E=Sophos;i="5.90,289,1643702400"; d="scan'208";a="579499505" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 14:01:19 -0700 From: Reinette Chatre To: shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: 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, mingo@redhat.com, hpa@zytor.com, luto@kernel.org, x86@kernel.org Subject: [PATCH V3 4/4] selftests/x86/corrupt_xstate_header: Use provided __cpuid_count() macro Date: Mon, 25 Apr 2022 14:01:14 -0700 Message-Id: <20f16bc002e1a328cda02a7b003e728b550951b7.1650918160.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: 5keodhgj6ch78fzmiw3t7q6kyik4dteb Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=g44QPv7U; spf=none (imf19.hostedemail.com: domain of reinette.chatre@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=reinette.chatre@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5A4BC1A004E X-HE-Tag: 1650920480-471534 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 --- No changes since V2. 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);