Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp873896pxk; Thu, 17 Sep 2020 19:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfGlCnP8JQDDg04fKHOtre5PBb5oxx2tScpyCI6ZWa6rR/Z9gOtRkXLro0AnLWLNV7b+b8 X-Received: by 2002:a05:6402:1558:: with SMTP id p24mr35321388edx.194.1600397858600; Thu, 17 Sep 2020 19:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600397858; cv=none; d=google.com; s=arc-20160816; b=0CdyA6Bc1tiFwUji9UJ80OyJdURNs2co/Sm7ZdcM0ueZGHVmsqoZjJ5QpVnHPkYBpW TMfkcqyHVwoxMO/JjklylhjK0GIlX1m9Ij6UfoPi2t9nmN61Lgz0gdvVIcFUe9QhTlXT iTrzmOxlpwFLpe57lsdsRiG2oFGnlxl5QMEW+XBlCpPo4GP75pPYNg8DAFbFqQdrNE9S xq2DxEzLM86brmOZisVhisy5hR3adm5FRU6lyThOupp1VijmxE5Zg3yaqfKc/JuDi0xF bWPTuuDkJ/YZUiJ70PhVStzS0+tYE84D25H87Tk0wOpINmQsAKRSlZBVSD+1b/nUx9cr LZ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bFqKz58x1xHILhKYSPOr2/rtjdGnjlQBllIwqLUdcJ0=; b=y++WC6043Hv912qGS/BOJFxXk6lnjtYSh0JFjYnZSEoS0WPI+yJB5nLIdUvz31765p gIcVrWhMC9VznUlrlZhQyphiNWkyuxAS0Bw+amm1YjHF0JcMCSWX7SpeGqgrUDKcEEHk DO+YxrDmbP0wGRUjVoSozprIF6dsDKWBzlM7SZryVDOnesR3Ts5lc2kEY4Ed+7TnrqX/ 5cFw8tAwK0IXpOOvdDngSQZQwM/oWNXgGHEi4HJjTP58ZyY6Y+mahFQGWbu+OsQMtVIL dXdjdeAiRPR46hxxeiF2tpUSkLzl5w4/hnD0xG/RmKwZzyMVg+od9M9w8k0dNF3jt+zt W9Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rHPRI3YX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si1258626edi.602.2020.09.17.19.57.15; Thu, 17 Sep 2020 19:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rHPRI3YX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbgIRCyw (ORCPT + 99 others); Thu, 17 Sep 2020 22:54:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:57572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727237AbgIRCHU (ORCPT ); Thu, 17 Sep 2020 22:07:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD621238E3; Fri, 18 Sep 2020 02:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394839; bh=GM7f6/Yo+DhTZY+DXNizPAXkh5SdHzaJ/cPyt9D+hfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rHPRI3YX77ldMOqBSPWx+gx8x04eg+Fq7AdIc0QbfxrXf6ghE8KLPxWkoUi5oCHM8 d7VW0YkFeg7+hvJhE7JJ6TAGagwEOlYn/DnQGPOrImKt0zAeDLkZU23bVs3c7gp2XA PtEnW79vBvxcrtb+zMQvP2lkmdI2dNIhOrOQC+ok= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Adrian Hunter , Alexander Shishkin , Borislav Petkov , "H . Peter Anvin" , Jiri Olsa , Leo Yan , Mark Rutland , Masami Hiramatsu , Mathieu Poirier , Peter Zijlstra , Steven Rostedt , x86@kernel.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 5.4 297/330] perf kcore_copy: Fix module map when there are no modules loaded Date: Thu, 17 Sep 2020 22:00:37 -0400 Message-Id: <20200918020110.2063155-297-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter [ Upstream commit 61f82e3fb697a8e85f22fdec786528af73dc36d1 ] In the absence of any modules, no "modules" map is created, but there are other executable pages to map, due to eBPF JIT, kprobe or ftrace. Map them by recognizing that the first "module" symbol is not necessarily from a module, and adjust the map accordingly. Signed-off-by: Adrian Hunter Cc: Alexander Shishkin Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Leo Yan Cc: Mark Rutland Cc: Masami Hiramatsu Cc: Mathieu Poirier Cc: Peter Zijlstra Cc: Steven Rostedt (VMware) Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/20200512121922.8997-10-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/symbol-elf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 66f4be1df573e..2ec0a32da5793 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1449,6 +1449,7 @@ struct kcore_copy_info { u64 first_symbol; u64 last_symbol; u64 first_module; + u64 first_module_symbol; u64 last_module_symbol; size_t phnum; struct list_head phdrs; @@ -1525,6 +1526,8 @@ static int kcore_copy__process_kallsyms(void *arg, const char *name, char type, return 0; if (strchr(name, '[')) { + if (!kci->first_module_symbol || start < kci->first_module_symbol) + kci->first_module_symbol = start; if (start > kci->last_module_symbol) kci->last_module_symbol = start; return 0; @@ -1722,6 +1725,10 @@ static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir, kci->etext += page_size; } + if (kci->first_module_symbol && + (!kci->first_module || kci->first_module_symbol < kci->first_module)) + kci->first_module = kci->first_module_symbol; + kci->first_module = round_down(kci->first_module, page_size); if (kci->last_module_symbol) { -- 2.25.1