Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp238431lqf; Fri, 26 Apr 2024 05:34:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQLq6cebwNKmcElaRCT4m1QHlhpJ+NToMbXoeU12I3F8iv5AmCteyEpb7jBDzEOyUzB99AC7yO4oFfcAuCumi5hRrjVM68D37jyOJl8g== X-Google-Smtp-Source: AGHT+IEFcW5DlgOeHL+CDIVqqTnGE+9uzTwEq4JyszXWI6HiUmMMrY3uqYrvCmYrGHSV0Kido9QF X-Received: by 2002:a17:906:3752:b0:a54:c130:21fd with SMTP id e18-20020a170906375200b00a54c13021fdmr1895103ejc.13.1714134892332; Fri, 26 Apr 2024 05:34:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714134892; cv=pass; d=google.com; s=arc-20160816; b=z9gEuDQct6i6OQckrXGJg2VOn5K42+Yvp58bQFFAt6ydUEqDZxjQw4YxKTM9BSRPBm UCHwaFOKQWMMXDPIOH3cctkIfhS+dLS+BS5X9AIcuvUiLIujXvyOVAPyvtmC66zW48wv vVzEQtCHHfuWgr8uQVpuevMLLcztA2ejW6L2UTMs/9CYMj8c5tgFvyKBzzfrIAynJRPn jWSp5Hd/hnXZliKsE9/UrX2CzdUaMsvpJbIXLO+o3EiXJtMIGR7OX2E8TnoQieUSoTdX rxkwMtoCMgtqgm1YhOT3YK56YfVBLGHOQ42hczYEXVuuoTJKy4XpnvOkKGTRZK8eh16C 0chg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vFDHYepn6bhFLIzwEWuDES2tyomi4jHJv4d47DCkNOk=; fh=ezDhvCRhIp+kaxZ5Ra9PEDycJOMnHMyQxQZs15WOv5w=; b=xyHeGgW10uBrOJuUkL+ZmOlZGDgHoUpn7/35YUI1QVyfzAwxkJEBF9s8od40hyB6kP +6E3XrzLUVqSdob2AW27Buthh94fLYvDeq0yeZmUpttIEGh1EiJ4a4nV9XnLSmYrp/Xf Srvg1bhy8EUBfCwSIrRDb/8be8mEcbpwq1fJEr8N7//2nbaKDJriGtK9Cnca5UoW+4Xg Jt5aTLNByU0hE5wemEkG4coCu6zJjbikp/sAwhb2SLnknmZxTOXSAdunwlFGgv93QYjq D1kEcyna6c0alXzcXP3BDRgl7CkD9rBRp2mkusIwGn8h/dGBOl5wYFQmygQEjQr1O1wU 5UnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qpIMwmIy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159990-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159990-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ky18-20020a170907779200b00a58868e99f9si3928473ejc.946.2024.04.26.05.34.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 05:34:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159990-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qpIMwmIy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159990-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159990-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DCE441F21251 for ; Fri, 26 Apr 2024 12:34:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EC151465A3; Fri, 26 Apr 2024 12:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qpIMwmIy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A22F3715E for ; Fri, 26 Apr 2024 12:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714134883; cv=none; b=LycA8JU+8TLqYDT44hcNuySEgrYMM7YcfW9ikpoDu0Xe9c7i231DzyVF7SInINmuXiJjzzy2FuEDvMNc7S0uxUcfw8pkdB1f2aZ9pCVaHZx82crNeTMJo/XBST68QuYFmebExqpId1Yp45Pt5czI2wBZIIKX2rw/c4WBhoTEUbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714134883; c=relaxed/simple; bh=e6PDpd9m5aNs9GktJ5+u/HJ8JwVHiegREXNQkYESuRk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KJ+lZZAH3fHdeHfkkTicCl0vCBVEWvXEOEPRGuAOYBAocxy9yRH1ZBgEY49qUdkwspmtRi6sfYOm8LxDjqIJb3rbFU3FYXg10DyO+deTuLl5cppV0qxyWTvhN9fH5dqjqV59KZ5CKSIHy4U+S3k5mabjjoSLVrEZEmLCKk8eW5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qpIMwmIy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A980C113CD; Fri, 26 Apr 2024 12:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714134882; bh=e6PDpd9m5aNs9GktJ5+u/HJ8JwVHiegREXNQkYESuRk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qpIMwmIyoyiZWggw8h4sZWS0KrLfPxF5ZR+sKaUI9LwBk5tgMhX44Dy2Ckm01o0+T YH3xfg1P8/1Iwb0UszWcSIroApZpv+QxlubysfBHGPBjTYHiJFphsQ6LiiJr6GC/Hc Oi4HZifg2pJH1MpNXuI67mtK3BJStMWef3RcqVQ6udoPR4Id91FWUUGAoF44ZKmLdF tdCHBwY9vXbhKJBF54Ca+FJmkzu9k9K71oeHBov9ZVh+HXt4OtATjn1KTq7UFxNZNl nbYkDShm2DTiWnPiKF31tT395Z6dQi/GxlTtvCRfm9LLda6St1xaG2aWFc/Q/YF8E/ eOJYJXGEGYjeg== Date: Fri, 26 Apr 2024 09:29:33 -0300 From: Arnaldo Carvalho de Melo To: linux-kernel@vger.kernel.org Cc: Adrian Hunter , Daniel Sneddon , Ian Rogers , Jiri Olsa , Namhyung Kim , Pawan Gupta , Thomas Gleixner Subject: Re: [PATCH 1/1 fyi] tools headers x86 cpufeatures: Sync with the kernel sources to pick TDX, Zen, APIC MSR fence changes Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Apr 25, 2024 at 06:19:07PM -0300, Arnaldo Carvalho de Melo wrote: > tldr; Just FYI, I'm carrying this on the perf tools tree. Sorry about the subject line, reused from a previous sync, will fix it up. - Arnaldo > Full explanation: > > There used to be no copies, with tools/ code using kernel headers > directly. From time to time tools/perf/ broke due to legitimate kernel > hacking. At some point Linus complained about such direct usage. Then we > adopted the current model. > > The way these headers are used in perf are not restricted to just > including them to compile something. > > There are sometimes used in scripts that convert defines into string > tables, etc, so some change may break one of these scripts, or new MSRs > may use some different #define pattern, etc. > > E.g.: > > $ ls -1 tools/perf/trace/beauty/*.sh | head -5 > tools/perf/trace/beauty/arch_errno_names.sh > tools/perf/trace/beauty/drm_ioctl.sh > tools/perf/trace/beauty/fadvise.sh > tools/perf/trace/beauty/fsconfig.sh > tools/perf/trace/beauty/fsmount.sh > $ > $ tools/perf/trace/beauty/fadvise.sh > static const char *fadvise_advices[] = { > [0] = "NORMAL", > [1] = "RANDOM", > [2] = "SEQUENTIAL", > [3] = "WILLNEED", > [4] = "DONTNEED", > [5] = "NOREUSE", > }; > $ > > The tools/perf/check-headers.sh script, part of the tools/ build > process, points out changes in the original files. > > So its important not to touch the copies in tools/ when doing changes in > the original kernel headers, that will be done later, when > check-headers.sh inform about the change to the perf tools hackers. > > To pick the changes from: > > 95a6ccbdc7199a14 ("x86/bhi: Mitigate KVM by default") > ec9404e40e8f3642 ("x86/bhi: Add BHI mitigation knob") > be482ff9500999f5 ("x86/bhi: Enumerate Branch History Injection (BHI) bug") > 0f4a837615ff925b ("x86/bhi: Define SPEC_CTRL_BHI_DIS_S") > 7390db8aea0d64e9 ("x86/bhi: Add support for clearing branch history at syscall entry") > > This causes these perf files to be rebuilt and brings some X86_FEATURE > that will be used when updating the copies of > tools/arch/x86/lib/mem{cpy,set}_64.S with the kernel sources: > > CC /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o > CC /tmp/build/perf/bench/mem-memset-x86-64-asm.o > > And addresses this perf build warning: > > Warning: Kernel ABI header differences: > diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h > > Cc: Adrian Hunter > Cc: Daniel Sneddon > Cc: Ian Rogers > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Pawan Gupta > Cc: Thomas Gleixner > Signed-off-by: Arnaldo Carvalho de Melo > --- > tools/arch/x86/include/asm/cpufeatures.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h > index a38f8f9ba6572912..3c7434329661c66e 100644 > --- a/tools/arch/x86/include/asm/cpufeatures.h > +++ b/tools/arch/x86/include/asm/cpufeatures.h > @@ -461,11 +461,15 @@ > > /* > * Extended auxiliary flags: Linux defined - for features scattered in various > - * CPUID levels like 0x80000022, etc. > + * CPUID levels like 0x80000022, etc and Linux defined features. > * > * Reuse free bits when adding new feature flags! > */ > #define X86_FEATURE_AMD_LBR_PMC_FREEZE (21*32+ 0) /* AMD LBR and PMC Freeze */ > +#define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* "" Clear branch history at syscall entry using SW loop */ > +#define X86_FEATURE_BHI_CTRL (21*32+ 2) /* "" BHI_DIS_S HW control available */ > +#define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* "" BHI_DIS_S HW control enabled */ > +#define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* "" Clear branch history at vmexit using SW loop */ > > /* > * BUG word(s) > @@ -515,4 +519,5 @@ > #define X86_BUG_SRSO X86_BUG(1*32 + 0) /* AMD SRSO bug */ > #define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* AMD DIV0 speculation bug */ > #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* CPU is vulnerable to Register File Data Sampling */ > +#define X86_BUG_BHI X86_BUG(1*32 + 3) /* CPU is affected by Branch History Injection */ > #endif /* _ASM_X86_CPUFEATURES_H */ > -- > 2.44.0 >