Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp131903rwl; Tue, 28 Mar 2023 22:32:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YtOZ0aajigxLt3JX2d7PbKOtp9Mt2AcPZtt6d3wPJq8DzZM8OBxinQLw4fBv32D8Aya2an X-Received: by 2002:a05:6402:5146:b0:502:1cae:8b11 with SMTP id n6-20020a056402514600b005021cae8b11mr20618154edd.23.1680067958128; Tue, 28 Mar 2023 22:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680067958; cv=none; d=google.com; s=arc-20160816; b=bmzpCQPmgkJXy4GxDWfjnwEwi4sofyBpxMbo/GU8M8wNghTS3afBNspFWD6BZ+weq0 5VR5GjNJ+mQTJDZJ1CRtM2YCKN2Lun2BETE9ZU057I9ZiH1P3JtdtQsA5wXj2YRuRSSF KaLCj8HHo4Vfckzln/pcs3Sv9DokETSlF9JMYfrsW0dvwCY1eQ0ji86oV82nI4XJmq9n pipLfXBJxtHiVtkpG5Z9ZLIO0QP3i034ensTM5GC9bfg4TOTZfe5ewtANmj2CKxb4VS1 LAkDQhROqwvNAjZa6shEsS9jGOeYZT/NNAzySWOweNIvVUSkfC0PW15ktCCgTJqtKk+k Wtkw== 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=znueE8Pjz+VVSGWqY7Odv2deVORd+PQf1G9dvU2f580=; b=oiJJd7ugk8fkHx8tHlczho+yPElNYZShyr//J0xgbyLNzoKcPnHg8CKQ+s1ATvjExV nuAX4msr2US5XDNDDXBPxfKW69LwigxyiSeg6pqlsAarJbuP3pZcTrJTw6iLdTobKSOS YOX1SGk/pBEhnOcVWSuY41XsST4UG2Lnk6bN0AZ3XwOyNYVaixfjr187xXMruM5Vy1dI nfwIL2sdCwozjoXmJn38XRS4LO/HAvg7t9MBo8am33bZDIhoexRGN1Tabk00qdGiE5VC xOB3A7iLBrz/soGWkJ5EnsBqma/C20AE8MKquA4msM3BYG/QZ/iKdl4V4M9LB7Vlykan Fk5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=RcfUdvTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq5-20020a056402214500b004af70883594si34078017edb.244.2023.03.28.22.32.13; Tue, 28 Mar 2023 22:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=RcfUdvTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjC2Fbj (ORCPT + 99 others); Wed, 29 Mar 2023 01:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjC2Fbg (ORCPT ); Wed, 29 Mar 2023 01:31:36 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9EC30FF for ; Tue, 28 Mar 2023 22:31:35 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id h17so14363306wrt.8 for ; Tue, 28 Mar 2023 22:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1680067893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=znueE8Pjz+VVSGWqY7Odv2deVORd+PQf1G9dvU2f580=; b=RcfUdvTQifKB0+AVdk8JrXzwaJMK7YuAUA/YSj1CZ942v2C8skCQf7YhZm05RsyrBB B4HSFLSRrBz63LT+rYM4DoyzUKm2uGte1JmKH8/renUTipLEaoHQUHVAmwyN3w8/qk5j H00QzeWAI11ziHELL2oHdjOYApjcBfP2BTFqRF5oXalAE3WxwDc+4kCfca+NKq6ZF4Tw O5q9PHLvTF0t34WBg7Zr1zC7RybtgVm1Nooi4PcYYqQUJYU4h/zDifnGN22opyBF7GTi 8WsqMiVm1PoYyXx1GQ4NDpmyH10auRIjgiRlN8E50jY8S1cm/pjpS0uWWIPa63rLLXJZ g//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680067893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=znueE8Pjz+VVSGWqY7Odv2deVORd+PQf1G9dvU2f580=; b=zyp9Z2XeEDlwYRyOkXsso4gx9RCSA608quJ5VFFPLP9WUm1kGc9JSBXEI1FXeE1Ebg gVPK7APwKNzvOyQCFqfSH7XH4/ITjgMco2vmkaL+O43HIBzckciJ6yD8fTHHQRi7JcGE CRsbyynuPqAOWIAXmwM+NU/uXBKKTF0CmPLy4JOe40voDbS4J7SSVOJFIAH7zoy+84t3 JgJJ4MMk1DvurgLT+lNCJOIxjr3SXNeWrI1s/fr4L3ljXzWZtNTscVpl28/yngiKCTPG RN22XYggX20YjdjsAiXl+Q+4WF8PPDUT+OfQ1gk0x7e9gyrz34T8KnP7bkfi0FcGgvDK uYew== X-Gm-Message-State: AAQBX9dLym13i6PUai5RYfoggn1UviCxHMIb8CT9p07OfTllENbe0KG5 +Wkc4ScksIcVmcQONcER/voL9A== X-Received: by 2002:a5d:4041:0:b0:2d7:a1e2:f5 with SMTP id w1-20020a5d4041000000b002d7a1e200f5mr12656353wrp.55.1680067893656; Tue, 28 Mar 2023 22:31:33 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id e11-20020a5d65cb000000b002c55de1c72bsm29119956wrw.62.2023.03.28.22.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 22:31:33 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Ard Biesheuvel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexandre Ghiti , Zong Li Subject: [PATCH v2 2/4] riscv: Dump out kernel offset information on panic Date: Wed, 29 Mar 2023 07:29:24 +0200 Message-Id: <20230329052926.69632-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230329052926.69632-1-alexghiti@rivosinc.com> References: <20230329052926.69632-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dump out the KASLR virtual kernel offset when panic to help debug kernel. Signed-off-by: Zong Li Signed-off-by: Alexandre Ghiti --- arch/riscv/kernel/setup.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 376d2827e736..c6937839bbd8 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -333,3 +334,27 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } + +static int dump_kernel_offset(struct notifier_block *self, + unsigned long v, void *p) +{ + pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n", + kernel_map.virt_offset, + KERNEL_LINK_ADDR); + + return 0; +} + +static struct notifier_block kernel_offset_notifier = { + .notifier_call = dump_kernel_offset +}; + +static int __init register_kernel_offset_dumper(void) +{ + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) + atomic_notifier_chain_register(&panic_notifier_list, + &kernel_offset_notifier); + + return 0; +} +device_initcall(register_kernel_offset_dumper); -- 2.37.2