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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C52D6C433F5 for ; Thu, 28 Apr 2022 10:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbiD1KZX (ORCPT ); Thu, 28 Apr 2022 06:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbiD1KZU (ORCPT ); Thu, 28 Apr 2022 06:25:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 802C61EEEF for ; Thu, 28 Apr 2022 03:22:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 38F0FB82C74 for ; Thu, 28 Apr 2022 10:22:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3FCC385A0; Thu, 28 Apr 2022 10:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651141321; bh=T43eOhfkYAIAzcaX7ZyWux1tIjqtySnRoASDc6wbkZQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F996I4S4t1o/qpGlQMeoCI18EdMkugEGUVE4eT4lWEJ31c7fc3fX6Kiux04EkDOli IzjnWkzVMb18Paq1hS2Z+LhwCupL6tBQkupyd9Sk7Q4ZkF4o/a/7LNfHyDuuEPJDmb 8pPTy2w84iMooyZdbzZGm4kszMKvplvocuDBWbkNflh5elHlKywCHKDh5WTRiWO8IJ 9mP4ogrY3YFd6N5SvbhvKeWCq8Xza9M8fvQHLAGu3PRtuzfN3PArKZMlZIVLz/yCi6 m6LhJtVZu+8MTDNhX5LLG19OFf2tnfhk4sf6ml2HBwLIWDKCjxidv62Xhsrw+mX7kv oXHMcAJ45SKFA== Date: Thu, 28 Apr 2022 11:21:56 +0100 From: Will Deacon To: Zhen Lei Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse Subject: Re: [PATCH v2] arm64: add the printing of tpidr_elx in __show_regs() Message-ID: <20220428102156.GA14123@willie-the-truck> References: <20220316062408.1113-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220316062408.1113-1-thunder.leizhen@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 16, 2022 at 02:24:08PM +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 | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > 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 5369e649fa79ff8..738932e6fa4e947 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -216,6 +216,17 @@ void __show_regs(struct pt_regs *regs) > show_regs_print_info(KERN_DEFAULT); > print_pstate(regs); > > + switch (read_sysreg(CurrentEL)) { This should use is_kernel_in_hyp_mode() to detect if we're running at El2. > + case CurrentEL_EL1: > + printk("tpidr_el1 : %016llx\n", read_sysreg(TPIDR_EL1)); > + break; > + case CurrentEL_EL2: > + printk("tpidr_el2 : %016llx\n", read_sysreg(TPIDR_EL2)); > + break; > + default: > + break; > + } I think this path can be triggered directly from usermode, so we really shouldn't be printing raw kernel virtual addresses here. Will 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 083EAC433FE for ; Thu, 28 Apr 2022 10:24:04 +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=fTkWt754QwCnC3Jh1rjHh+jhx30JAUWN30uNDFEjDEI=; b=WTlfzqxwbwItgt vVS5YU6K2QpTNu4lww/YX/eb8oetmQP4b0IIWiPU8FbnQQ6Yp37FjPQV+bQ8PaAWNfryg/JpsJZp5 IMPn7/sX8C+Au5Qccdv8+nPTwSS7JkQwKNszusyWXki2aSCzJis1cniLWoR8dr2Vh5rPRdAzd/322 5qLwjBZx1WRkULTb5KpDuf3I8XQJn78azjoDzh9i04G7FLjgeU0nA7qW9CKv0G7jhnbmBwroM31ce 0B4dJRkfrt7W7kCU4jNbMkg2NUDhA5aT39bxSjPp3B5LEAdnYBSRlcQg6kwcvZzq/0suEmN8YjES/ hxqVv2Uo3aYOctkh3/pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk1IW-0066Jx-77; Thu, 28 Apr 2022 10:22:57 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk1Hi-0065tA-Ni for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2022 10:22:08 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13AB6B82ADD; Thu, 28 Apr 2022 10:22:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3FCC385A0; Thu, 28 Apr 2022 10:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651141321; bh=T43eOhfkYAIAzcaX7ZyWux1tIjqtySnRoASDc6wbkZQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F996I4S4t1o/qpGlQMeoCI18EdMkugEGUVE4eT4lWEJ31c7fc3fX6Kiux04EkDOli IzjnWkzVMb18Paq1hS2Z+LhwCupL6tBQkupyd9Sk7Q4ZkF4o/a/7LNfHyDuuEPJDmb 8pPTy2w84iMooyZdbzZGm4kszMKvplvocuDBWbkNflh5elHlKywCHKDh5WTRiWO8IJ 9mP4ogrY3YFd6N5SvbhvKeWCq8Xza9M8fvQHLAGu3PRtuzfN3PArKZMlZIVLz/yCi6 m6LhJtVZu+8MTDNhX5LLG19OFf2tnfhk4sf6ml2HBwLIWDKCjxidv62Xhsrw+mX7kv oXHMcAJ45SKFA== Date: Thu, 28 Apr 2022 11:21:56 +0100 From: Will Deacon To: Zhen Lei Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse Subject: Re: [PATCH v2] arm64: add the printing of tpidr_elx in __show_regs() Message-ID: <20220428102156.GA14123@willie-the-truck> References: <20220316062408.1113-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220316062408.1113-1-thunder.leizhen@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220428_032207_161950_43A2A173 X-CRM114-Status: GOOD ( 19.17 ) 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 Wed, Mar 16, 2022 at 02:24:08PM +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 | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > 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 5369e649fa79ff8..738932e6fa4e947 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -216,6 +216,17 @@ void __show_regs(struct pt_regs *regs) > show_regs_print_info(KERN_DEFAULT); > print_pstate(regs); > > + switch (read_sysreg(CurrentEL)) { This should use is_kernel_in_hyp_mode() to detect if we're running at El2. > + case CurrentEL_EL1: > + printk("tpidr_el1 : %016llx\n", read_sysreg(TPIDR_EL1)); > + break; > + case CurrentEL_EL2: > + printk("tpidr_el2 : %016llx\n", read_sysreg(TPIDR_EL2)); > + break; > + default: > + break; > + } I think this path can be triggered directly from usermode, so we really shouldn't be printing raw kernel virtual addresses here. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel