From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 886101170E for ; Mon, 11 Sep 2023 13:58:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1D56C433CA; Mon, 11 Sep 2023 13:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694440687; bh=dNznVvXsnHJ4j3+N71QtfTo0eW7MOg+YTRF0cACyvXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYwrV2umzyJSh6VJka8KXEMYHhauFRovMsiE19p0JBWzow6nM0npOT5ztNbMprrYn xMNU2X5cDvMNQZw9FoukgDiNFNev+RBC4EyktCf0KVN9sJSU3Pkrj5mC9IMogXy1nz ZDQ5WnmtIXh/G6j/dr30ZPgcjpAI9MZRDqAAOVU4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuan-Ying Lee , Pankaj Raghav , AngeloGioacchino Del Regno , Chinwen Chang , Jan Kiszka , Kieran Bingham , Luis Chamberlain , Matthias Brugger , Qun-Wei Lin , Andrew Morton , Sasha Levin Subject: [PATCH 6.5 150/739] scripts/gdb: fix lx-lsmod show the wrong size Date: Mon, 11 Sep 2023 15:39:09 +0200 Message-ID: <20230911134655.316645506@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.921299741@linuxfoundation.org> References: <20230911134650.921299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuan-Ying Lee [ Upstream commit fb40b0537342e1acd5c2daf2ff6780c1d0d2883c ] 'lsmod' shows total core layout size, so we need to sum up all the sections in core layout in gdb scripts. / # lsmod kasan_test 200704 0 - Live 0xffff80007f640000 Before patch: (gdb) lx-lsmod Address Module Size Used by 0xffff80007f640000 kasan_test 36864 0 After patch: (gdb) lx-lsmod Address Module Size Used by 0xffff80007f640000 kasan_test 200704 0 Link: https://lkml.kernel.org/r/20230710092852.31049-1-Kuan-Ying.Lee@mediatek.com Fixes: b4aff7513df3 ("scripts/gdb: use mem instead of core_layout to get the module address") Signed-off-by: Kuan-Ying Lee Reviewed-by: Pankaj Raghav Cc: AngeloGioacchino Del Regno Cc: Chinwen Chang Cc: Jan Kiszka Cc: Kieran Bingham Cc: Luis Chamberlain Cc: Matthias Brugger Cc: Qun-Wei Lin Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- scripts/gdb/linux/constants.py.in | 3 +++ scripts/gdb/linux/modules.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index 50a92c4e9984e..fab74ca9df6fc 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -64,6 +64,9 @@ LX_GDBPARSED(IRQ_HIDDEN) /* linux/module.h */ LX_GDBPARSED(MOD_TEXT) +LX_GDBPARSED(MOD_DATA) +LX_GDBPARSED(MOD_RODATA) +LX_GDBPARSED(MOD_RO_AFTER_INIT) /* linux/mount.h */ LX_VALUE(MNT_NOSUID) diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 261f28640f4cd..f76a43bfa15fc 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command): " " if utils.get_long_type().sizeof == 8 else "")) for module in module_list(): - layout = module['mem'][constants.LX_MOD_TEXT] + text = module['mem'][constants.LX_MOD_TEXT] + text_addr = str(text['base']).split()[0] + total_size = 0 + + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): + total_size += module['mem'][i]['size'] + gdb.write("{address} {name:<19} {size:>8} {ref}".format( - address=str(layout['base']).split()[0], + address=text_addr, name=module['name'].string(), - size=str(layout['size']), + size=str(total_size), ref=str(module['refcnt']['counter'] - 1))) t = self._module_use_type.get_type().pointer() -- 2.40.1