From patchwork Wed Aug 2 15:06:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 13338322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA992C001DF for ; Wed, 2 Aug 2023 15:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xB1pjWEHft29bIXjRWQJTfSIBTvizXbze8RXUIYDxzs=; b=T8FCSAEeme8x3q3IFSw76TlerQ +9HC0rarErEG37FH5sdiMfM2Ce3pbe7qWteemTNgPIlXfPKVF/ZVf/obzDjrKMiM4BqQtROOAYStN jG2ieHTyYMohkG1aPJ3dlvqVx263JIOYUDi4AJJX6GRsYf3vmAJoghFhY+g0JHZlz89t+bIYGp3B9 PNReIBD+SgUjgTRbmJOW4odv4uD0hA98qhosx2JAx3pBHjKUKlzwlbK/+cL7jdiIxX/QaoB0olGg1 fuRxUe2VsjTk5nR15cKtkUL0lxF55kLuaqsZ5EkJlxG0jjn27HCVz0UTF6HRbakRnuE7reudcRjhf D3gmvJqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRDRr-005BFi-1O; Wed, 02 Aug 2023 15:07:39 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRDRp-005BDr-0q for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2023 15:07:38 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58473c4f629so72402727b3.1 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=S3Jwu1if0i38SKKyuPFBQipULY9Scr7/8jvP3seYgLNLeygKu7huErqpVj/ruIMwG9 fnw55d82ai8emvq+sgbcMVzHuxxXP0Orvi7/VnTPaoPFbIhDHbtlbRRbtEXp+Qh3St80 dtpYYlGtq492zkgBUMOg/3KZEyp8jSuhmVw6JyzsJCBAesDb+eOOOTDVOdGpPrycy7Lp GVgM60Z0N35/gdFjVieLCoE+AhVT1jdnYdN3vccA0DHcEl3xJz9PyaQZJfR54XOBSr0v moZMN9DmEkLKPDc4t+zkYR2et4skzYN4SYj8dxk0PP8ydrmF3rviaHH7+Z6hUEarG/zQ 46Lg== X-Gm-Message-State: ABy/qLYaDIPbIF1PIDDaIcUmVlDRpl73IbOsAkazb8831qsUi/Ww1/ay 7BuuaL1oYYSnjSRVQtyr64/lQfPg6A== X-Google-Smtp-Source: APBJJlGl7coc7Y9Wjkd2tlsnTCLaJ9EQ+DV9HEDr83tchbeO/pNpIzRKN5owQrLr3Yo4s+6Z8oFpFbyHBA== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230802_080737_299569_F4168AE3 X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);