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: 12826246 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB11BC433FE for ; Mon, 25 Apr 2022 21:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbiDYVEZ (ORCPT ); Mon, 25 Apr 2022 17:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237504AbiDYVEY (ORCPT ); Mon, 25 Apr 2022 17:04:24 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19A718366 for ; Mon, 25 Apr 2022 14:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650920479; x=1682456479; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SFrZIOQtKpUy81uaSvHixmsB2hBWhZKBOMyLkzWOzZY=; b=CQLzYRpO2U7cjTLDnntHLV0k5qSnUlwxqHbina2zj8264dQP5xoGN1PS z1EKEe6J6O+0a+tng218fMYb9fKotZuqV7wVhd6d/nd+SYmMy3mEcdij8 Bhjfp77R60cJMreu5zvZuZUaHOWLk+UCwUZ9PDYdHNfhr2Kd7PdAQKhHA 04uhho0UDJ42VOEsqkNOJMFp8p/ClKSYY0FTmBj/CzGlS5DkFXaRu2nNZ 3fu5UJ//9eQE5xYonHLFH9J4SvmrSKbnBtidcU5xa73cjCh2dEzgtRu89 OaxmKcE/AtU/MD2fWqZnXOHLkzdu/nWmvbIEdtdGHWtm4+Us6g7zOMzd3 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="290502301" X-IronPort-AV: E=Sophos;i="5.90,289,1643702400"; d="scan'208";a="290502301" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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