Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1068658rwo; Wed, 2 Aug 2023 08:16:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlGsnEumUWML+vnC8gRzDYHMDeUp3pkKTarIaYLwoM7Mo8sUQ+zr55dSnSeZ5MLfyk5s9OV+ X-Received: by 2002:a05:6402:759:b0:522:4764:8baa with SMTP id p25-20020a056402075900b0052247648baamr8074460edy.12.1690989392459; Wed, 02 Aug 2023 08:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690989392; cv=none; d=google.com; s=arc-20160816; b=fqCRrvi7OvtxqV8wQ2EcFsuuFuE4B9taQAkkQisPrZNxeD+cszHpKh7NosymLc2QA9 64f4mbhhJSfNztgWjZ5rkiPdMrsWEC1rHgl2+VEMk/sFZkJTbNi8k7g+0vh+iGsUVzep xOHqqFlPBgAA4GJO2fQz6Xy51ZQDbhgYnBj8TjOznsIX7+lVL4grABtMo/aQ4EMLzNRK 2AkdpYS+EgGjihx0GmbV1vfLTuSpl+XHI+zN+MirM/KtOwA5WM3NAFcf4/Cl8lRr2G3e Q6TIxn/VnbN5aooRrcP7/7brEv/do8S+Qm0WvLzyIkNyS6GzDWiaFWrIlD5wGzfnJ7ZK S6bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=bvGboV0t8alUYsd0cddb1UrgSKN8k9GsOS0292grtRY=; fh=lNGG3jUJkf8aHp9vpCSrpIUZatSpkge/xU1iDADXpuE=; b=E6oyASmeKkbcJXY+aPZSNMs7i7R3aQvg25E9CNB96nVjjk6FbzYkbNgggoWQi0E55l /WiptiTpL/ivPMbsxnPbcI1ah9INolYGE2bGW2Wfhu0KK3hGS0c9PB5oRec8LZaMaMP0 VB1omlFGvASJQ2m6rb1tbDkrUhHlQh6SVGHYy/AurQFGG2YN7exMXnCQksBAzkiRQVec bjkh3cOL+VI6lDY64GUinMEyzeSEBeT2uY3celCcTrYd7eXjhyoXfPDDVvC6MXJGW3hG by6mKYriXM0A7DbJRb6G5oOPPde7xW3xZ+NBW7jiTq1JBFUrvKxTljqsKGyBP5DBxKqR vcTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=GYpXHhyb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a056402134a00b005222c9def7bsi10478143edw.322.2023.08.02.08.16.07; Wed, 02 Aug 2023 08:16:32 -0700 (PDT) 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=@google.com header.s=20221208 header.b=GYpXHhyb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233948AbjHBPIZ (ORCPT + 99 others); Wed, 2 Aug 2023 11:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234889AbjHBPHv (ORCPT ); Wed, 2 Aug 2023 11:07:51 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF63A30D7 for ; Wed, 2 Aug 2023 08:07:32 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-57320c10635so79956727b3.3 for ; Wed, 02 Aug 2023 08:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690988852; x=1691593652; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bvGboV0t8alUYsd0cddb1UrgSKN8k9GsOS0292grtRY=; b=GYpXHhyb51djbzUFEuGFZEroZZF3Dvb8cCqx1P0jJsczmAPHDexsCVHdASsbs/x7Jx keu22L3rwyjMwK0648nvVpSVK2uMvNELdai3ps7AmNO7EMR4Dfoc/3b8EMN7gRfAYkEb I84cnhcKToeQ+dUV+jqQgwNM1R9Q+EtB9FwZu7Nw8xFIIRQjVDGQwKOcVrtkRmn3rYHt eT6bdpbrI6PQSCGPEXiPiOwfVOzKnH6H0arou10oqq0ZaeqOyz56dIvYL7ADRA/4oKnJ chV5fqZcOs1jJU7BfKlWNdoeiyXZNKH4X59F1Y911DP4rfjhXRtAHf46t7M0Zt3NbLlo PINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690988852; x=1691593652; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bvGboV0t8alUYsd0cddb1UrgSKN8k9GsOS0292grtRY=; b=RZnwuWhdFIo7hR9HEwbYKPTq1zvXTiU45XX+uryB1E7CBm2FAb6HHh7ayyztf5tXWp 4vvqAFdQF2jMUdjw1vYhQja0BEBwtYk7ir0Q4U2NFGN0813TysL3T/1VLi9b+HA11+eW JtvqTQqSt4ukbacPrawuSFuYI/6m34V3Ys8uppjod9nLFVrs5U9JC0381miBBIzoGruy jIwhwqO3ljsboUXrWanHakG2UllM1eRoz1Iv0QYGK8gHykWft/O0amc3XRiYIYbY2E6e Ep3c/Qgy8oAFsDTY1LZqvWkOO8A00S0aFUIlfWhn4fe+xIx5+bfD/HZkmKb9DU0WJ3WA ngDg== X-Gm-Message-State: ABy/qLZAg3WuEnVBEbK+nREW1aQkWsIVjEM+P3SyzaMakT+c/LhwtJct lLirOaLp9CXB0FaOvvsE/3TuXY51hg== X-Received: from elver.muc.corp.google.com ([2a00:79e0:9c:201:5f73:1fc0:c9fd:f203]) (user=elver job=sendgmr) by 2002:a25:ab86:0:b0:d0d:a7bc:4040 with SMTP id v6-20020a25ab86000000b00d0da7bc4040mr122142ybi.0.1690988851982; Wed, 02 Aug 2023 08:07:31 -0700 (PDT) Date: Wed, 2 Aug 2023 17:06:38 +0200 In-Reply-To: <20230802150712.3583252-1-elver@google.com> Mime-Version: 1.0 References: <20230802150712.3583252-1-elver@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230802150712.3583252-2-elver@google.com> Subject: [PATCH 2/3] list_debug: Introduce inline wrappers for debug checks From: Marco Elver To: elver@google.com, Andrew Morton , Kees Cook Cc: Guenter Roeck , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Miguel Ojeda , Nick Desaulniers , Nathan Chancellor , Tom Rix , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 Turn the list debug checking functions __list_*_valid() into inline functions that wrap the out-of-line functions. Care is taken to ensure the inline wrappers are always inlined, so that additional compiler instrumentation (such as sanitizers) does not result in redundant outlining. This change is preparation for performing checks in the inline wrappers. No functional change intended. Signed-off-by: Marco Elver --- arch/arm64/kvm/hyp/nvhe/list_debug.c | 6 +++--- include/linux/list.h | 15 +++++++++++++-- lib/list_debug.c | 11 +++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/list_debug.c b/arch/arm64/kvm/hyp/nvhe/list_debug.c index d68abd7ea124..589284496ac5 100644 --- a/arch/arm64/kvm/hyp/nvhe/list_debug.c +++ b/arch/arm64/kvm/hyp/nvhe/list_debug.c @@ -26,8 +26,8 @@ static inline __must_check bool nvhe_check_data_corruption(bool v) /* The predicates checked here are taken from lib/list_debug.c. */ -bool __list_add_valid(struct list_head *new, struct list_head *prev, - struct list_head *next) +bool ___list_add_valid(struct list_head *new, struct list_head *prev, + struct list_head *next) { if (NVHE_CHECK_DATA_CORRUPTION(next->prev != prev) || NVHE_CHECK_DATA_CORRUPTION(prev->next != next) || @@ -37,7 +37,7 @@ bool __list_add_valid(struct list_head *new, struct list_head *prev, return true; } -bool __list_del_entry_valid(struct list_head *entry) +bool ___list_del_entry_valid(struct list_head *entry) { struct list_head *prev, *next; diff --git a/include/linux/list.h b/include/linux/list.h index f10344dbad4d..e0b2cf904409 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -39,10 +39,21 @@ static inline void INIT_LIST_HEAD(struct list_head *list) } #ifdef CONFIG_DEBUG_LIST -extern bool __list_add_valid(struct list_head *new, +extern bool ___list_add_valid(struct list_head *new, struct list_head *prev, struct list_head *next); -extern bool __list_del_entry_valid(struct list_head *entry); +static __always_inline bool __list_add_valid(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + return ___list_add_valid(new, prev, next); +} + +extern bool ___list_del_entry_valid(struct list_head *entry); +static __always_inline bool __list_del_entry_valid(struct list_head *entry) +{ + return ___list_del_entry_valid(entry); +} #else static inline bool __list_add_valid(struct list_head *new, struct list_head *prev, diff --git a/lib/list_debug.c b/lib/list_debug.c index d98d43f80958..fd69009cc696 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -17,8 +17,8 @@ * attempt). */ -bool __list_add_valid(struct list_head *new, struct list_head *prev, - struct list_head *next) +bool ___list_add_valid(struct list_head *new, struct list_head *prev, + struct list_head *next) { if (CHECK_DATA_CORRUPTION(prev == NULL, "list_add corruption. prev is NULL.\n") || @@ -37,9 +37,9 @@ bool __list_add_valid(struct list_head *new, struct list_head *prev, return true; } -EXPORT_SYMBOL(__list_add_valid); +EXPORT_SYMBOL(___list_add_valid); -bool __list_del_entry_valid(struct list_head *entry) +bool ___list_del_entry_valid(struct list_head *entry) { struct list_head *prev, *next; @@ -65,6 +65,5 @@ bool __list_del_entry_valid(struct list_head *entry) return false; return true; - } -EXPORT_SYMBOL(__list_del_entry_valid); +EXPORT_SYMBOL(___list_del_entry_valid); -- 2.41.0.585.gd2178a4bd4-goog