* [PATCH v2 0/3] Add support for divde[.] and divdeu[.] instruction emulation
@ 2020-01-13 5:41 Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes Balamuruhan S
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Balamuruhan S @ 2020-01-13 5:41 UTC (permalink / raw)
To: mpe
Cc: ravi.bangoria, Balamuruhan S, paulus, sandipan, naveen.n.rao,
linuxppc-dev
Hi All,
This patchset adds support to emulate divde, divde., divdeu and divdeu.
instructions and testcases for it.
Changes in v2:
-------------
* Fix review comments from Paul to make divde_dot and divdeu_dot simple
by using divde and divdeu, then goto `arith_done` instead of
`compute_done`.
* Include `Reviewed-by` tag from Sandipan Das.
* Rebase with recent mpe's merge tree.
I would request for your review and suggestions for making it better.
Boot Log:
--------
:: ::
:: ::
[ 2.777518] emulate_step_test: divde : RA = LONG_MIN, RB = LONG_MIN PASS
[ 2.777882] emulate_step_test: divde : RA = 1L, RB = 0 PASS
[ 2.778432] emulate_step_test: divde : RA = LONG_MIN, RB = LONG_MAX PASS
[ 2.778880] emulate_step_test: divde. : RA = LONG_MIN, RB = LONG_MIN PASS
[ 2.780172] emulate_step_test: divde. : RA = 1L, RB = 0 PASS
[ 2.780582] emulate_step_test: divde. : RA = LONG_MIN, RB = LONG_MAX PASS
[ 2.780983] emulate_step_test: divdeu : RA = LONG_MIN, RB = LONG_MIN PASS
[ 2.781276] emulate_step_test: divdeu : RA = 1L, RB = 0 PASS
[ 2.781579] emulate_step_test: divdeu : RA = LONG_MIN, RB = LONG_MAX PASS
[ 2.781820] emulate_step_test: divdeu : RA = LONG_MAX - 1, RB = LONG_MAX PASS
[ 2.782056] emulate_step_test: divdeu : RA = LONG_MIN + 1, RB = LONG_MIN PASS
[ 2.782296] emulate_step_test: divdeu. : RA = LONG_MIN, RB = LONG_MIN PASS
[ 2.782556] emulate_step_test: divdeu. : RA = 1L, RB = 0 PASS
[ 2.783502] emulate_step_test: divdeu. : RA = LONG_MIN, RB = LONG_MAX PASS
[ 2.783748] emulate_step_test: divdeu. : RA = LONG_MAX - 1, RB = LONG_MAX PASS
[ 2.783973] emulate_step_test: divdeu. : RA = LONG_MIN + 1, RB = LONG_MIN PASS
[ 2.789617] registered taskstats version 1
[ 2.794779] printk: console [netcon0] enabled
[ 2.794931] netconsole: network logging started
[ 2.795327] hctosys: unable to open rtc device (rtc0)
[ 2.953449] Freeing unused kernel memory: 5120K
[ 2.953639] This architecture does not have kernel memory protection.
[ 2.953918] Run /init as init process
[ 3.173573] mount (54) used greatest stack depth: 12576 bytes left
[ 3.252465] mount (55) used greatest stack depth: 12544 bytes left
Welcome to Buildroot
buildroot login:
Balamuruhan S (3):
powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot
opcodes
powerpc sstep: add support for divde[.] and divdeu[.] instructions
powerpc test_emulate_step: add testcases for divde[.] and divdeu[.]
instructions
arch/powerpc/include/asm/ppc-opcode.h | 10 +++
arch/powerpc/lib/sstep.c | 13 ++-
arch/powerpc/lib/test_emulate_step.c | 164 ++++++++++++++++++++++++++++++++++
3 files changed, 186 insertions(+), 1 deletion(-)
base-commit: 20862247a368dbb75d6e97d82345999adaacf3cc
--
2.14.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes
2020-01-13 5:41 [PATCH v2 0/3] Add support for divde[.] and divdeu[.] instruction emulation Balamuruhan S
@ 2020-01-13 5:41 ` Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 3/3] powerpc test_emulate_step: add testcases " Balamuruhan S
2 siblings, 0 replies; 4+ messages in thread
From: Balamuruhan S @ 2020-01-13 5:41 UTC (permalink / raw)
To: mpe
Cc: ravi.bangoria, Balamuruhan S, paulus, sandipan, naveen.n.rao,
linuxppc-dev
include instruction opcodes for divde, divde_dot, divideu and
divideu_dot as macros.
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
---
arch/powerpc/include/asm/ppc-opcode.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index c1df75edde44..0acd01afd5b7 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -339,6 +339,10 @@
#define PPC_INST_DIVWU 0x7c000396
#define PPC_INST_DIVD 0x7c0003d2
#define PPC_INST_DIVDU 0x7c000392
+#define PPC_INST_DIVDE 0x7c000352
+#define PPC_INST_DIVDE_DOT 0x7c000353
+#define PPC_INST_DIVDEU 0x7c000312
+#define PPC_INST_DIVDEU_DOT 0x7c000313
#define PPC_INST_RLWINM 0x54000000
#define PPC_INST_RLWINM_DOT 0x54000001
#define PPC_INST_RLWIMI 0x50000000
@@ -439,6 +443,12 @@
__PPC_RA(a) | __PPC_RB(b))
#define PPC_DCBZL(a, b) stringify_in_c(.long PPC_INST_DCBZL | \
__PPC_RA(a) | __PPC_RB(b))
+#define PPC_DIVDE(t, a, b) stringify_in_c(.long PPC_INST_DIVDE | \
+ ___PPC_RT(t) | ___PPC_RA(a) | \
+ ___PPC_RB(b))
+#define PPC_DIVDEU(t, a, b) stringify_in_c(.long PPC_INST_DIVDEU | \
+ ___PPC_RT(t) | ___PPC_RA(a) | \
+ ___PPC_RB(b))
#define PPC_LQARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LQARX | \
___PPC_RT(t) | ___PPC_RA(a) | \
___PPC_RB(b) | __PPC_EH(eh))
--
2.14.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions
2020-01-13 5:41 [PATCH v2 0/3] Add support for divde[.] and divdeu[.] instruction emulation Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes Balamuruhan S
@ 2020-01-13 5:41 ` Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 3/3] powerpc test_emulate_step: add testcases " Balamuruhan S
2 siblings, 0 replies; 4+ messages in thread
From: Balamuruhan S @ 2020-01-13 5:41 UTC (permalink / raw)
To: mpe
Cc: ravi.bangoria, Balamuruhan S, paulus, sandipan, naveen.n.rao,
linuxppc-dev
This patch adds emulation support for divde, divdeu instructions,
* Divide Doubleword Extended (divde[.])
* Divide Doubleword Extended Unsigned (divdeu[.])
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index c077acb983a1..2cac71a71878 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1736,7 +1736,18 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
op->val = (int) regs->gpr[ra] /
(int) regs->gpr[rb];
goto arith_done;
-
+#ifdef __powerpc64__
+ case 425: /* divde[.] */
+ asm volatile(PPC_DIVDE(%0, %1, %2) :
+ "=r" (op->val) : "r" (regs->gpr[ra]),
+ "r" (regs->gpr[rb]));
+ goto arith_done;
+ case 393: /* divdeu[.] */
+ asm volatile(PPC_DIVDEU(%0, %1, %2) :
+ "=r" (op->val) : "r" (regs->gpr[ra]),
+ "r" (regs->gpr[rb]));
+ goto arith_done;
+#endif
case 755: /* darn */
if (!cpu_has_feature(CPU_FTR_ARCH_300))
return -1;
--
2.14.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] powerpc test_emulate_step: add testcases for divde[.] and divdeu[.] instructions
2020-01-13 5:41 [PATCH v2 0/3] Add support for divde[.] and divdeu[.] instruction emulation Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions Balamuruhan S
@ 2020-01-13 5:41 ` Balamuruhan S
2 siblings, 0 replies; 4+ messages in thread
From: Balamuruhan S @ 2020-01-13 5:41 UTC (permalink / raw)
To: mpe
Cc: ravi.bangoria, Balamuruhan S, paulus, sandipan, naveen.n.rao,
linuxppc-dev
add testcases for divde, divde., divdeu, divdeu. emulated
instructions to cover few scenarios,
* with same dividend and divisor to have undefine RT
for divdeu[.]
* with divide by zero to have undefine RT for both
divde[.] and divdeu[.]
* with negative dividend to cover -|divisor| < r <= 0 if
the dividend is negative for divde[.]
* normal case with proper dividend and divisor for both
divde[.] and divdeu[.]
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
---
arch/powerpc/lib/test_emulate_step.c | 164 +++++++++++++++++++++++++++++++++++
1 file changed, 164 insertions(+)
diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
index 42347067739c..552b62a70e55 100644
--- a/arch/powerpc/lib/test_emulate_step.c
+++ b/arch/powerpc/lib/test_emulate_step.c
@@ -53,6 +53,14 @@
___PPC_RA(a) | ___PPC_RB(b))
#define TEST_ADDC_DOT(t, a, b) (PPC_INST_ADDC | ___PPC_RT(t) | \
___PPC_RA(a) | ___PPC_RB(b) | 0x1)
+#define TEST_DIVDE(t, a, b) (PPC_INST_DIVDE | ___PPC_RT(t) | \
+ ___PPC_RA(a) | ___PPC_RB(b))
+#define TEST_DIVDE_DOT(t, a, b) (PPC_INST_DIVDE_DOT | ___PPC_RT(t) | \
+ ___PPC_RA(a) | ___PPC_RB(b))
+#define TEST_DIVDEU(t, a, b) (PPC_INST_DIVDEU | ___PPC_RT(t) | \
+ ___PPC_RA(a) | ___PPC_RB(b))
+#define TEST_DIVDEU_DOT(t, a, b)(PPC_INST_DIVDEU_DOT | ___PPC_RT(t) | \
+ ___PPC_RA(a) | ___PPC_RB(b))
#define MAX_SUBTESTS 16
@@ -837,6 +845,162 @@ static struct compute_test compute_tests[] = {
}
}
}
+ },
+ {
+ .mnemonic = "divde",
+ .subtests = {
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MIN",
+ .instr = TEST_DIVDE(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MIN,
+ }
+ },
+ {
+ .descr = "RA = 1L, RB = 0",
+ .instr = TEST_DIVDE(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = 1L,
+ .gpr[22] = 0,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MAX",
+ .instr = TEST_DIVDE(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MAX,
+ }
+ }
+ }
+ },
+ {
+ .mnemonic = "divde.",
+ .subtests = {
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MIN",
+ .instr = TEST_DIVDE_DOT(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MIN,
+ }
+ },
+ {
+ .descr = "RA = 1L, RB = 0",
+ .instr = TEST_DIVDE_DOT(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = 1L,
+ .gpr[22] = 0,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MAX",
+ .instr = TEST_DIVDE_DOT(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MAX,
+ }
+ }
+ }
+ },
+ {
+ .mnemonic = "divdeu",
+ .subtests = {
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MIN",
+ .instr = TEST_DIVDEU(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MIN,
+ }
+ },
+ {
+ .descr = "RA = 1L, RB = 0",
+ .instr = TEST_DIVDEU(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = 1L,
+ .gpr[22] = 0,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MAX",
+ .instr = TEST_DIVDEU(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MAX,
+ }
+ },
+ {
+ .descr = "RA = LONG_MAX - 1, RB = LONG_MAX",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MAX - 1,
+ .gpr[22] = LONG_MAX,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN + 1, RB = LONG_MIN",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = LONG_MIN + 1,
+ .gpr[22] = LONG_MIN,
+ }
+ }
+ }
+ },
+ {
+ .mnemonic = "divdeu.",
+ .subtests = {
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MIN",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MIN,
+ }
+ },
+ {
+ .descr = "RA = 1L, RB = 0",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = 1L,
+ .gpr[22] = 0,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN, RB = LONG_MAX",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MIN,
+ .gpr[22] = LONG_MAX,
+ }
+ },
+ {
+ .descr = "RA = LONG_MAX - 1, RB = LONG_MAX",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .regs = {
+ .gpr[21] = LONG_MAX - 1,
+ .gpr[22] = LONG_MAX,
+ }
+ },
+ {
+ .descr = "RA = LONG_MIN + 1, RB = LONG_MIN",
+ .instr = TEST_DIVDEU_DOT(20, 21, 22),
+ .flags = IGNORE_GPR(20),
+ .regs = {
+ .gpr[21] = LONG_MIN + 1,
+ .gpr[22] = LONG_MIN,
+ }
+ }
+ }
}
};
--
2.14.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-13 5:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 5:41 [PATCH v2 0/3] Add support for divde[.] and divdeu[.] instruction emulation Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions Balamuruhan S
2020-01-13 5:41 ` [PATCH v2 3/3] powerpc test_emulate_step: add testcases " Balamuruhan S
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.