From patchwork Mon Mar 29 17:53:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kardell X-Patchwork-Id: 12170629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B692FC433C1 for ; Mon, 29 Mar 2021 17:53:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AEF8861981 for ; Mon, 29 Mar 2021 17:53:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEF8861981 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=telliq.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0E5556B007D; Mon, 29 Mar 2021 13:53:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 094F46B007E; Mon, 29 Mar 2021 13:53:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E508E6B0080; Mon, 29 Mar 2021 13:53:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id C758C6B007D for ; Mon, 29 Mar 2021 13:53:31 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 873543623 for ; Mon, 29 Mar 2021 17:53:31 +0000 (UTC) X-FDA: 77973659022.07.5AD50CB Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf19.hostedemail.com (Postfix) with ESMTP id 4F2E69001146 for ; Mon, 29 Mar 2021 17:53:14 +0000 (UTC) Received: by mail-wm1-f50.google.com with SMTP id k128so7031577wmk.4 for ; Mon, 29 Mar 2021 10:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telliq.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N6EnRd/MY7h8IstQCaZRWpBwbfFtnJv4s7DJ21C8TVU=; b=CAYs0tgpe8vK037DR+QKaY/dFao1NgmTdZvmoJDVBWeLeSuPcF3sVB1RqBALma6L8e 60P2lVgiHv00myzkjExiWiTZHHsP7a/koD0WhGQ+zNK1slD/vjgM6DrhEZVhmH2+Tnmu Z/mI+39OQ3DTCUwCqMrlnG5aMbvmKzhNwdyUvJ44OPCCWxE0MdElOpdyvE7VNhXccv/5 HebYIbIELrPYac0N9mRrcLivnzbn51nOkbB2tL/qlB5Q0pwMejygyEGxzUBbSykJ3YuR LLyWHvkBLRHBMbVOTCYKZhA1cUYOPBjFs2k3h6OlZiJnMiAZoytiL8wzI5xn/HtZmzbW zm+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N6EnRd/MY7h8IstQCaZRWpBwbfFtnJv4s7DJ21C8TVU=; b=o4j2dTBxofyWdT4ZSCI6Nyznq8FSncB+qrQvZZAivDOZwcIpkzLj+Cdm+SQV4/oeFW jSKnZm/JQ8SH47X4pvsF1UT8wJvR5/yVWDYRiAxvok0a4aKj99PBDZHQ/5Zym9L+WUkR ZS8caKRBgN1NYDSgIBedrjs4/bbMaGjNV7+Xzam8sU0VnlHTfMwuZBxkn1p5mS44PjrP 5oyyEwxJ9Xqyfigz+xDVT4XmnQ5kyyUQ5WYmNRuqyTJoiKwTFzjm+DOvd2ytkjcDMf6F TEMgcGs6+gVZ23b1uBrTev/JtN5ZcXHfmKGlfrOYQeH8wgAjfr297mtK3Ky1bWy5djcG B0yg== X-Gm-Message-State: AOAM532WkO8N7aOVdsz0psSmhrgDbltJZEkoVyywWgVYZ60k4/F3eWUr dx+gYnlkHoDX811rznB08kzsag== X-Google-Smtp-Source: ABdhPJzNvL5rgMlYeb3DLyMYlNh0fTGWd7RQJVVnvzJUaoumN5K/evaFhoN2SSC65l7mRBlLfxAODg== X-Received: by 2002:a7b:c841:: with SMTP id c1mr232796wml.123.1617040399629; Mon, 29 Mar 2021 10:53:19 -0700 (PDT) Received: from emu.mida (static-212-247-121-18.cust.tele2.se. [212.247.121.18]) by smtp.gmail.com with ESMTPSA id q4sm154209wma.20.2021.03.29.10.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 10:53:19 -0700 (PDT) From: Jan Kardell To: Linux ARM Cc: linux-kernel@vger.kernel.org, Russell King , linux-omap@vger.kernel.org, Andrew Morton , linux-mm@kvack.org Subject: [PATCH] arm: Define arch_is_kernel_initmem_freed() for lockdep Date: Mon, 29 Mar 2021 19:53:18 +0200 Message-Id: <20210329175318.21393-1-jan.kardell@telliq.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4F2E69001146 X-Stat-Signature: zzeyxwxpqqakqaipkbajha77ztgsusi1 Received-SPF: none (arkub.com>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail-wm1-f50.google.com; client-ip=209.85.128.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617040394-530177 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This fixes the warning: WARNING: CPU: 0 PID: 1994 at kernel/locking/lockdep.c:1119 alloc_netdev_mqs+0xb4/0x3b0 This warning is because the check in static_obj() assumes that all memory within [_stext, _end] belongs to static objects. The init section is also part of this range, and freeing it allows the buddy allocator to allocate memory from it. To fix this, define arch_is_kernel_initmem_freed() for arm, it will return 1 if initmem has been freed and the address is in the range [__init_begin, __init_end], and this function is called by the static_obj() function in lockdep. Tested on TI am3352 (Cortex A8). This change is modelled after commit 7a5da02de8d6eafba995 ("locking/lockdep: check for freed initmem in static_obj()") for s390 by Gerald Schaefer Signed-off-by: Jan Kardell --- arch/arm/include/asm/sections.h | 13 +++++++++++++ arch/arm/mm/init.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h index 700b8bcdf9bd..1dd64c90c1ac 100644 --- a/arch/arm/include/asm/sections.h +++ b/arch/arm/include/asm/sections.h @@ -2,6 +2,8 @@ #ifndef _ASM_ARM_SECTIONS_H #define _ASM_ARM_SECTIONS_H +#define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed + #include extern char _exiprom[]; @@ -11,6 +13,17 @@ extern char __idmap_text_end[]; extern char __entry_text_start[]; extern char __entry_text_end[]; +extern bool initmem_freed; + +static inline int arch_is_kernel_initmem_freed(unsigned long addr) +{ + if (!initmem_freed) + return 0; + return addr >= (unsigned long)__init_begin && + addr < (unsigned long)__init_end; +} + + static inline bool in_entry_text(unsigned long addr) { return memory_contains(__entry_text_start, __entry_text_end, diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 828a2561b229..cd7a4273797a 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -41,6 +41,8 @@ #include "mm.h" +bool initmem_freed; + #ifdef CONFIG_CPU_CP15_MMU unsigned long __init __clear_cr(unsigned long mask) { @@ -523,8 +525,10 @@ void free_initmem(void) fix_kernmem_perms(); poison_init_mem(__init_begin, __init_end - __init_begin); - if (!machine_is_integrator() && !machine_is_cintegrator()) + if (!machine_is_integrator() && !machine_is_cintegrator()) { + initmem_freed = true; free_initmem_default(-1); + } } #ifdef CONFIG_BLK_DEV_INITRD