From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [PATCH v2 3/4] powerpc: Fix instruction dumping to use address value correctly
Date: Sun, 24 May 2020 15:08:21 +0530 [thread overview]
Message-ID: <20200524093822.423487-3-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20200524093822.423487-1-aneesh.kumar@linux.ibm.com>
Use ___va() to convert the real address that will skip the input
validation. We can get interrupts with IR=0 and with NIP value > PAGE_OFFSET.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/processor.h | 9 +++++++++
arch/powerpc/kernel/process.c | 7 ++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 4e53df163b92..8bf7921dceca 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -441,6 +441,15 @@ extern void cvt_fd(float *from, double *to);
extern void cvt_df(double *from, float *to);
extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
+static inline unsigned long fixup_real_addr(struct pt_regs *regs,
+ unsigned long addr)
+{
+ if (!(regs->msr & MSR_IR))
+ return (unsigned long)___va(addr);
+
+ return addr;
+}
+
#ifdef CONFIG_PPC64
/*
* We handle most unaligned accesses in hardware. On the other hand
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 93bf4a766707..de07b796222d 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1262,12 +1262,9 @@ static void show_instructions(struct pt_regs *regs)
/* If executing with the IMMU off, adjust pc rather
* than print XXXXXXXX.
*/
- if (!(regs->msr & MSR_IR)) {
- pc = (unsigned long)phys_to_virt(pc);
- nip = (unsigned long)phys_to_virt(regs->nip);
- }
+ pc = fixup_real_addr(regs, pc);
+ nip = fixup_real_addr(regs, nip);
#endif
-
for (i = 0; i < NR_INSN_TO_PRINT; i++) {
int instr;
--
2.26.2
next prev parent reply other threads:[~2020-05-24 9:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-24 9:38 [PATCH v2 1/4] powerpc/instruction_dump: Fix kernel crash with show_instructions Aneesh Kumar K.V
2020-05-24 9:38 ` [PATCH v2 2/4] powerpc/va: Add a __va() variant that doesn't do input validation Aneesh Kumar K.V
2020-05-24 9:38 ` Aneesh Kumar K.V [this message]
2020-05-24 9:38 ` [PATCH v2 4/4] powerpc: Avoid opencoding fixup_real_addr Aneesh Kumar K.V
2020-06-18 12:37 ` [PATCH v2 1/4] powerpc/instruction_dump: Fix kernel crash with show_instructions Michael Ellerman
2022-03-09 17:25 ` Christophe Leroy
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=20200524093822.423487-3-aneesh.kumar@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.