From: Fredrik Noring <noring@nocrew.org>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
linux-mips@vger.kernel.org, "Andreas Jaeger" <aj@suse.de>,
"Nick Clifton" <nickc@redhat.com>,
"Jürgen Urban" <JuergenUrban@gmx.de>,
libc-help@sourceware.org
Subject: Re: [PATCH 002/120] MIPS: R5900: Trap the RDHWR instruction as an SQ address exception
Date: Sun, 13 Dec 2020 12:43:47 +0100 [thread overview]
Message-ID: <X9X+c6FNqH1pJSKf@sx9> (raw)
In-Reply-To: <alpine.LFD.2.21.2012121105280.2104409@eddie.linux-mips.org>
> So I think we can safely ignore them, just as we can any ULR access with
> rt != $3.
The comment is corrected and the conditions on rd and rt are now strict,
as shown in the patch below.
Fredrik
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 92bd2b0f0548..89ce42c60c6f 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -90,6 +90,7 @@
#include <asm/fpu_emulator.h>
#include <asm/inst.h>
#include <asm/mmu_context.h>
+#include <asm/traps.h>
#include <linux/uaccess.h>
#define STR(x) __STR(x)
@@ -934,7 +935,46 @@ static void emulate_load_store_insn(struct pt_regs *regs,
* interest.
*/
case spec3_op:
- if (insn.dsp_format.func == lx_op) {
+ if (IS_ENABLED(CONFIG_CPU_R5900)) {
+ /*
+ * On the R5900, a valid RDHWR instruction
+ *
+ * +--------+-------+----+----+-------+--------+
+ * | 011111 | 00000 | rt | rd | 00000 | 111011 |
+ * +--------+-------+----+----+-------+--------+
+ * 6 5 5 5 5 6
+ *
+ * having rt $3 (v1) and rd $29 (MIPS_HWR_ULR) is
+ * interpreted as the R5900 specific SQ instruction
+ *
+ * +--------+-------+----+---------------------+
+ * | 011111 | base | rt | offset |
+ * +--------+-------+----+---------------------+
+ * 6 5 5 16
+ *
+ * with
+ *
+ * sq v1,-6085(zero)
+ *
+ * that asserts an address exception since -6085(zero)
+ * always resolves to 0xffffe83b in 32-bit KSEG2.
+ *
+ * Other legacy values of rd, such as MIPS_HWR_CPUNUM,
+ * are ignored.
+ */
+ if (insn.r_format.func == rdhwr_op &&
+ insn.r_format.rd == MIPS_HWR_ULR &&
+ insn.r_format.rt == 3 &&
+ insn.r_format.rs == 0 &&
+ insn.r_format.re == 0) {
+ if (compute_return_epc(regs) < 0 ||
+ simulate_rdhwr(regs, insn.r_format.rd,
+ insn.r_format.rt) < 0)
+ goto sigill;
+ return;
+ }
+ goto sigbus;
+ } else if (insn.dsp_format.func == lx_op) {
switch (insn.dsp_format.op) {
case lwx_op:
if (!access_ok(addr, 4))
prev parent reply other threads:[~2020-12-13 11:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1567326213.git.noring@nocrew.org>
[not found] ` <4f856a5ea2c039c6639df875d11b5bff1bf7ecd2.1567326213.git.noring@nocrew.org>
2020-11-19 7:15 ` Philippe Mathieu-Daudé
2020-11-19 13:28 ` Maciej W. Rozycki
2020-11-19 13:42 ` Maciej W. Rozycki
2020-12-12 10:58 ` Fredrik Noring
2020-12-12 11:36 ` Maciej W. Rozycki
2020-12-12 12:14 ` Fredrik Noring
2020-12-13 11:43 ` Fredrik Noring [this message]
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=X9X+c6FNqH1pJSKf@sx9 \
--to=noring@nocrew.org \
--cc=JuergenUrban@gmx.de \
--cc=aj@suse.de \
--cc=f4bug@amsat.org \
--cc=libc-help@sourceware.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@linux-mips.org \
--cc=nickc@redhat.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).