From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 999A2C001B0 for ; Tue, 8 Aug 2023 22:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230358AbjHHWdC (ORCPT ); Tue, 8 Aug 2023 18:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbjHHWdB (ORCPT ); Tue, 8 Aug 2023 18:33:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A4C29552 for ; Tue, 8 Aug 2023 11:35:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D60561B5A for ; Tue, 8 Aug 2023 18:35:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 001F3C433C8; Tue, 8 Aug 2023 18:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1691519728; bh=IV7UENa1SW83fVT5Ihf8Cu9qzgxDRmICvAJ75JB+dmE=; h=Date:To:From:Subject:From; b=xNROhs4OLLNcEx8+lmpAY91cORmgJ8xeM7pZ1RESbH2da7oC1EFLbkoDqDpWXJQVS 2/ooeQPVhuioHodlNGPEg/xTfnzo0jAiElw7ko1b5z5421LzxptMvyvPv2JCRgoK4o 0xBxNoY/l+mCDk+0ZB9CJiSPxlbuevxeOZcXa/0o= Date: Tue, 08 Aug 2023 11:35:27 -0700 To: mm-commits@vger.kernel.org, yuzenghui@huawei.com, will@kernel.org, trix@redhat.com, suzuki.poulose@arm.com, samitolvanen@google.com, rostedt@goodmis.org, peterz@infradead.org, oliver.upton@linux.dev, ojeda@kernel.org, ndesaulniers@google.com, nathan@kernel.org, maz@kernel.org, mark.rutland@arm.com, linux@roeck-us.net, keescook@chromium.org, james.morse@arm.com, glider@google.com, dvyukov@google.com, catalin.marinas@arm.com, elver@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: + list_debug-introduce-inline-wrappers-for-debug-checks.patch added to mm-nonmm-unstable branch Message-Id: <20230808183528.001F3C433C8@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: list_debug: introduce inline wrappers for debug checks has been added to the -mm mm-nonmm-unstable branch. Its filename is list_debug-introduce-inline-wrappers-for-debug-checks.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/list_debug-introduce-inline-wrappers-for-debug-checks.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Marco Elver Subject: list_debug: introduce inline wrappers for debug checks Date: Tue, 8 Aug 2023 12:17:26 +0200 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. Link: https://lkml.kernel.org/r/20230808102049.465864-2-elver@google.com Signed-off-by: Marco Elver Cc: Alexander Potapenko Cc: Catalin Marinas Cc: Dmitry Vyukov Cc: Guenter Roeck Cc: James Morse Cc: Kees Cook Cc: Marc Zyngier Cc: Mark Rutland Cc: Miguel Ojeda Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Oliver Upton Cc: Peter Zijlstra Cc: Sami Tolvanen Cc: Steven Rostedt (Google) Cc: Suzuki K Poulose Cc: Tom Rix Cc: Will Deacon Cc: Zenghui Yu Signed-off-by: Andrew Morton --- arch/arm64/kvm/hyp/nvhe/list_debug.c | 6 ++-- include/linux/list.h | 37 ++++++++++++++++++++++--- lib/list_debug.c | 11 +++---- 3 files changed, 41 insertions(+), 13 deletions(-) --- a/arch/arm64/kvm/hyp/nvhe/list_debug.c~list_debug-introduce-inline-wrappers-for-debug-checks +++ a/arch/arm64/kvm/hyp/nvhe/list_debug.c @@ -26,8 +26,8 @@ static inline __must_check bool nvhe_che /* 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_or_report(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 * return true; } -bool __list_del_entry_valid(struct list_head *entry) +bool __list_del_entry_valid_or_report(struct list_head *entry) { struct list_head *prev, *next; --- a/include/linux/list.h~list_debug-introduce-inline-wrappers-for-debug-checks +++ a/include/linux/list.h @@ -39,10 +39,39 @@ static inline void INIT_LIST_HEAD(struct } #ifdef CONFIG_DEBUG_LIST -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); +/* + * Performs the full set of list corruption checks before __list_add(). + * On list corruption reports a warning, and returns false. + */ +extern bool __list_add_valid_or_report(struct list_head *new, + struct list_head *prev, + struct list_head *next); + +/* + * Performs list corruption checks before __list_add(). Returns false if a + * corruption is detected, true otherwise. + */ +static __always_inline bool __list_add_valid(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + return __list_add_valid_or_report(new, prev, next); +} + +/* + * Performs the full set of list corruption checks before __list_del_entry(). + * On list corruption reports a warning, and returns false. + */ +extern bool __list_del_entry_valid_or_report(struct list_head *entry); + +/* + * Performs list corruption checks before __list_del_entry(). Returns false if a + * corruption is detected, true otherwise. + */ +static __always_inline bool __list_del_entry_valid(struct list_head *entry) +{ + return __list_del_entry_valid_or_report(entry); +} #else static inline bool __list_add_valid(struct list_head *new, struct list_head *prev, --- a/lib/list_debug.c~list_debug-introduce-inline-wrappers-for-debug-checks +++ a/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_or_report(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 * return true; } -EXPORT_SYMBOL(__list_add_valid); +EXPORT_SYMBOL(__list_add_valid_or_report); -bool __list_del_entry_valid(struct list_head *entry) +bool __list_del_entry_valid_or_report(struct list_head *entry) { struct list_head *prev, *next; @@ -65,6 +65,5 @@ bool __list_del_entry_valid(struct list_ return false; return true; - } -EXPORT_SYMBOL(__list_del_entry_valid); +EXPORT_SYMBOL(__list_del_entry_valid_or_report); _ Patches currently in -mm which might be from elver@google.com are compiler_types-introduce-the-clang-__preserve_most-function-attribute.patch list_debug-introduce-inline-wrappers-for-debug-checks.patch list_debug-introduce-config_debug_list_minimal.patch