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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F90FC77B7A for ; Tue, 6 Jun 2023 11:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235772AbjFFL1v (ORCPT ); Tue, 6 Jun 2023 07:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235701AbjFFL1t (ORCPT ); Tue, 6 Jun 2023 07:27:49 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F5CE52; Tue, 6 Jun 2023 04:27:46 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Qb7PZ539nz18M4Z; Tue, 6 Jun 2023 19:22:58 +0800 (CST) Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 19:27:43 +0800 Subject: Re: [PATCH v4 3/3] kallsyms: make kallsyms_show_value() as generic function To: Maninder Singh , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Onkarnath References: <20230606042802.508954-1-maninder1.s@samsung.com> <20230606042802.508954-3-maninder1.s@samsung.com> From: "Leizhen (ThunderTown)" Message-ID: Date: Tue, 6 Jun 2023 19:27:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20230606042802.508954-3-maninder1.s@samsung.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/6/6 12:28, Maninder Singh wrote: > This change makes function kallsyms_show_value() as > generic function without dependency on CONFIG_KALLSYMS. > > Now module address will be displayed with lsmod and /proc/modules. > > Earlier: > ======= > / # insmod test.ko > / # lsmod > test 12288 0 - Live 0x0000000000000000 (O) // No Module Load address > / # > > With change: > ========== > / # insmod test.ko > / # lsmod > test 12288 0 - Live 0xffff800000fc0000 (O) // Module address > / # cat /proc/modules > test 12288 0 - Live 0xffff800000fc0000 (O) Reviewed-by: Zhen Lei > > Co-developed-by: Onkarnath > Signed-off-by: Onkarnath > Signed-off-by: Maninder Singh > --- > include/linux/kallsyms.h | 11 +++-------- > kernel/ksyms_common.c | 2 -- > 2 files changed, 3 insertions(+), 10 deletions(-) > > diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h > index 1037f4957caa..c3f075e8f60c 100644 > --- a/include/linux/kallsyms.h > +++ b/include/linux/kallsyms.h > @@ -65,6 +65,9 @@ static inline void *dereference_symbol_descriptor(void *ptr) > return ptr; > } > > +/* How and when do we show kallsyms values? */ > +extern bool kallsyms_show_value(const struct cred *cred); > + > #ifdef CONFIG_KALLSYMS > unsigned long kallsyms_sym_address(int idx); > int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long), > @@ -94,9 +97,6 @@ extern int sprint_backtrace_build_id(char *buffer, unsigned long address); > > int lookup_symbol_name(unsigned long addr, char *symname); > > -/* How and when do we show kallsyms values? */ > -extern bool kallsyms_show_value(const struct cred *cred); > - > #else /* !CONFIG_KALLSYMS */ > > static inline unsigned long kallsyms_lookup_name(const char *name) > @@ -154,11 +154,6 @@ static inline int lookup_symbol_name(unsigned long addr, char *symname) > return -ERANGE; > } > > -static inline bool kallsyms_show_value(const struct cred *cred) > -{ > - return false; > -} > - > static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long), > void *data) > { > diff --git a/kernel/ksyms_common.c b/kernel/ksyms_common.c > index e776f12f0f5a..9603bbef095c 100644 > --- a/kernel/ksyms_common.c > +++ b/kernel/ksyms_common.c > @@ -6,7 +6,6 @@ > #include > #include > > -#ifdef CONFIG_KALLSYMS > static inline int kallsyms_for_perf(void) > { > #ifdef CONFIG_PERF_EVENTS > @@ -42,4 +41,3 @@ bool kallsyms_show_value(const struct cred *cred) > return false; > } > } > -#endif > -- Regards, Zhen Lei