From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0865EC433F5 for ; Thu, 5 May 2022 13:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eUeXwjj1cdkFXFZppVFV01hqEZOI3TD2crxkHbpXPis=; b=4coZZBjY2M0soB CJcDgY2Xg4PaDNf9goWavdmw9z8m6+AKE2DNSMyPGS+XuSyhGGC4y4sISZWUgbzPX+zuvfUoAQ+to f//Th26V3S4zf0zatp8XB3LNMLVglZGRsNS1EkccblQF+ywV6x3wCm/1STl+Iz0dYk34WqDG4HUFr 5N1GC2PdP2ePntGD913+HbLflAQCu+ozEO4+La5yltSy0F82C1ZfIGPnTE5sLAs/QQ3K2sRmsVByw OTkcaLr/2HqJMHOhzB1Odn1X35pTctu790b6m5qWgd91a/gOkN3r93o+e8+uF76bbObrrqOC6bo+z 7J77qg/gkrSUDn60dPYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmb9N-00Fws9-3N; Thu, 05 May 2022 13:04:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmb9K-00Fwre-BU for linux-arm-kernel@lists.infradead.org; Thu, 05 May 2022 13:04:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91CCD106F; Thu, 5 May 2022 06:04:04 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.29.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F2213F885; Thu, 5 May 2022 06:04:03 -0700 (PDT) Date: Thu, 5 May 2022 14:04:00 +0100 From: Mark Rutland To: Zhen Lei Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] arm64: add the printing of tpidr_elx in __show_regs() Message-ID: References: <20220505095640.312-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220505095640.312-1-thunder.leizhen@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220505_060406_476366_E404416C X-CRM114-Status: GOOD ( 20.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 05, 2022 at 05:56:40PM +0800, Zhen Lei wrote: > Commit 7158627686f0 ("arm64: percpu: implement optimised pcpu access > using tpidr_el1") and commit 6d99b68933fb ("arm64: alternatives: use > tpidr_el2 on VHE hosts") use tpidr_elx to cache my_cpu_offset to optimize > pcpu access. However, when performing reverse execution based on the > registers and the memory contents in kdump, this information is sometimes > required if there is a pcpu access. > > Signed-off-by: Zhen Lei > --- > arch/arm64/kernel/process.c | 5 +++++ > 1 file changed, 5 insertions(+) > > v2 --> v3: > 1) Relace "switch (read_sysreg(CurrentEL))" statement with > "if (is_kernel_in_hyp_mode())" statement. > 2) Change the register name to lowercase. > > v1 --> v2: > Directly print the tpidr_elx register of the current exception level. > Avoid coupling with the implementation of 'my_cpu_offset'. > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 7fa97df55e3ad3f..7b6bccce9721c36 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -216,6 +216,11 @@ void __show_regs(struct pt_regs *regs) > show_regs_print_info(KERN_DEFAULT); > print_pstate(regs); > > + if (is_kernel_in_hyp_mode()) > + printk("tpidr_el2 : %016llx\n", read_sysreg(tpidr_el2)); > + else > + printk("tpidr_el1 : %016llx\n", read_sysreg(tpidr_el1)); If we care about the offset specifically, this would be simpler as: printk("cpu offset : 0x%016lx\n", __my_cpu_offset()); ... which should do the right thing even if we repurpose the TPIDRs and move the offset elsewhere. As Will says, we should only log this for !user_mode(regs), so it could be placed in the block below, immediately before we print the kernel PC, i.e. if (!user_mode_regs) { printk("cpu offset : %016lx\n", __my_cpu_offset()); printk("pc : %pS\n", (void *)regs->pc); printk("lr : %pS\n", (void *)ptrauth_strip_insn_pac(lr)); ... } ... or in a separate block which checks the same condition. Thanks, Mark. > + > if (!user_mode(regs)) { > printk("pc : %pS\n", (void *)regs->pc); > printk("lr : %pS\n", (void *)ptrauth_strip_insn_pac(lr)); > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel