Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp255992pxy; Wed, 28 Apr 2021 03:46:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0ragF0C03mcKxDJn+EHrYQW2ksnCTdJ/pVPSVLx0t0hzvu6rth1qNdkFk5WFYyFsVbrlu X-Received: by 2002:a63:d70c:: with SMTP id d12mr3094887pgg.328.1619606801388; Wed, 28 Apr 2021 03:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619606801; cv=none; d=google.com; s=arc-20160816; b=QiYhNDyGkwJfzrobFwiyU2UaGCtIybtRNb1wuUFogsl+AKdxkKNa0I6pRbuHYCGmkn wh74c7PA4cLJ5CLxjvfY8LS+2JX6Ie7Cy5h+kah/3NJEtyKgy/BP5viIp7l6OWlOafgj 2Znp5191+AAV/ltD3oTkCuszGnJ58S2pYoyMVMxSiaZQadHjwbb/BQ1BCbxRyqGwLb/g D2q3+zz0KcRFMl04OY3VAMpqxmqk+hATviCcwmmzPgAeo46Hl/GQ0rH6q7H3xN+uj4AX nLjhKkkFOrBfzBUoDA+OTFXiQBLA/sjNX5OB83ZmhgvniUbnCobAbejk2lLximX0chlO IMTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=id68obkVrtWS6HXPvkWeXSQyvZyR++NmzAuxtZLxn7A=; b=Uaiz181GWXOmLWqy+lfYDit0Bsbocu826Wpuf5RVuu3zEYvDzV8Ifp19B1SbZmCdgA uU7a1IFkx//QkTXREE5KiNy63iNh8Fq4NekkYerHCtg5w7bo3UPtQHUDSzd3XJvk195V 7HqEmf36DnRYEeWbkod7MW2wRUHLzJou7bHyr0VXlRnmm+IcTce6NyMmz5jEOtdHKgMX +FkuG/YvaSF9S/v0uhaEHSqsmAFCGlRLpgVmEQcZ7KdkNop/2MAW+icobUehAh1n/7mp 3c5qyWOqrbWnkvQQK6CQqcjdWe4WFWjXZYajW4vTRrZ+OfsGdpsp74T5xfxpl+uorLS5 QNkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WO+3HTk8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u71si3295701pgc.366.2021.04.28.03.46.26; Wed, 28 Apr 2021 03:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WO+3HTk8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238960AbhD1KDd (ORCPT + 99 others); Wed, 28 Apr 2021 06:03:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35301 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238428AbhD1KD3 (ORCPT ); Wed, 28 Apr 2021 06:03:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619604164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=id68obkVrtWS6HXPvkWeXSQyvZyR++NmzAuxtZLxn7A=; b=WO+3HTk83qmFOp+qU9OCdyxQGQf8K+SjyZv17RI98XbgQFm+E03OEkvBzZcwK7WFvpduXH /wqzMufb4ApHKD6bSRR3HF8a5VjQuZyOc42GD0w/jhEfJnMFmU5xQtTGFm4+jdrffSiv+s Mwp5zfmy7s4ifzC//ya2rr0U6fliV80= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-ZqXsWSWtMkG_TuH05OLV4Q-1; Wed, 28 Apr 2021 06:02:42 -0400 X-MC-Unique: ZqXsWSWtMkG_TuH05OLV4Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E2FC18B615D; Wed, 28 Apr 2021 10:02:33 +0000 (UTC) Received: from localhost (ovpn-13-87.pek2.redhat.com [10.72.13.87]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 761CB6B8D4; Wed, 28 Apr 2021 10:02:32 +0000 (UTC) Date: Wed, 28 Apr 2021 18:02:29 +0800 From: Baoquan He To: Stephen Boyd Cc: Andrew Morton , linux-kernel@vger.kernel.org, Jiri Olsa , Alexei Starovoitov , Jessica Yu , Evan Green , Hsin-Yi Wang , Dave Young , Vivek Goyal , kexec@lists.infradead.org Subject: Re: [PATCH v5 03/13] buildid: Stash away kernels build ID on init Message-ID: <20210428100229.GA8374@localhost.localdomain> References: <20210420215003.3510247-1-swboyd@chromium.org> <20210420215003.3510247-4-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210420215003.3510247-4-swboyd@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/20/21 at 02:49pm, Stephen Boyd wrote: > 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. > > Cc: Jiri Olsa > Cc: Alexei Starovoitov > Cc: Jessica Yu > Cc: Evan Green > Cc: Hsin-Yi Wang > Cc: Dave Young > Cc: Baoquan He > Cc: Vivek Goyal > Cc: > Signed-off-by: Stephen Boyd > --- > include/linux/buildid.h | 3 +++ > init/main.c | 1 + > lib/buildid.c | 15 +++++++++++++++ > 3 files changed, 19 insertions(+) > > diff --git a/include/linux/buildid.h b/include/linux/buildid.h > index ebce93f26d06..f375900cf9ed 100644 > --- a/include/linux/buildid.h > +++ b/include/linux/buildid.h > @@ -10,4 +10,7 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id, > __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 > diff --git a/init/main.c b/init/main.c > index 53b278845b88..eaede2f41327 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -857,6 +857,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) > set_task_stack_end_magic(&init_task); > smp_setup_processor_id(); > debug_objects_early_init(); > + init_vmlinux_build_id(); > > cgroup_init_early(); > > diff --git a/lib/buildid.c b/lib/buildid.c > index 6aea1c4e5e85..1103ed46214f 100644 > --- a/lib/buildid.c > +++ b/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, unsigned char *build_id, u32 buf_size) > { > 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); > +} LGTM, thx. Acked-by: Baoquan He