From: Mark Rutland <mark.rutland@arm.com>
To: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
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()
Date: Thu, 5 May 2022 14:04:00 +0100 [thread overview]
Message-ID: <YnPLQJhu5B1Cxvoh@FVFF77S0Q05N.cambridge.arm.com> (raw)
In-Reply-To: <20220505095640.312-1-thunder.leizhen@huawei.com>
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 <thunder.leizhen@huawei.com>
> ---
> 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
next prev parent reply other threads:[~2022-05-05 13:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 9:56 [PATCH v3] arm64: add the printing of tpidr_elx in __show_regs() Zhen Lei
2022-05-05 10:51 ` Will Deacon
2022-05-05 13:04 ` Mark Rutland [this message]
2022-05-05 13:26 ` Leizhen (ThunderTown)
2022-05-05 13:34 ` Leizhen (ThunderTown)
2022-05-06 8:16 ` Leizhen (ThunderTown)
2022-05-06 10:09 ` Mark Rutland
2022-05-06 10:21 ` Leizhen (ThunderTown)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YnPLQJhu5B1Cxvoh@FVFF77S0Q05N.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox