From patchwork Sat Aug 10 07:21:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 171008 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp213795ily; Sat, 10 Aug 2019 00:22:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt4WazFLlk64b01CqyTf8VfY3+RcVOOyX4EGVPhT1Bd5gNBRhCt35syit+NkNmpLufoXYx X-Received: by 2002:a17:902:6b44:: with SMTP id g4mr22964793plt.152.1565421736275; Sat, 10 Aug 2019 00:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565421736; cv=none; d=google.com; s=arc-20160816; b=r7s/TM7lFY/aJ84zvlbspPOghKh0bd1bej+U+V5++IGcFG+WalIymW1M7h6Z/hIpPS NbuRqIBRt1KKO85NSvObnctjx1MfVM5l3znUhDozkeIg5B3dXNEjM7/BsByvzRpFoVUd fCVzuFzUo0OPlFbdgogonM5xqgNW3McXeVQ659Ru0UolF/0UxI3BXZ4i8cYYAQeuEeSH gz8PYL8luHgMEH/8mcqzxDqsxML/PfDPTWU4E53U8Vb6d9D5qsxH2MKi6W5VqmAhVS8u oDg2M0DEJtNoLaFMzQRK0rqVAiyrAEOfibLWnIgNpff6X3PQdHZKmk493TKW4IzuFYqQ ywCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=SUoVe7v3rT/MuQ/nwpXN/VHHe+ExuqKtoNBajOsMZ6w=; b=K5amL9qZkCI61SK7hGmb4zgAwlU2zcLMnKKIbwC5gRSFzNKr+P5OQ+bIp6EfdKZpHj yqJgPpM+9/iX+X9ofHcCQBDwR7N1zTmLd+G8fIfU8YgNC5vxRPX4MYJwsn26cDzO1fUp zbi7jd6TpRZeHXuzoM+vR/ilFqnY6DUkQdUC89DAb4nT66MMuU6o0u8TGigMSly7fsut v+aCEormZmGDr2U/pEWqo9OCq9PTYKnimYKjb/rdhQFddtpnwS7w5PlcVVZnrhXLIifk 96SIZwcBzcVmGnd7tuVDmMUN7dHAGVLFM8iV29cy0a7Q/VoLfbV6DGryLcXGvuthHsfu skhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wQJH7ETU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si57780429pgy.255.2019.08.10.00.22.16; Sat, 10 Aug 2019 00:22:16 -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=@linaro.org header.s=google header.b=wQJH7ETU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726284AbfHJHWP (ORCPT + 28 others); Sat, 10 Aug 2019 03:22:15 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36006 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfHJHWM (ORCPT ); Sat, 10 Aug 2019 03:22:12 -0400 Received: by mail-pg1-f196.google.com with SMTP id l21so46934690pgm.3 for ; Sat, 10 Aug 2019 00:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SUoVe7v3rT/MuQ/nwpXN/VHHe+ExuqKtoNBajOsMZ6w=; b=wQJH7ETUQf/Dh4ez18JN84T3l+cjXjy09Eucj14X0AHuvosMhmvOogUX+atkAp20mg SmV0+RgkID9grGKgKmWpop/TOMD8i0v3r4+jQ9itYf1FiRZ28doVdPHOTRf6LYovTj4l 0qsL3fBBtjZJwSpnrTtiPbQLj/IHWXapZo1y4q03jxmYWnwZKDFcc+Gjbyixt23U8y+E egXKOO7CqMkvduanDLWTKBdCTiTbpwSrLmRRSZnvzYkQsI2JOQ3bmQiMScqg41bMQ6To +lCMPz4rEH2MSbhrKFvLRkW0JkDkbDpoR+eHWJQ0F0M+RxwMwE11pr3jKvrGCWplkSYQ VPeA== 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:in-reply-to :references; bh=SUoVe7v3rT/MuQ/nwpXN/VHHe+ExuqKtoNBajOsMZ6w=; b=uheBZaHUUMC3Yqd/UYsXPuAHebPHtM/xeoCREsYXroAnLQYNba30+YNDPy9RH4Xajv Z39wdFtnZ93oh3azbxveD+MYej9BNCwDwdIFwzE04VoP9kMm9ZtZ6UjrdaD3T/UN8Z3/ /Wtv713KHHfrAg4JaR4SkNXxyz8HQiTPFTjv+Oc7R12DDaTxqtZnL4BgwqHKGhPcR7lG CI7QR7Qyc6Xs+wPwEFZglrp342d9Q0tu0VYcCnTBhRIjq4kTLOXaL1mbqohS1tTWAaBy KFigBCIO1xluYAZTT86SC1eVyVJ9va4PSpreuD6BEyLPh5Gu/KuYQxePdJETTIs74/Op BntA== X-Gm-Message-State: APjAAAUzcAmnNRaAKTQCLPbvWYD4EQ7ptkm2lS5M5bP3rORUc8y4Ibr3 1krJDpuqs2pSp8VNdr8VvB4+bQ== X-Received: by 2002:a63:124a:: with SMTP id 10mr20982007pgs.254.1565421732167; Sat, 10 Aug 2019 00:22:12 -0700 (PDT) Received: from localhost.localdomain (li456-16.members.linode.com. [50.116.10.16]) by smtp.gmail.com with ESMTPSA id l17sm24872660pgj.44.2019.08.10.00.22.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 10 Aug 2019 00:22:11 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , David Miller , Milian Wolff , Donald Yandt , Davidlohr Bueso , Wei Li , Adrian Hunter , Mark Drayton , "Tzvetomir Stoyanov (VMware)" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, Mathieu Poirier Cc: Leo Yan Subject: [PATCH v4 1/2] perf machine: Support arch's specific kernel start address Date: Sat, 10 Aug 2019 15:21:34 +0800 Message-Id: <20190810072135.27072-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190810072135.27072-1-leo.yan@linaro.org> References: <20190810072135.27072-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org machine__get_kernel_start() gives out the kernel start address; some architectures need to tweak the start address so that can reflect the kernel start address correctly. This is not only for x86_64 arch, but it is also required by other architectures, e.g. arm/arm64 needs to tweak the kernel start address so can include the kernel memory regions which are used before the '_stext' symbol. This patch refactors machine__get_kernel_start() by adding a weak arch__fix_kernel_text_start(), any architecture can implement it to tweak its specific start address; this also allows the arch specific code to be placed into 'arch' folder. Signed-off-by: Leo Yan --- tools/perf/arch/x86/util/machine.c | 10 ++++++++++ tools/perf/util/machine.c | 13 +++++++------ tools/perf/util/machine.h | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/tools/perf/arch/x86/util/machine.c b/tools/perf/arch/x86/util/machine.c index 1e9ec783b9a1..9f012131534a 100644 --- a/tools/perf/arch/x86/util/machine.c +++ b/tools/perf/arch/x86/util/machine.c @@ -101,4 +101,14 @@ int machine__create_extra_kernel_maps(struct machine *machine, return ret; } +void arch__fix_kernel_text_start(u64 *start) +{ + /* + * On x86_64, PTI entry trampolines are less than the + * start of kernel text, but still above 2^63. So leave + * kernel_start = 1ULL << 63 for x86_64. + */ + *start = 1ULL << 63; +} + #endif diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f6ee7fbad3e4..603518835692 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2671,6 +2671,10 @@ int machine__nr_cpus_avail(struct machine *machine) return machine ? perf_env__nr_cpus_avail(machine->env) : 0; } +void __weak arch__fix_kernel_text_start(u64 *start __maybe_unused) +{ +} + int machine__get_kernel_start(struct machine *machine) { struct map *map = machine__kernel_map(machine); @@ -2687,14 +2691,11 @@ int machine__get_kernel_start(struct machine *machine) machine->kernel_start = 1ULL << 63; if (map) { err = map__load(map); - /* - * On x86_64, PTI entry trampolines are less than the - * start of kernel text, but still above 2^63. So leave - * kernel_start = 1ULL << 63 for x86_64. - */ - if (!err && !machine__is(machine, "x86_64")) + if (!err) machine->kernel_start = map->start; } + + arch__fix_kernel_text_start(&machine->kernel_start); return err; } diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index ef803f08ae12..9cb459f4bfbc 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -278,6 +278,8 @@ void machine__get_kallsyms_filename(struct machine *machine, char *buf, int machine__create_extra_kernel_maps(struct machine *machine, struct dso *kernel); +void arch__fix_kernel_text_start(u64 *start); + /* Kernel-space maps for symbols that are outside the main kernel map and module maps */ struct extra_kernel_map { u64 start;