From patchwork Thu Nov 30 21:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 172129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp690768vqy; Thu, 30 Nov 2023 13:16:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGseuApEVNTIN9IXRE3ONiY3/64lyX4+mnm0pKc5ml3teS+gFQ1/nNWf44bOlA2AcSrwMjZ X-Received: by 2002:a05:6a20:8f0f:b0:18c:531a:a503 with SMTP id b15-20020a056a208f0f00b0018c531aa503mr21054883pzk.2.1701379012572; Thu, 30 Nov 2023 13:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701379012; cv=none; d=google.com; s=arc-20160816; b=hP8DgnYd5xWBi+GZXKeROoYYx112Qk6qdL6sVCZXlU+AzzQ0lWQZqy31CZ+Y8mhzQ8 9I2HgkJmOHSm1cJkQVs7SB2TV/F1JbdbxtSO8mBO+J0zCh1q6pEoP4/dwul39BYb1kLw qBPBjejLigqla0w16BjhZEzqWepPHE1SC5vAuAI1tdnQ1I92j+7IZ9NYHuB7tx9/ehSc qRBKszek+zL7y8NFkBJ9zZ7nL65586NHxSCdogty0nOu424HoetkFzmmw9uuXrBjDeKk iIQ/ReNuHjzGTAyOIkBx862V+Um1/jEYrMCvd2p/6pxXHGf++1ret9Y06A+ucr3VCR6M wG4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Bl8RA0BfuW7vlYWghNCY0FMcpqvsacHdKivd0p7LxBw=; fh=lC3L+tLu9jMrTwLXdci/D+zTDmYl6oRylGrfIkeVy60=; b=Y+uIQIYupMN8jdcBUodQdQl4DQRhb4cVCSUgTXl53xR5ZmltlH4SbV1fr7aH8hJSyy ZgZ9koRERx6B0VwtmKRqijNegP3ctN1s9905t7/O9biV5VbDhwH1Xeo9z/3vNe3D790a XCzkgdWyFKsYlnwU3I6U4Vsne705D2nXeGVZCb9TXkukp8Pq5v7eE608Zh/G4vRuRmRq sZiFFRoM8XX9QXjMxaiw3agjAloNGK8ggfdleQGBnk/fpkvcGMZlTJgeTCmdEsI2TRYP D4xqd0S9DY8fHnMRgT1nS1XDKBYyMKHsY8FfvGL3sAmmZWXxGRQgrYLp1v+31TtFCN71 0IKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pd09TXUt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Nue5eO5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 18-20020a630212000000b005898699b2afsi2220635pgc.176.2023.11.30.13.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 13:16:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pd09TXUt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Nue5eO5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7C7FE8029AE4; Thu, 30 Nov 2023 13:16:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376915AbjK3VQh (ORCPT + 99 others); Thu, 30 Nov 2023 16:16:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376859AbjK3VQ2 (ORCPT ); Thu, 30 Nov 2023 16:16:28 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC92610D9; Thu, 30 Nov 2023 13:16:34 -0800 (PST) Date: Thu, 30 Nov 2023 21:16:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701378992; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bl8RA0BfuW7vlYWghNCY0FMcpqvsacHdKivd0p7LxBw=; b=pd09TXUt6HDx+jxSLghOxJjtamtW7+LJf1DcKhUMmDTaFCrTYxMyHppvtcTEmifNEnOqlT 4XLvgy4XbH93J/r+J6DG0ZYEwGWXkOSUXgp00h+sBvdt5ammlcTZhx0wMPCiy4yFaxlZR5 c6VwEHpQ9hKGBNMEdzHSB/6saxkIirTi1RsrgjQAqhYd+7gleUtEO3sY5tVedZQDMCePA9 o8NLn/vmlbtaLsBmP+YtbyRqFAPMEFYP2vg8omLXCmzgDbNdTnQ1rTkmtthYyqMP0n6AH/ LGb8zJT+DKUtNRePhqz9vg2BmyQDtdTuWWCo1wI8ZBVRwetpsjjgy9vTG4gq1Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701378992; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bl8RA0BfuW7vlYWghNCY0FMcpqvsacHdKivd0p7LxBw=; b=Nue5eO5qrt/Uj+bhXMM2QLAAic/mFkxzBotxQHfrx9WtknmXiPCHcqte+EGb9WpTU6laGm i5TZet/tHNKVeaBA== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/percpu] x86/callthunks: Fix and unify call thunks assembly snippets Cc: Uros Bizjak , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231105213731.1878100-4-ubizjak@gmail.com> References: <20231105213731.1878100-4-ubizjak@gmail.com> MIME-Version: 1.0 Message-ID: <170137899220.398.1284129355490971042.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 13:16:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781761631325160358 X-GMAIL-MSGID: 1784025199002137049 The following commit has been merged into the x86/percpu branch of tip: Commit-ID: 2adeed985a42ff3334e6898c8c0827e7626c1336 Gitweb: https://git.kernel.org/tip/2adeed985a42ff3334e6898c8c0827e7626c1336 Author: Uros Bizjak AuthorDate: Sun, 05 Nov 2023 22:34:37 +01:00 Committer: Ingo Molnar CommitterDate: Thu, 30 Nov 2023 20:06:17 +01:00 x86/callthunks: Fix and unify call thunks assembly snippets Currently thunk debug macros explicitly define %gs: segment register prefix for their percpu variables. This is not compatible with !CONFIG_SMP, which requires non-prefixed percpu variables. Fix call thunks debug macros to use PER_CPU_VAR macro from percpu.h to conditionally use %gs: segment register prefix, depending on CONFIG_SMP. Finally, unify ASM_ prefixed assembly macros with their non-prefixed variants. With support of %rip-relative relocations in place, call thunk templates allow %rip-relative addressing, so unified assembly snippet can be used everywhere. Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20231105213731.1878100-4-ubizjak@gmail.com --- arch/x86/include/asm/nospec-branch.h | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index c55cc24..65fbf6b 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -59,13 +59,13 @@ #ifdef CONFIG_CALL_THUNKS_DEBUG # define CALL_THUNKS_DEBUG_INC_CALLS \ - incq %gs:__x86_call_count; + incq PER_CPU_VAR(__x86_call_count); # define CALL_THUNKS_DEBUG_INC_RETS \ - incq %gs:__x86_ret_count; + incq PER_CPU_VAR(__x86_ret_count); # define CALL_THUNKS_DEBUG_INC_STUFFS \ - incq %gs:__x86_stuffs_count; + incq PER_CPU_VAR(__x86_stuffs_count); # define CALL_THUNKS_DEBUG_INC_CTXSW \ - incq %gs:__x86_ctxsw_count; + incq PER_CPU_VAR(__x86_ctxsw_count); #else # define CALL_THUNKS_DEBUG_INC_CALLS # define CALL_THUNKS_DEBUG_INC_RETS @@ -80,9 +80,6 @@ #define CREDIT_CALL_DEPTH \ movq $-1, PER_CPU_VAR(pcpu_hot + X86_call_depth); -#define ASM_CREDIT_CALL_DEPTH \ - movq $-1, PER_CPU_VAR(pcpu_hot + X86_call_depth); - #define RESET_CALL_DEPTH \ xor %eax, %eax; \ bts $63, %rax; \ @@ -95,20 +92,14 @@ CALL_THUNKS_DEBUG_INC_CALLS #define INCREMENT_CALL_DEPTH \ - sarq $5, %gs:pcpu_hot + X86_call_depth; \ - CALL_THUNKS_DEBUG_INC_CALLS - -#define ASM_INCREMENT_CALL_DEPTH \ sarq $5, PER_CPU_VAR(pcpu_hot + X86_call_depth); \ CALL_THUNKS_DEBUG_INC_CALLS #else #define CREDIT_CALL_DEPTH -#define ASM_CREDIT_CALL_DEPTH #define RESET_CALL_DEPTH -#define INCREMENT_CALL_DEPTH -#define ASM_INCREMENT_CALL_DEPTH #define RESET_CALL_DEPTH_FROM_CALL +#define INCREMENT_CALL_DEPTH #endif /* @@ -158,7 +149,7 @@ jnz 771b; \ /* barrier for jnz misprediction */ \ lfence; \ - ASM_CREDIT_CALL_DEPTH \ + CREDIT_CALL_DEPTH \ CALL_THUNKS_DEBUG_INC_CTXSW #else /* @@ -325,7 +316,7 @@ .macro CALL_DEPTH_ACCOUNT #ifdef CONFIG_CALL_DEPTH_TRACKING ALTERNATIVE "", \ - __stringify(ASM_INCREMENT_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(INCREMENT_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm