From patchwork Mon Apr 25 21:01:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 12826255 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 B9B41C433FE for ; Mon, 25 Apr 2022 21:01:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1306F6B00B5; Mon, 25 Apr 2022 17:01:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11D226B00B4; Mon, 25 Apr 2022 17:01:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E14A66B00B7; Mon, 25 Apr 2022 17:01:23 -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 CA5E76B00B4 for ; Mon, 25 Apr 2022 17:01:23 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A3EA82590 for ; Mon, 25 Apr 2022 21:01:23 +0000 (UTC) X-FDA: 79396622046.30.82DDF91 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf19.hostedemail.com (Postfix) with ESMTP id 77E0F1A0046 for ; Mon, 25 Apr 2022 21:01:19 +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:mime-version: content-transfer-encoding; bh=SFrZIOQtKpUy81uaSvHixmsB2hBWhZKBOMyLkzWOzZY=; b=RzTAKnBynjMGOwIv0zXkFEOlRhnLVNx9wpYEoyySnzMtYt7ze+B600i/ ZdmTwY2K/R3uoHhBxTaj0sxITirTE4kubGy+pta7XObiPK57tMFy3aKUy 9T3Ip1SUq7xsAF/IUU523CdS77bY7MCUCyF0P4FICi97GMIynzRsdeRhH yhsm8Y03+9C/kNu2FcrnWmsqWqqjngKFXfyTkCL0nt/Y7WptaJJbvpQ2w iRHB6U3aKCCSmOf1scPkjayR+8Hx0tDt/BSGqMM7XPrdM6R2f+AqJ9Fh4 NTW2bW6Gc53moM4y1GYfsUFELE/r2P4WgM+DoGiEbgKmHYRFzQ6VQ6458 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="328304047" X-IronPort-AV: E=Sophos;i="5.90,289,1643702400"; d="scan'208";a="328304047" 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="579499489" 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 0/4] selftests: Remove duplicate CPUID wrappers Date: Mon, 25 Apr 2022 14:01:10 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Stat-Signature: wx16sy7s1kzw6747qg9i9tktz3zff7ym Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=RzTAKnBy; 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: 77E0F1A0046 X-HE-Tag: 1650920479-140230 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: Changes since V2: - V2: https://lore.kernel.org/lkml/cover.1647360971.git.reinette.chatre@intel.com/ - Rebased against v5.18-rc4, no functional changes. - Add text in cover letter and first patch to highlight that the __cpuid_count() macro provided is not a new implementation but copied from gcc. Changes since V1: - V1: https://lore.kernel.org/lkml/cover.1644000145.git.reinette.chatre@intel.com/ - Change solution to not use __cpuid_count() from compiler's cpuid.h but instead use a local define of __cpuid_count() provided in kselftest.h to ensure tests continue working in all supported environments. (Shuah) - Rewrite cover letter and changelogs to reflect new solution. A few tests that require running CPUID do so with a private implementation of a wrapper for CPUID. This duplication of the CPUID wrapper should be avoided. Both gcc and clang/LLVM provide wrappers for CPUID but the wrappers are not available in the minimal required version of gcc, v3.2, that the selftests need to be used in. __cpuid_count() was added to gcc in v4.4, which is ok for kernels after v4.19 when the gcc minimal required version was changed to v4.6. Copy gcc's __cpuid_count() to provide a local define of __cpuid_count() to kselftest.h to ensure that selftests can still work in environments with older stable kernels (v4.9 and v4.14 that have the minimal required version of gcc of v3.2). Update tests with private CPUID wrappers to use the new macro. Cc: Dave Hansen Cc: Sandipan Das Cc: Florian Weimer Cc: "Desnes A. Nunes do Rosario" Cc: Ingo Molnar Cc: Thiago Jung Bauermann Cc: Michael Ellerman Cc: Michal Suchanek Cc: linux-mm@kvack.org Cc: Chang S. Bae Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Andy Lutomirski Reinette Chatre (4): selftests: Provide local define of __cpuid_count() selftests/vm/pkeys: Use provided __cpuid_count() macro selftests/x86/amx: Use provided __cpuid_count() macro selftests/x86/corrupt_xstate_header: Use provided __cpuid_count() macro tools/testing/selftests/kselftest.h | 15 ++++++++++++ tools/testing/selftests/vm/pkey-x86.h | 21 ++-------------- tools/testing/selftests/x86/amx.c | 24 ++++++------------- .../selftests/x86/corrupt_xstate_header.c | 16 ++----------- 4 files changed, 26 insertions(+), 50 deletions(-) base-commit: af2d861d4cd2a4da5137f795ee3509e6f944a25b