Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp920358pxb; Tue, 8 Feb 2022 05:36:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyzVf3/TEdgyKOVSySo34VdUZX6nDaPyTvmckZpL+zupSP7OwiZQmAkULi4iw4uWvjYqsU X-Received: by 2002:a17:90b:1e05:: with SMTP id pg5mr1419986pjb.56.1644327384874; Tue, 08 Feb 2022 05:36:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644327384; cv=none; d=google.com; s=arc-20160816; b=rZSXQyhAjG7BplqB5keMnxNUYF5x9lXRqmkinjQkfxiWbkHvTIvZW56mNFn3g2CA9G qkSG2QflSvltfnJILLp+fudK6E0m6KTbQWWrDZkMefaNlxnJJe5/1iL4YiiBwj451M2W NeYiSKWMlwdJzv/kSX/oGr/p+es7VBSFH/Y8o7Zmv9+WmsbU2iCQ7+dyJUq2RSgTKVYo wcTc2tYQY+03Zabu2W4/VfdHo4Z769Qih1q5wBpO14SxVpWPTP4FKu71WdqqrOkFWzOI wLEPkuXtzAOPlezOxB3I8N0KlF+yj4P6vXnMuf7otOF1yljt7Gmrn/hFuew/IKfuCqOT bWvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=vAANZBXJ7sjdB6HJV8mdniD7XEYfQ+ohI4e6g+PRzDA=; b=WLtAAo81XlYg5Yxec29TayFWEhBtD+Wde67tY7MaqNB+0MNO0oVA1q+OZNX7rCDDkw dvZwfT7hUkQOTxspT6xtlsKuzxV3aDyLjKXoBUmN0amszIz42BX92yR7u8kt9Xub+eD/ 25jbRrz04H4BreX/z/da9yuA8Ih2iJLyqIDj+vKMka5qnpvWl8ba56Vpq0Ghq/31IVtn Z+VLx2SpycU4R3qOEIGh/9N3ujezB/QhsN1Twub+rEWPC4KnL6mEtIborFy+Ctz2cAM0 K9VFdQkEGxXj7FvZ1cgr0/ICMJ7aaDzHGBwJkvTFu8OmFAUZVJkHa34YAIyppVgWSjel XyWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=b7VXqSPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17si14151467plh.278.2022.02.08.05.36.09; Tue, 08 Feb 2022 05:36:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=b7VXqSPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346477AbiBGSI3 (ORCPT + 99 others); Mon, 7 Feb 2022 13:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344328AbiBGSAw (ORCPT ); Mon, 7 Feb 2022 13:00:52 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC44C0401DA for ; Mon, 7 Feb 2022 10:00:51 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id h11so3610843ilq.9 for ; Mon, 07 Feb 2022 10:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vAANZBXJ7sjdB6HJV8mdniD7XEYfQ+ohI4e6g+PRzDA=; b=b7VXqSPJlQilf3OxElTU4ZKiyU9lyp6MPPkBwL3AuC4i1t/FNz/Jjp2J9pCnwsQOFh wn7MaGFgiAcqPlfAb36NLajsoEJnZh84xdKMn9a02dgLgIbq7gCaCCARpHEsjDz/hDRZ 1NtPXaqXy+5I3ONdQazd/+U2JAUCjLtZfNiE8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vAANZBXJ7sjdB6HJV8mdniD7XEYfQ+ohI4e6g+PRzDA=; b=guOv4r9PkR7e0VATjS3Y37nPDM3fx5KJ3qmWCX/MX0AdtAHIYa/0rWoRglPA5+tsGJ gP2pIb6oxaBma6NHh3NG+ZFwS/vd4hZGj4C5+/sHQ9rilMxaXATH9V9dh8EBLwlI0lPE qJ3ieQ2clu4cvalcl1vjvza3xrS4tJ0IXJrUulEGRyIBMT3nEuKqx+mII7WT16UOiz+4 v3H3+7t/N0wAPdGg48oLtjMUHf1bmKKmDCJysL7fHCW481cIn2+6V7rGRFB8HgBPtebw NIn3sW1cFoCN1Mx+vXH+v3AexfyPvFzUVvrSeUv40ebmYgEfxEk791Zn4SKLgTH/mnB9 zSug== X-Gm-Message-State: AOAM531TA+CNNfw2ZV1vdxA4TETcNhNdohvc7LURucD+cnW0t4RzGC5q C2QaTBzuwl3l6atKaPFaZulJ0g== X-Received: by 2002:a92:c5b1:: with SMTP id r17mr350950ilt.320.1644256850455; Mon, 07 Feb 2022 10:00:50 -0800 (PST) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id c13sm2055151ilq.50.2022.02.07.10.00.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 10:00:50 -0800 (PST) Subject: Re: [PATCH 0/3] selftests: Remove duplicate CPUID wrappers To: Reinette Chatre , shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ram Pai , Sandipan Das , Florian Weimer , "Desnes A. Nunes do Rosario" , Ingo Molnar , Thiago Jung Bauermann , Michael Ellerman , Michal Suchanek , linux-mm@kvack.org, "Chang S . Bae" , Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Andy Lutomirski , Shuah Khan References: <81df8c0e-fde6-f3b8-f988-b539f193635b@linuxfoundation.org> From: Shuah Khan Message-ID: <3787aee3-064a-dce7-1ab1-0dcabd56a100@linuxfoundation.org> Date: Mon, 7 Feb 2022 11:00:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/4/22 5:11 PM, Reinette Chatre wrote: > Hi Shuah, > > On 2/4/2022 3:39 PM, Shuah Khan wrote: >> On 2/4/22 12:17 PM, Reinette Chatre wrote: >>> 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 but having one is also >>> unnecessary because of the existence of a macro that can >>> be used instead. >>> >>> This series replaces private CPUID wrappers with calls >>> to the __cpuid_count() macro from cpuid.h as made available >>> by gcc and clang/llvm. >>> >>> Cc: Dave Hansen >>> Cc: Ram Pai >>> 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 (3): >>>    selftests/vm/pkeys: Use existing __cpuid_count() macro >>>    selftests/x86/amx: Use existing __cpuid_count() macro >>>    selftests/x86/corrupt_xstate_header: Use existing __cpuid_count() >>>      macro >>> >>>   tools/testing/selftests/vm/pkey-x86.h         | 22 +++--------------- >>>   tools/testing/selftests/x86/amx.c             | 23 +++++-------------- >>>   .../selftests/x86/corrupt_xstate_header.c     | 17 ++------------ >>>   3 files changed, 11 insertions(+), 51 deletions(-) >>> >> >> I am all for this cleanup. However, I am not finding __cpuid_count() >> marco on my system with gcc: >> >> gcc --version >> gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 >> >> My concern is regression on older gcc versions. > > Please see this message from our earlier thread where you were able > to find it on your system: > https://lore.kernel.org/linux-kselftest/63293c72-55ca-9446-35eb-74aff4c8ba5d@linuxfoundation.org/ > Right. After I sent off the response, I was thinking we discussed this before. Thanks for the refresh. > As mentioned in that thread, on my system it arrived via user space's > libgcc-dev package. This does not seem to be the first time including > files from this source - I did a quick check and from what I can tell > existing kselftest includes like stdarg.h, stdbool.h, stdatomic.h, > unwind.h, x86intrin.h ... arrive via libgcc-dev. > This will work fine on newer versions of gcc/clang. However this could fail when mainline kselftest is used on stable releases on test rings and so on, especially if they have older versions of gcc/clang. We will have to find a solution for this. Instead of deleting the local define, let's keep it under ifndef __cpuid_count /usr/lib/gcc/x86_64-linux-gnu/11/include/cpuid.h #define __cpuid_count(level, count, a, b, c, d) \ __asm__ __volatile__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "2" (count)) thanks, -- Shuah