Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2231301ybi; Thu, 20 Jun 2019 11:16:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkoHcHtubhu7cdkEaVAa03ZzcgwmtAamqrTJFiPSTnf8lOqgneP6rezOqLMP4vS0oQTGT2 X-Received: by 2002:a65:50c3:: with SMTP id s3mr13946938pgp.177.1561054577445; Thu, 20 Jun 2019 11:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054577; cv=none; d=google.com; s=arc-20160816; b=syLiFsw8+ECJPVEmEoNhEcPlVaAO/SXxx4VyreKZuz66CBWIP4WfHvx+Q8ZPuFp73b jdVRgpjEiOf/koxJidCgXZaILtI/V/xeq2ZLZP2/58b6HS0veYVhztmFf+UTgjIz2/vg Jt9Z6aMgCY3MXaIOkKukps+580aaYtdhgahbdkjaX4m2zH+sNYk8BLYRWMQvmnt6+fE0 hywR2ktOC3tAE0zvAgWxv1qC65V0tVBEABIcsTijRyqubW5wYwKxNVUJ71SZFtKD0UNG W2zLeXxHOj3WB8OIShXnauxpkeuytnl33HkpD3irISZb2s8l0TeSxCWkyDIN0zu0L1IQ KvqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K/kCFGUIJsPB8sJmnjT/kQm7ifYCOyWNPZ9y7zbhfoM=; b=D4QSjAsdD7h5sdRQEf5QOl3Wh9YvhMnDFoxXlyrUbWoitGAl2icnZQuql91loqHrMH uKyolAOfidqWxK1T/eW2GOAQRH1QndLmAwcDVHotoA7hpS+ctl890yNo3qYiGVBI3+KU zy97AfR8yMQQvdEURQEJXLve5Z/E04e0RbWx5ITBj9QCUi0D4ohccYwwP8OOUZbrQfu4 7HTzbDcy9t2zb7dJ/2TS8HWOjhAZhCTuj2m+g3l1pHonx0kCQTUSkG7oH/5Jy49BfY36 JUzNmBPElkKcnkcdY5ObePXClUwu17E0IXCUW+KvlvFimrQpwDMz01bu38UVLhp7OoA0 +qtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SYzV69W5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v62si197127pfv.63.2019.06.20.11.16.02; Thu, 20 Jun 2019 11:16:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SYzV69W5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729702AbfFTSP7 (ORCPT + 99 others); Thu, 20 Jun 2019 14:15:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:44992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729695AbfFTSP6 (ORCPT ); Thu, 20 Jun 2019 14:15:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E6FD21537; Thu, 20 Jun 2019 18:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054556; bh=cWq0Z9QT4n7CT7f9rcLqy3iF8KYjB5mlRvO3kD03/kU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYzV69W5ryOFH3rD1nQomVJ1qVZEF0EK/Me8CEbHpwwQ0bdzCewgCRz++PubNP8vK zgW+ahQUNCLpixjBQggVnM4Qxxbbc9XUc0tmO5tRGK/RIxtaLjROgA3drXUrJmeMxc 209wGli7UfAE54o60VmQ8mMAwZuzqCyUyQu5b/Ek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Heiko Carstens , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.1 69/98] perf record: Fix s390 missing module symbol and warning for non-root users Date: Thu, 20 Jun 2019 19:57:36 +0200 Message-Id: <20190620174352.619645515@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ] Command 'perf record' and 'perf report' on a system without kernel debuginfo packages uses /proc/kallsyms and /proc/modules to find addresses for kernel and module symbols. On x86 this works for root and non-root users. On s390, when invoked as non-root user, many of the following warnings are shown and module symbols are missing: proc/{kallsyms,modules} inconsistency while looking for "[sha1_s390]" module! Command 'perf record' creates a list of module start addresses by parsing the output of /proc/modules and creates a PERF_RECORD_MMAP record for the kernel and each module. The following function call sequence is executed: machine__create_kernel_maps machine__create_module modules__parse machine__create_module --> for each line in /proc/modules arch__fix_module_text_start Function arch__fix_module_text_start() is s390 specific. It opens file /sys/module//sections/.text to extract the module's .text section start address. On s390 the module loader prepends a header before the first section, whereas on x86 the module's text section address is identical the the module's load address. However module section files are root readable only. For non-root the read operation fails and machine__create_module() returns an error. Command perf record does not generate any PERF_RECORD_MMAP record for loaded modules. Later command perf report complains about missing module maps. To fix this function arch__fix_module_text_start() always returns success. For root users there is no change, for non-root users the module's load address is used as module's text start address (the prepended header then counts as part of the text section). This enable non-root users to use module symbols and avoid the warning when perf report is executed. Output before: [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text Output after: [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text 0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz 0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz 0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/arch/s390/util/machine.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c index 0b2054007314..a19690a17291 100644 --- a/tools/perf/arch/s390/util/machine.c +++ b/tools/perf/arch/s390/util/machine.c @@ -5,16 +5,19 @@ #include "util.h" #include "machine.h" #include "api/fs/fs.h" +#include "debug.h" int arch__fix_module_text_start(u64 *start, const char *name) { + u64 m_start = *start; char path[PATH_MAX]; snprintf(path, PATH_MAX, "module/%.*s/sections/.text", (int)strlen(name) - 2, name + 1); - - if (sysfs__read_ull(path, (unsigned long long *)start) < 0) - return -1; + if (sysfs__read_ull(path, (unsigned long long *)start) < 0) { + pr_debug2("Using module %s start:%#lx\n", path, m_start); + *start = m_start; + } return 0; } -- 2.20.1