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 X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 36725C43464 for ; Fri, 18 Sep 2020 02:39:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFB1223730 for ; Fri, 18 Sep 2020 02:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600396795; bh=YAGJYVhFjbze1tis9xG12RuVtC+ft7YD7wfMI7gkrTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gltFd6CZL6hCzKkUmziLsablfBffoDhOzt9T3l7o4llUrYGnDsM9oYhGlE/NtgwMd harR9OkbOj86zLTvZpO7KrV/QtWX1YRcLghV2AONHleJGtn+BGeIWkNCczCSTTZaGz ZZpJQ2UdldokytvfJQ0M/dSOwczuLpqraS8ZShRI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728687AbgIRCjx (ORCPT ); Thu, 17 Sep 2020 22:39:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgIRCLv (ORCPT ); Thu, 17 Sep 2020 22:11:51 -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 D4547208DB; Fri, 18 Sep 2020 02:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395110; bh=YAGJYVhFjbze1tis9xG12RuVtC+ft7YD7wfMI7gkrTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EnsjLRtOPjfR1u22KVKeTnWhmkVXdRVNb671abcJm1jrqnJnoyp0yqlrIKAte6R/X m8PTQjohmD2opHP3W4BTonhS7Bep2q9nLXexgLRPti9VjgjKyhYKabrPgZPDb3740V Mnv1ihthqXz/m4IcFYzhInnpRKqVYViS7wtztdQE= 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 4.19 184/206] perf kcore_copy: Fix module map when there are no modules loaded Date: Thu, 17 Sep 2020 22:07:40 -0400 Message-Id: <20200918020802.2065198-184-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-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 a701a8a48f005..166c621e02235 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1421,6 +1421,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; @@ -1497,6 +1498,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; @@ -1694,6 +1697,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