Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5438149ybh; Wed, 7 Aug 2019 06:05:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHnbb00Ihd1HOc5cx3++rljQHVBFw3XzkkDdwdyh2Pp8LhZQ7SEmbfPDRhDajA88lvnn7q X-Received: by 2002:a17:902:c509:: with SMTP id o9mr8260827plx.222.1565183123458; Wed, 07 Aug 2019 06:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565183123; cv=none; d=google.com; s=arc-20160816; b=aaR6bMJm2y7IAyxdxSNDGQW7zpytW3ZgUYqsSF+E3DpxHj3yF5qsni8HJj7wK56dU7 Vq1ZaS/yUKjnX1uvpqcB7HciGHfhCpdDOQh8iMJPpMVFrNHstKmsDjYpFeybh7Ymcik3 nSCacRCA0EGUez8E+PouTb/Ty5wnotODEj9N6G7PaUyr3lDk2NNc6EZDsDUdP0PtDUbQ Gv1mF4UVZjLH6qzS9b61bL8eNkiI/s0qic4wJh57Hq0V4Q3q5a1e50Er0jJdbKoAj1YX 0LUzKryLL6R157Jk8XvaScoOYr1k6NA7ilWAB9zeOha0cUnn7JsVDzxLJDbagNcHYSMp wlIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=sll3cquHDHsEK/N7ohKPeCjBJoS1aFGfGY4rTHFGcsg=; b=uxqz/Buy2GTXYsb3mIw5sGwUpeGuTNFrkGLtQcwO0loDJFXXyxvpC7waFivth+7mmT CAVidM4BwAebVvQVS9ixw7fKkEFOjD83die3YjfjWsi8toMcTrYZhC67MlcZNAOF/Zab RJoVFP+HTgxg6oOSbGZR+bzmweY6FDRf220P2GWuywOAQ+QOzVaC9JxdSGSlNE2mLB3G VthfaIbdo5YJZtqvu3WboRy0GfPuPrSaonq+yiyWQl83SY5fwcQCozj3QzM3Zv3KjD8A jzq+KMR1F0n4AsfiAA2xi1xXoNPA2Ahya6oz0Q935miTyh1gZ373ooPawxjRQYpcCxhN 3eZg== ARC-Authentication-Results: i=1; mx.google.com; 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 44si46668128plb.366.2019.08.07.06.05.06; Wed, 07 Aug 2019 06:05:23 -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; 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 S2388088AbfHGNDm (ORCPT + 99 others); Wed, 7 Aug 2019 09:03:42 -0400 Received: from ozlabs.org ([203.11.71.1]:39343 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387981AbfHGNDm (ORCPT ); Wed, 7 Aug 2019 09:03:42 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 463WsR3f5pz9sNx; Wed, 7 Aug 2019 23:03:39 +1000 (AEST) From: Michael Ellerman To: Jason Yan , linuxppc-dev@lists.ozlabs.org, diana.craciun@nxp.com, christophe.leroy@c-s.fr, benh@kernel.crashing.org, paulus@samba.org, npiggin@gmail.com, keescook@chromium.org, kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org, wangkefeng.wang@huawei.com, yebin10@huawei.com, thunder.leizhen@huawei.com, jingxiangfeng@huawei.com, fanchengyang@huawei.com, zhaohongjiang@huawei.com, Jason Yan Subject: Re: [PATCH v5 10/10] powerpc/fsl_booke/kaslr: dump out kernel offset information on panic In-Reply-To: <20190807065706.11411-11-yanaijie@huawei.com> References: <20190807065706.11411-1-yanaijie@huawei.com> <20190807065706.11411-11-yanaijie@huawei.com> Date: Wed, 07 Aug 2019 23:03:35 +1000 Message-ID: <87zhklt9eg.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jason Yan writes: > When kaslr is enabled, the kernel offset is different for every boot. > This brings some difficult to debug the kernel. Dump out the kernel > offset when panic so that we can easily debug the kernel. Some of this is taken from the arm64 version right? Please say so when you copy other people's code. > diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c > index c4ed328a7b96..078fe3d76feb 100644 > --- a/arch/powerpc/kernel/machine_kexec.c > +++ b/arch/powerpc/kernel/machine_kexec.c > @@ -86,6 +86,7 @@ void arch_crash_save_vmcoreinfo(void) > VMCOREINFO_STRUCT_SIZE(mmu_psize_def); > VMCOREINFO_OFFSET(mmu_psize_def, shift); > #endif > + vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); > } There's no mention of that in the commit log. Please split it into a separate patch and describe what you're doing and why. > diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c > index 1f8db666468d..064075f02837 100644 > --- a/arch/powerpc/kernel/setup-common.c > +++ b/arch/powerpc/kernel/setup-common.c > @@ -715,12 +715,31 @@ static struct notifier_block ppc_panic_block = { > .priority = INT_MIN /* may not return; must be done last */ > }; > > +/* > + * Dump out kernel offset information on panic. > + */ > +static int dump_kernel_offset(struct notifier_block *self, unsigned long v, > + void *p) > +{ > + pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n", > + kaslr_offset(), KERNELBASE); > + > + return 0; > +} > + > +static struct notifier_block kernel_offset_notifier = { > + .notifier_call = dump_kernel_offset > +}; > + > void __init setup_panic(void) > { > /* PPC64 always does a hard irq disable in its panic handler */ > if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic) > return; > atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block); > + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0) > + atomic_notifier_chain_register(&panic_notifier_list, > + &kernel_offset_notifier); Don't you want to do that before the return above? > } cheers