From patchwork Thu Jul 8 01:09:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12364427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36514C11F66 for ; Thu, 8 Jul 2021 01:09:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0D9F61CDA for ; Thu, 8 Jul 2021 01:09:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0D9F61CDA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D29646B0099; Wed, 7 Jul 2021 21:09:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFFC16B009A; Wed, 7 Jul 2021 21:09:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA1266B009B; Wed, 7 Jul 2021 21:09:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id A21356B0099 for ; Wed, 7 Jul 2021 21:09:16 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 08244181AC9C6 for ; Thu, 8 Jul 2021 01:09:16 +0000 (UTC) X-FDA: 78337637112.26.2E95ABC Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP id 6BCFC20019DD for ; Thu, 8 Jul 2021 01:09:15 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id DA57461CD9; Thu, 8 Jul 2021 01:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1625706554; bh=ca7ZImwfVHz88xDeO01M4RQiuIK/wsfCMv4xDj31L/k=; h=Date:From:To:Subject:In-Reply-To:From; b=Uwz/u+Uh7HaPJodPGI5x7qe+qpezenCrUtD5AUKwhj4LmfnqlIdMfcqVvymjPegAg oSpNFKeLEI+9pTz2Ei0aW5qYczM32wcU9KNss7mbvBHBne9K1fHUAlgrOlTbIoES4q Lnn20sHFLkr66rPIWzDqrxpmrQfVcWs6GjCibgpg= Date: Wed, 07 Jul 2021 18:09:13 -0700 From: Andrew Morton To: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, ast@kernel.org, bhe@redhat.com, bp@alien8.de, catalin.marinas@arm.com, dyoung@redhat.com, evgreen@chromium.org, hsinyi@chromium.org, jeyu@kernel.org, jolsa@kernel.org, khlebnikov@yandex-team.ru, linux-mm@kvack.org, linux@rasmusvillemoes.dk, mingo@redhat.com, mm-commits@vger.kernel.org, pmladek@suse.com, rostedt@goodmis.org, sashal@kernel.org, sergey.senozhatsky@gmail.com, swboyd@chromium.org, tglx@linutronix.de, torvalds@linux-foundation.org, vgoyal@redhat.com, will@kernel.org, willy@infradead.org Subject: [patch 33/54] buildid: stash away kernels build ID on init Message-ID: <20210708010913.9QJXJoDJ6%akpm@linux-foundation.org> In-Reply-To: <20210707175950.eceddb86c6c555555d4730e2@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Stat-Signature: krkaujogaxpfiy8n9tj4sdz337wh16ij X-Rspamd-Queue-Id: 6BCFC20019DD X-Rspam-User: nil X-Rspamd-Server: rspam01 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="Uwz/u+Uh"; dmarc=none; spf=pass (imf26.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1625706555-539167 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Stephen Boyd Subject: buildid: stash away kernels build ID on init Parse the kernel's build ID at initialization so that other code can print a hex format string representation of the running kernel's build ID. This will be used in the kdump and dump_stack code so that developers can easily locate the vmlinux debug symbols for a crash/stacktrace. [swboyd@chromium.org: fix implicit declaration of init_vmlinux_build_id()] Link: https://lkml.kernel.org/r/CAE-0n51UjTbay8N9FXAyE7_aR2+ePrQnKSRJ0gbmRsXtcLBVaw@mail.gmail.com Link: https://lkml.kernel.org/r/20210511003845.2429846-4-swboyd@chromium.org Signed-off-by: Stephen Boyd Acked-by: Baoquan He Cc: Jiri Olsa Cc: Alexei Starovoitov Cc: Jessica Yu Cc: Evan Green Cc: Hsin-Yi Wang Cc: Dave Young Cc: Vivek Goyal Cc: Andy Shevchenko Cc: Borislav Petkov Cc: Catalin Marinas Cc: Ingo Molnar Cc: Konstantin Khlebnikov Cc: Matthew Wilcox Cc: Petr Mladek Cc: Rasmus Villemoes Cc: Sasha Levin Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Will Deacon Signed-off-by: Andrew Morton --- include/linux/buildid.h | 3 +++ init/main.c | 2 ++ lib/buildid.c | 15 +++++++++++++++ 3 files changed, 20 insertions(+) --- a/include/linux/buildid.h~buildid-stash-away-kernels-build-id-on-init +++ a/include/linux/buildid.h @@ -10,4 +10,7 @@ int build_id_parse(struct vm_area_struct __u32 *size); int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size); +extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX]; +void init_vmlinux_build_id(void); + #endif --- a/init/main.c~buildid-stash-away-kernels-build-id-on-init +++ a/init/main.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -913,6 +914,7 @@ asmlinkage __visible void __init __no_sa set_task_stack_end_magic(&init_task); smp_setup_processor_id(); debug_objects_early_init(); + init_vmlinux_build_id(); cgroup_init_early(); --- a/lib/buildid.c~buildid-stash-away-kernels-build-id-on-init +++ a/lib/buildid.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include @@ -172,3 +173,17 @@ int build_id_parse_buf(const void *buf, { return parse_build_id_buf(build_id, NULL, buf, buf_size); } + +unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX] __ro_after_init; + +/** + * init_vmlinux_build_id - Compute and stash the running kernel's build ID + */ +void __init init_vmlinux_build_id(void) +{ + extern const void __start_notes __weak; + extern const void __stop_notes __weak; + unsigned int size = &__stop_notes - &__start_notes; + + build_id_parse_buf(&__start_notes, vmlinux_build_id, size); +}