Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp381290pxf; Thu, 8 Apr 2021 05:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6m4K6fKshGiyivEW10Ha7KU7n1tKDvcZjf1RMqNsplXmDzgfEhuJkxE8f2AT5phDY5d7v X-Received: by 2002:a05:6402:148a:: with SMTP id e10mr10827436edv.377.1617884144215; Thu, 08 Apr 2021 05:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617884144; cv=none; d=google.com; s=arc-20160816; b=H0EjvePHdTZAOdPQftjmVpYkTTEXhXJSU7P1OXVXt6HErPdlynzZ6gmwmrlEf1BkCj rv54qaP34b9xlTgP5eIxUkpQu4iXV/5jqBA+U/sBwQ1obkmN6plGYNZiZFLfsXUrkNtl PHnyImjQVPCtxHnYAunmlo5ApaPnv+icB4CnV5FDEFreT1XTmM+2lgLnvTMI13ArLAGZ UMRpfki1iIJ8DpkvPfy/kOtVcV/NwyxpM4pO53Snr/zQT/qR0g9UtCw0OrBwrIgJEKkr kxjTvxlPwoszwX59kWDDqMY+gc/P2awRUkmW54HI6wdmHMq0M7HI9/O0edhJA3jEthZY OsxA== 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=jl/iDVbgDjoIROPCoDBb62Co+bvxRy+mMrB2zXmb1T0=; b=GgsOyiW6JJ37vYTWlwIGNmWhBbWUqpP7Xw1TM74EIIUhwo3B4I3+pV+QR7xIPIsgxO bI7xfcpUtqxciaxdVLoHfdOPbQnVWAUg9zwPNd5shqPA4JRXqaPhUCVhuyAGMDevPODK XMbXl0QlH/p3DHF02E2oj5q9DNjNsDMXs+/S3+z240GUtcUvGFXXe6Pkz86h1bimHaOB xTfuMZoZPo0XZvX33T6XD76hQjUU6BOoZphtsSnH23BymuHn+hHs2ZAQJMd20Zx8iNa/ XSQ57PVWayezVsS0BU0bYoV1cXCLLlCxD1IsrGB9mxVmJFnT1TRvxnPh3VquTk1ggHY3 3OaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XTMN4lw0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="xb/cdHMu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c23si15617996eja.640.2021.04.08.05.15.20; Thu, 08 Apr 2021 05:15:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XTMN4lw0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="xb/cdHMu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbhDHMOA (ORCPT + 99 others); Thu, 8 Apr 2021 08:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbhDHMNz (ORCPT ); Thu, 8 Apr 2021 08:13:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 693D8C061762; Thu, 8 Apr 2021 05:13:44 -0700 (PDT) Date: Thu, 08 Apr 2021 12:13:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1617884022; 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=jl/iDVbgDjoIROPCoDBb62Co+bvxRy+mMrB2zXmb1T0=; b=XTMN4lw01G4vumOWYJTU5u5yxjsIqL6oMfoXv477c9dOwd0zSiYOkaJlH9yXV4+2U9Nn9x wBIIG66vvhx1imVz6ihVa4hXPy8sIKkNFf1NEB9CJ753OcOGt8zmR+Iigh+RCvufr/a/hv C3LzUvao6USBTGRKMHTGDP4G9jubqABrlYdRULwXfv/0PCBh0Ulnnh8hzNc6VTrjQXNSl0 3RjXjLgDOu7S1jzmIVOQJP9Wcqef6esmC6pw7mdHUoKl6USMANeVTflp4epDJam+i/zdUX kX0q0r+FJGYV3x0OnJIHfeyGteiingOkx+cOo93HWRYbBKP1hyQfPFXv7hcUOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1617884022; 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=jl/iDVbgDjoIROPCoDBb62Co+bvxRy+mMrB2zXmb1T0=; b=xb/cdHMu3zv5wFJeAhadbyKVMl7Ztckv9fehRxt+GZ9hZyrfPm6AQuwb2LW1cZCnj+SiyY Ir2/E2kPsV3XpmDw== From: "tip-bot2 for Kees Cook" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] jump_label: Provide CONFIG-driven build state defaults Cc: Kees Cook , Thomas Gleixner , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210401232347.2791257-2-keescook@chromium.org> References: <20210401232347.2791257-2-keescook@chromium.org> MIME-Version: 1.0 Message-ID: <161788402204.29796.3718117807122564028.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: 0d66ccc1627013c95f1e7ef10b95b8451cd7834e Gitweb: https://git.kernel.org/tip/0d66ccc1627013c95f1e7ef10b95b8451cd7834e Author: Kees Cook AuthorDate: Thu, 01 Apr 2021 16:23:42 -07:00 Committer: Thomas Gleixner CommitterDate: Thu, 08 Apr 2021 14:05:19 +02:00 jump_label: Provide CONFIG-driven build state defaults As shown in the comment in jump_label.h, choosing the initial state of static branches changes the assembly layout. If the condition is expected to be likely it's inline, and if unlikely it is out of line via a jump. A few places in the kernel use (or could be using) a CONFIG to choose the default state, which would give a small performance benefit to their compile-time declared default. Provide the infrastructure to do this. Signed-off-by: Kees Cook Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20210401232347.2791257-2-keescook@chromium.org --- include/linux/jump_label.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index d926912..05f5554 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -382,6 +382,21 @@ struct static_key_false { [0 ... (count) - 1] = STATIC_KEY_FALSE_INIT, \ } +#define _DEFINE_STATIC_KEY_1(name) DEFINE_STATIC_KEY_TRUE(name) +#define _DEFINE_STATIC_KEY_0(name) DEFINE_STATIC_KEY_FALSE(name) +#define DEFINE_STATIC_KEY_MAYBE(cfg, name) \ + __PASTE(_DEFINE_STATIC_KEY_, IS_ENABLED(cfg))(name) + +#define _DEFINE_STATIC_KEY_RO_1(name) DEFINE_STATIC_KEY_TRUE_RO(name) +#define _DEFINE_STATIC_KEY_RO_0(name) DEFINE_STATIC_KEY_FALSE_RO(name) +#define DEFINE_STATIC_KEY_MAYBE_RO(cfg, name) \ + __PASTE(_DEFINE_STATIC_KEY_RO_, IS_ENABLED(cfg))(name) + +#define _DECLARE_STATIC_KEY_1(name) DECLARE_STATIC_KEY_TRUE(name) +#define _DECLARE_STATIC_KEY_0(name) DECLARE_STATIC_KEY_FALSE(name) +#define DECLARE_STATIC_KEY_MAYBE(cfg, name) \ + __PASTE(_DECLARE_STATIC_KEY_, IS_ENABLED(cfg))(name) + extern bool ____wrong_branch_error(void); #define static_key_enabled(x) \ @@ -482,6 +497,10 @@ extern bool ____wrong_branch_error(void); #endif /* CONFIG_JUMP_LABEL */ +#define static_branch_maybe(config, x) \ + (IS_ENABLED(config) ? static_branch_likely(x) \ + : static_branch_unlikely(x)) + /* * Advanced usage; refcount, branch is enabled when: count != 0 */