Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp175336pxf; Wed, 24 Mar 2021 02:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC0wxu3DjWaX2N3944ysQ4nRYic/u4PnSBu/QlhZKt4zTmqNCbWTnTwUhziaUluw15eQuW X-Received: by 2002:a05:6402:48c:: with SMTP id k12mr2327134edv.237.1616577261959; Wed, 24 Mar 2021 02:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616577261; cv=none; d=google.com; s=arc-20160816; b=pG32cAztgzR2eVqjZH94nzu4tvSqzS7vXouFlWNDc4VSNHMPavhC0G+iOUmGWJjgDL wayzruqlQI32ZMqGNV2gxeikzmSam0ygCIoNDYSJyxQPWx4+mCDRoloVPbV/XsQq6HVw WiRgQIT04V/xQ4YoOqMamtnniuyei5AG2KdoBvxlhPi9Zp5fZARmxMu3lkuMPFey0xn1 dgO+HhbGeyvv1adc2YjMcH3xReCxEigdOlGBaVO0GOnfSANPPqdMJVLZxJaLMglmewOY Dm23Z1t3JCKdLbAvWMsd30LRjkKh69C0H1/AY1/KbF0teTAez2VGEOD0mHOv+VtYSaPr gB/A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yTViBd2CblQCYYTYIA/BnWrPbYp/Rg6Ysmy5b/6qMok=; b=IK9XcXdy+jQt2DtfHloRlsuq2NDkGVhkdqPtSazZqhmYdbhfGQUxD7iHD5opxNlQS4 T3IIFxAJkUqQq73SkEM86sENJB+4vu8syA69zdQbYKCpHONN3LxJfOawwgmyKw/VDlyo m/LT+qq2PUl8rE1nVmwpUXJBKtBwaY37PAZ9owgly16GCzLDmAmgWCtUQvOacdSBr1H3 +9zh5bGLP4Cjsa0w1JL4KZLfZvCeUDbEBeHjZQrXQjjtyaEhnXcKxg/HZLd99wbVCGLu RGMEjYrvOrYXjCcr92hdY7nggGAG0KnInwZdBEfsVbR9Ebp96oTBkdmRCGwSaZS4G5iM RJQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="b4+g/DEA"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c20si1489065ejr.71.2021.03.24.02.13.59; Wed, 24 Mar 2021 02:14:21 -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=@chromium.org header.s=google header.b="b4+g/DEA"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234747AbhCXCFG (ORCPT + 99 others); Tue, 23 Mar 2021 22:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234724AbhCXCEt (ORCPT ); Tue, 23 Mar 2021 22:04:49 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C7E5C061763 for ; Tue, 23 Mar 2021 19:04:49 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id t20so7099152plr.13 for ; Tue, 23 Mar 2021 19:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yTViBd2CblQCYYTYIA/BnWrPbYp/Rg6Ysmy5b/6qMok=; b=b4+g/DEALeK+0LblrPRdyC7/O4Xdztch96h9gpl27A3SR2nHtlOPNjeKB3HvKk6Jqr zY6tuHTg6dtpWzsLjwIeQNpV8bvwyrrk6z7ieedC26/5lifdiUdDnPYlj88b+DY6rNIG +2Gk9Vz2ZZzFuUSwmZCUhI37Ejk0tXOItOwaA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yTViBd2CblQCYYTYIA/BnWrPbYp/Rg6Ysmy5b/6qMok=; b=gXpTOB18UK+6q9C/jhe5kql960eGU6ICNa/g9aJfW7O0umKVzSMazoCNtP4XWZtyb3 Q5xGQ+j9MsIvMUJpk1Z30rgKr0ONwV0iM+4UnDqZyyfEKeaV7uZZYzm1lLEbw2QjbV7n sdcDE4tkbEPQgk3fcqyEr7SOPyr2j0cBg9I/XC+8moAWu7CGGrqZl0SEjjsk39Agii30 9Sul96TBQXK47mQVYmjOTDJGa0nITmduGvBNhh8qHcaD3+qS0UGXHmFJtUS7wlppKfbr BKdb3tHBOTXKt6QBmwq9iTBvGLIMe1hnle+j26T6W3M8f05h+kQAXyc1KH6PcNdt8zTZ 417Q== X-Gm-Message-State: AOAM5329F5rE0dN5f9FQY8qob6yPpYZ8kNS9AHtVgKDrF3GN+593rFIi IAknEXXuXOCU8X6eavHPqvpRgmrjfEXHAA== X-Received: by 2002:a17:90a:2a41:: with SMTP id d1mr933288pjg.164.1616551488794; Tue, 23 Mar 2021 19:04:48 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:84ac:62f7:16a8:ccc7]) by smtp.gmail.com with ESMTPSA id b3sm389441pjg.41.2021.03.23.19.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 19:04:48 -0700 (PDT) From: Stephen Boyd To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Alexei Starovoitov , Jessica Yu , Evan Green , Hsin-Yi Wang , Dave Young , Baoquan He , Vivek Goyal , kexec@lists.infradead.org Subject: [PATCH v2 02/12] buildid: Add method to get running kernel's build ID Date: Tue, 23 Mar 2021 19:04:33 -0700 Message-Id: <20210324020443.1815557-3-swboyd@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210324020443.1815557-1-swboyd@chromium.org> References: <20210324020443.1815557-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add vmlinux_build_id() so that callers 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 | 2 ++ lib/buildid.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/buildid.h b/include/linux/buildid.h index ebce93f26d06..2ff6b1b7cc9b 100644 --- a/include/linux/buildid.h +++ b/include/linux/buildid.h @@ -10,4 +10,6 @@ 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); +const unsigned char *vmlinux_build_id(void); + #endif diff --git a/lib/buildid.c b/lib/buildid.c index 010ab0674cb9..fa1b6466b4b8 100644 --- a/lib/buildid.c +++ b/lib/buildid.c @@ -4,6 +4,7 @@ #include #include #include +#include #define BUILD_ID 3 @@ -171,3 +172,21 @@ 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); } + +/** + * vmlinux_build_id - Get the running kernel's build ID + * + * Return: Running kernel's build ID + */ +const unsigned char *vmlinux_build_id(void) +{ + extern const void __start_notes __weak; + extern const void __stop_notes __weak; + unsigned int size = &__stop_notes - &__start_notes; + static unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX]; + + if (!memchr_inv(vmlinux_build_id, 0, BUILD_ID_SIZE_MAX)) + build_id_parse_buf(&__start_notes, vmlinux_build_id, size); + + return vmlinux_build_id; +} -- https://chromeos.dev