Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1469403iob; Thu, 5 May 2022 01:51:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx94EoCNjXUCcEKfcl6qBqP/nvEKq2eXVLepZ/ZNqEdk+zsp2UWdV+PeTrcpJVr6WaIK8aU X-Received: by 2002:a05:6402:4410:b0:427:ab6f:a39a with SMTP id y16-20020a056402441000b00427ab6fa39amr27252777eda.120.1651740695310; Thu, 05 May 2022 01:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651740695; cv=none; d=google.com; s=arc-20160816; b=CLvbKd9nvHeYqZBuw+3eO4YIln4VpwBGgeqo/HiOMlSMTfEcbU4BE/eYQeyPmN9IwV TCTUV/D+dSpjtP295MheUXRRW6/OFIh8GLd1U5TRmnceSOldliQqt/yFEaZxZfolvx7U yA0ltOc08nga00y/xSyorGMsrlA4gcIAdgOAOmzTFNy89vh5BR5uXVhVkaepHW84K7PT NKevDlNhyIWZ9lWczndk3VgaRjhru4xiVV/JP9WOYRS4NBVgwKQkjikiIzmS3L51rf9S 7VB1Fp3gmU7lV+s1VClJ7o4m5P1WjFtJF2Ep/RCzVCtEJ7RXsovHA7mSIOHqpXiuzEUk 7H+w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ucQ9/ow0uX0jUHSakd+D9ewk3Yvo+X6TX7SmK6jIdKQ=; b=bdo3LhHhio+MhVMCdVAYyueN+SiTvMLgM1Czaim3FVEWZmJFcPOZlcBp7uiRKfpch8 R1EuU5ZZ2LqtHNU/5lacwWyQz5d9SwzIOgDGUGS32I5MUShYEGoLs2CHvlQHSgUVovxa cjYFwZy29gwkFgD2iHh8JVhyQbeaX71t5Nv6uuSMoy00cCslSNUtMZ2xsiqzHBANbpxN o7qvqH3Q7nzQEFxluvYiVG62J51/CVLkxCIyyo9UqioRZVTxWYC+6QD8kpFXyVdytUbG NqmhhC6VyVxtTNyaNWeO3YruB8Y3Fye538WrWIS/cvRuWThZmfLNvfowZXF0UQr32+tW NnqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhugop2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020a056402274e00b00426286d41afsi1702912edd.284.2022.05.05.01.51.11; Thu, 05 May 2022 01:51:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhugop2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359078AbiEDRnr (ORCPT + 99 others); Wed, 4 May 2022 13:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356056AbiEDRJA (ORCPT ); Wed, 4 May 2022 13:09:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E54527F5; Wed, 4 May 2022 09:54:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DB9F5B827A7; Wed, 4 May 2022 16:54:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66AC6C385A4; Wed, 4 May 2022 16:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683290; bh=lxOCNLhoXuv1p/yYbOt/qn66HbF114gIdpkYgvRyQOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhugop2ZMxygL+Em7/qjYMYiJOi0gP8Lrzo/NxHRyuLDqn87sb3lNq3o3xQlBRjQg LfqmzgaK4PrIHJ82jVhCz8nvl+N2I9402RotlOQ+CCBn9iUSPEIvfLOKFD9l3V9zb4 17/7pJUHll/pO9fSV2a7SxhUQeWGsfPv701glhSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , Ian Rogers , Heiko Carstens , Ingo Molnar , Jiri Olsa , John Garry , Leo Yan , Mark Rutland , Masami Hiramatsu , Mathieu Poirier , Michael Ellerman , Michael Petlan , Peter Zijlstra , Song Liu , Will Deacon , linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Arnaldo Carvalho de Melo Subject: [PATCH 5.15 156/177] perf symbol: Update symbols__fixup_end() Date: Wed, 4 May 2022 18:45:49 +0200 Message-Id: <20220504153107.383498779@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim commit 8799ebce84d672aae1dc3170510f6a3e66f96b11 upstream. Now arch-specific functions all do the same thing. When it fixes the symbol address it needs to check the boundary between the kernel image and modules. For the last symbol in the previous region, it cannot know the exact size as it's discarded already. Thus it just uses a small page size (4096) and rounds it up like the last symbol. Fixes: 3cf6a32f3f2a4594 ("perf symbols: Fix symbol size calculation condition") Signed-off-by: Namhyung Kim Acked-by: Ian Rogers Cc: Heiko Carstens Cc: Ingo Molnar Cc: Jiri Olsa Cc: John Garry Cc: Leo Yan Cc: Mark Rutland Cc: Masami Hiramatsu Cc: Mathieu Poirier Cc: Michael Ellerman Cc: Michael Petlan Cc: Peter Zijlstra Cc: Song Liu Cc: Will Deacon Cc: linux-s390@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20220416004048.1514900-3-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/symbol.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -217,8 +217,8 @@ again: } } -void symbols__fixup_end(struct rb_root_cached *symbols, - bool is_kallsyms __maybe_unused) +/* Update zero-sized symbols using the address of the next symbol */ +void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms) { struct rb_node *nd, *prevnd = rb_first_cached(symbols); struct symbol *curr, *prev; @@ -232,8 +232,29 @@ void symbols__fixup_end(struct rb_root_c prev = curr; curr = rb_entry(nd, struct symbol, rb_node); - if (prev->end == prev->start || prev->end != curr->start) - arch__symbols__fixup_end(prev, curr); + /* + * On some architecture kernel text segment start is located at + * some low memory address, while modules are located at high + * memory addresses (or vice versa). The gap between end of + * kernel text segment and beginning of first module's text + * segment is very big. Therefore do not fill this gap and do + * not assign it to the kernel dso map (kallsyms). + * + * In kallsyms, it determines module symbols using '[' character + * like in: + * ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi] + */ + if (prev->end == prev->start) { + /* Last kernel/module symbol mapped to end of page */ + if (is_kallsyms && (!strchr(prev->name, '[') != + !strchr(curr->name, '['))) + prev->end = roundup(prev->end + 4096, 4096); + else + prev->end = curr->start; + + pr_debug4("%s sym:%s end:%#" PRIx64 "\n", + __func__, prev->name, prev->end); + } } /* Last entry */