From patchwork Tue Nov 23 09:06:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Zhang X-Patchwork-Id: 12633781 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B6C1C433EF for ; Tue, 23 Nov 2021 09:07:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 162BA6B0073; Tue, 23 Nov 2021 04:07:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1142A6B0074; Tue, 23 Nov 2021 04:07:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1CFF6B0075; Tue, 23 Nov 2021 04:07:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id E23F06B0073 for ; Tue, 23 Nov 2021 04:07:30 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AB383184DBBEB for ; Tue, 23 Nov 2021 09:07:20 +0000 (UTC) X-FDA: 78839616198.24.2C9FDD9 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf01.hostedemail.com (Postfix) with ESMTP id A42895092EF8 for ; Tue, 23 Nov 2021 09:07:16 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id m15so17731373pgu.11 for ; Tue, 23 Nov 2021 01:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUHBLf5vNSlEiUHIVpm7uW2Kv1mivoocEqGi35UzJDo=; b=E9Njrw0uX2NtO/86NxIMhkIFZpYymPmae0/0ncowoV1DigjBKTp8KE7VrlXbUgVbMb p655JEdYujbN610Z7gb2rNJyDLX6V3rvbFf45fC4wfvZIxYEyOTiNvTdmyePw9SDpECY c0suK9yqIdEhNZl+XLPPbv4vX4rF/JEi7x815O0F+MncTwrSRe7A35dZzGf0lKNuQHOF JZ55u5SCzAcPTFKX1bcX03u3EemINfdIq1OXWlsbF1io0pjAtzI2+kXSVxWxs0zJb8WN RYl9Op0olCnDsjdEHvsDf4dWJVqUVcIi7Akj0NET42ytdlvqNsHDIOpp1qNZYT4CvjzO KhSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUHBLf5vNSlEiUHIVpm7uW2Kv1mivoocEqGi35UzJDo=; b=V6/eqcwtRKFi0o3Xf+UKEltW3pZAYymuTvaUTS4AxRnQ8w0VAprfXvJ0zCTYuBrUv/ vHtwL2hW+6kh1itOztboOPvemvXTI4RgTp5d4y4zzeD1IYpMIz8CGlqUkKHoasc8fEk9 sXcXzznS77ktyEkxVEtS3zV9HfiSC6SClyZxUU5EmdWw/pkAGgbXkE7UognIGbdPiYMz TTAPyPWgaksBbl8pdncvW61dQIJHLUerHfJDWGKqszUHLe9fW451aRJaPlPDRW4BqJ9R vmI5yb0tsZYe8MO5fLr7n2np6J1NaZ8t0DeF5I8k8HEtHS87ySC26ZrB3b6Sg7eDDBfc iyYQ== X-Gm-Message-State: AOAM530wbz2KPrD4oWt4cejL2SnahvK/pARzbGvVowUhuCJZkMAabX3q p2mofVbUwQSrRGkPlXxby3c= X-Google-Smtp-Source: ABdhPJyzeM1ZaQ0CZXGAIYfYbVQfDPp5pR8xK+fJZr7hkv5S6N/IyRP9kjmT3yrvPx7/bI9pBnW+gA== X-Received: by 2002:a05:6a00:1945:b0:44c:a955:35ea with SMTP id s5-20020a056a00194500b0044ca95535eamr3849851pfk.85.1637658439294; Tue, 23 Nov 2021 01:07:19 -0800 (PST) Received: from localhost.localdomain ([103.99.179.247]) by smtp.gmail.com with ESMTPSA id u13sm8751242pgp.27.2021.11.23.01.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 01:07:19 -0800 (PST) From: Calvin Zhang To: Rob Herring , Frank Rowand , Catalin Marinas , Andrew Morton Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Calvin Zhang Subject: [PATCH] mm: kmemleak: alloc gray object for reserved region with direct map. Date: Tue, 23 Nov 2021 17:06:41 +0800 Message-Id: <20211123090641.3654006-1-calvinzhang.cool@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: A42895092EF8 X-Stat-Signature: 64mki7hcgmg497cjgq8sax564ogzb39p Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E9Njrw0u; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of calvinzhang.cool@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=calvinzhang.cool@gmail.com X-Rspamd-Server: rspam02 X-HE-Tag: 1637658436-398786 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Reserved regions with direct mapping may contain references to other regions. CMA region with fixed location is reserved without creating kmemleak_object for it. So add them as gray kmemleak objects. Signed-off-by: Calvin Zhang --- drivers/of/fdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bdca35284ceb..116c582fea7a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -26,6 +26,7 @@ #include #include #include +#include #include /* for COMMAND_LINE_SIZE */ #include @@ -522,9 +523,12 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, size = dt_mem_next_cell(dt_root_size_cells, &prop); if (size && - early_init_dt_reserve_memory_arch(base, size, nomap) == 0) + early_init_dt_reserve_memory_arch(base, size, nomap) == 0) { pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M)); + if (!nomap) + kmemleak_alloc_phys(base, size, 0, 0); + } else pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M));