Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4552091ybb; Tue, 24 Mar 2020 00:32:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvsxxm8Jh33R4MKX8+qNqEEUOiGdAdgLsbvybwxqq3bDtk0oHxYsEIjGIN+5nJA4i3XldM7 X-Received: by 2002:aca:cdd1:: with SMTP id d200mr2305929oig.153.1585035124592; Tue, 24 Mar 2020 00:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585035124; cv=none; d=google.com; s=arc-20160816; b=aK7Ojmgv9EOQDiV1zzhQaQKeBKoWGxdewIyDY9JLLVsEyn8dqYFA9xX/V8v98izUdR y/t6gH+rfpoXvgazCMuHhEqDJQxv/1O24SwL7v13LmIMgw/EggXIhr1XN97fS7EFjqig 0WisP9nHrUo+LMaRJd2bnK6gpAnLH/VIwWn4NESvpTwcyMIx4/mmW6HfzC7a6SRioTQJ WlJ/OG55LmYzy4j2jQ3YBZfpI5qZY8zZjjY7Efe24XxHR62G4cdd54jJWwqQi08ktHCM wV1DV6pzEEyKOMU/CPTdx/gG1/3kbul70q02OuLB1MJjwjN9/ys+XdDQAbkHOQIYywHe 3gqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=54p31XcZy9VY/uTSVV1VAo6tqKUeT0iaZ8T4Yx3sR7Y=; b=sBc4m5oh6VECFHCPTBwEyvn2yTlyiB5rSERS5pq3d5vz1/wW+o1CH1qu8nQdlDPaEK poJ1vSvYGuOSk30cWHuEkFWg721lFGSJAtbymOfQL/FS6H39QVtMqBf552u/le+fkwH8 lgHmHKZhR0w9etWFCITD9Ho8bsgHyUQNRt6sosgNNVfY4l+ITZ543VG1z4D6zgvmLzZJ 8a/S8BVxcFzMkzSE2wtfq7Ly6qu1HXjPwAneoNCExuw9NIfKfz6OQzuhEOSZ1mEomIgo X6NlThrptEznJzmq8GzA9veFmp7QW1KBRNDPpdd4Di4owh1rYpAKqh9a5aKj8YvUGdu1 M0Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=iEXF+9cx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si8334361oth.136.2020.03.24.00.31.52; Tue, 24 Mar 2020 00:32:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=iEXF+9cx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbgCXHbN (ORCPT + 99 others); Tue, 24 Mar 2020 03:31:13 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:36488 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727535AbgCXHbL (ORCPT ); Tue, 24 Mar 2020 03:31:11 -0400 Received: by mail-pj1-f67.google.com with SMTP id nu11so1056479pjb.1 for ; Tue, 24 Mar 2020 00:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=54p31XcZy9VY/uTSVV1VAo6tqKUeT0iaZ8T4Yx3sR7Y=; b=iEXF+9cxq8xsvBHmABzfWbJjn41vgvA6oKrfEkKliYoY7j4OI83K0ywdq9cODsiA2Z v6OCCQIEj68L96a+WLVMjjt6ALm+CsD3j0D4KebwyuwLrDSgVo6P9mlbgoXk12+g8hYq h3HZjhPy1S8gcvtOkooUJKx59NBgXDGs9v2+7xxixk90ggSaHgyDTC4fWJPtMQM6OEfo 1wP2sr8P3cQdvqRJvgyEiw6sOtpJrqjA4X1skfY4hFk5KMDcO1X3+K0WPyoE+Y3vNWP+ 0/At0OSgtSowO8eLWPmOYfifL5cMVVVHKwjfRwnTsOBdpeyiYvdATTYSilWaUKS0Ndx7 0slw== 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=54p31XcZy9VY/uTSVV1VAo6tqKUeT0iaZ8T4Yx3sR7Y=; b=Kmw2HQR3BTApcBy7pckdw6vYZnv2ASegpKkCEZe8fqLahpAec4hfAat4XFSXZb5wqo Me63TuLaBqohQZX/+I2/Cnuk22BvvyaUPk2cJg4SO8CeKb0zDM2zACQnGnkMa82+/6ak QHqCzqgOmolVUYEQjEE8bNvrlIkHfxLcNEgG+5ZAuZk2Jd4kf9kIt6QpwHIgygJLrYZu VPU7AYFhb4H8Kjh0WGIwSMa5rPqB5H7KM1E6KIDIoJhFu3EmM5QN1hTbWn/GUPD6ZRC9 Bk4G3l0hmDKeTCx98/7WiOECODZZjk6LWZv4Z2pwc/S1+ue1hgnXRVhHWNk+nJUDYC/C KKTg== X-Gm-Message-State: ANhLgQ1p/r1AYutGO859RvpvMAvD5Jv9OVF8akrb3Xjr6xPbtjRPvH6U aafkAGagSVQQaOpTwHG1rSlOjw== X-Received: by 2002:a17:90a:cc14:: with SMTP id b20mr3916243pju.75.1585035071082; Tue, 24 Mar 2020 00:31:11 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id i187sm15124648pfg.33.2020.03.24.00.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 00:31:10 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, alex@ghiti.fr, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH RFC 8/8] riscv/kaslr: dump out kernel offset information on panic Date: Tue, 24 Mar 2020 15:30:53 +0800 Message-Id: X-Mailer: git-send-email 2.25.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dump out the kernel offset when panic to help debug kernel. Signed-off-by: Zong Li --- arch/riscv/kernel/setup.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 913d25e4b9fa..3ce50bf628ba 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -85,3 +85,26 @@ void __init setup_arch(char **cmdline_p) riscv_fill_hwcap(); } + +static int dump_kernel_offset(struct notifier_block *self, unsigned long v, + void *p) +{ + pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n", + get_kaslr_offset(), PAGE_OFFSET); + + 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) && get_kaslr_offset() > 0) + atomic_notifier_chain_register(&panic_notifier_list, + &kernel_offset_notifier); + + return 0; +} +__initcall(register_kernel_offset_dumper); -- 2.25.1