* [PATCH 1/3] powerpc/probes: Remove ppc_opcode_t
@ 2022-07-07 14:55 ` Christophe Leroy
0 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
ppc_opcode_t is just an u32. There is no point in hiding u32
behind such a typedef. Remove it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/kprobes.h | 2 +-
arch/powerpc/include/asm/probes.h | 1 -
arch/powerpc/include/asm/uprobes.h | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h
index bab364152b29..c8e4b4fd4e33 100644
--- a/arch/powerpc/include/asm/kprobes.h
+++ b/arch/powerpc/include/asm/kprobes.h
@@ -29,7 +29,7 @@
struct pt_regs;
struct kprobe;
-typedef ppc_opcode_t kprobe_opcode_t;
+typedef u32 kprobe_opcode_t;
extern kprobe_opcode_t optinsn_slot;
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 6f66e358aa37..00634e3145e7 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -10,7 +10,6 @@
#include <linux/types.h>
#include <asm/disassemble.h>
-typedef u32 ppc_opcode_t;
#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
/* Trap definitions per ISA */
diff --git a/arch/powerpc/include/asm/uprobes.h b/arch/powerpc/include/asm/uprobes.h
index a7ae1860115a..4fea116d3d37 100644
--- a/arch/powerpc/include/asm/uprobes.h
+++ b/arch/powerpc/include/asm/uprobes.h
@@ -12,7 +12,7 @@
#include <linux/notifier.h>
#include <asm/probes.h>
-typedef ppc_opcode_t uprobe_opcode_t;
+typedef u32 uprobe_opcode_t;
#define MAX_UINSN_BYTES 8
#define UPROBE_XOL_SLOT_BYTES (MAX_UINSN_BYTES)
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 1/3] powerpc/probes: Remove ppc_opcode_t
@ 2022-07-07 14:55 ` Christophe Leroy
0 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
ppc_opcode_t is just an u32. There is no point in hiding u32
behind such a typedef. Remove it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/kprobes.h | 2 +-
arch/powerpc/include/asm/probes.h | 1 -
arch/powerpc/include/asm/uprobes.h | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h
index bab364152b29..c8e4b4fd4e33 100644
--- a/arch/powerpc/include/asm/kprobes.h
+++ b/arch/powerpc/include/asm/kprobes.h
@@ -29,7 +29,7 @@
struct pt_regs;
struct kprobe;
-typedef ppc_opcode_t kprobe_opcode_t;
+typedef u32 kprobe_opcode_t;
extern kprobe_opcode_t optinsn_slot;
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 6f66e358aa37..00634e3145e7 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -10,7 +10,6 @@
#include <linux/types.h>
#include <asm/disassemble.h>
-typedef u32 ppc_opcode_t;
#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
/* Trap definitions per ISA */
diff --git a/arch/powerpc/include/asm/uprobes.h b/arch/powerpc/include/asm/uprobes.h
index a7ae1860115a..4fea116d3d37 100644
--- a/arch/powerpc/include/asm/uprobes.h
+++ b/arch/powerpc/include/asm/uprobes.h
@@ -12,7 +12,7 @@
#include <linux/notifier.h>
#include <asm/probes.h>
-typedef ppc_opcode_t uprobe_opcode_t;
+typedef u32 uprobe_opcode_t;
#define MAX_UINSN_BYTES 8
#define UPROBE_XOL_SLOT_BYTES (MAX_UINSN_BYTES)
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
2022-07-07 14:55 ` Christophe Leroy
@ 2022-07-07 14:55 ` Christophe Leroy
-1 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
Add and use PPC_RAW_TRAP() instead of opencoding.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/ppc-opcode.h | 2 ++
arch/powerpc/include/asm/probes.h | 3 ++-
arch/powerpc/xmon/xmon.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 89beabf5325c..5527a955fb4a 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -581,6 +581,8 @@
#define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
#define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
+#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
+#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
/* Deal with instructions that older assemblers aren't aware of */
#define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 00634e3145e7..e77a2ed7d938 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -9,8 +9,9 @@
*/
#include <linux/types.h>
#include <asm/disassemble.h>
+#include <asm/ppc-opcode.h>
-#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
+#define BREAKPOINT_INSTRUCTION PPC_RAW_TRAP() /* trap */
/* Trap definitions per ISA */
#define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index f80c714f1d49..26ef3388c24c 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -116,7 +116,7 @@ struct bpt {
static struct bpt bpts[NBPTS];
static struct bpt dabr[HBP_NUM_MAX];
static struct bpt *iabr;
-static unsigned bpinstr = 0x7fe00008; /* trap */
+static unsigned int bpinstr = PPC_RAW_TRAP();
#define BP_NUM(bp) ((bp) - bpts + 1)
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
@ 2022-07-07 14:55 ` Christophe Leroy
0 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
Add and use PPC_RAW_TRAP() instead of opencoding.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/ppc-opcode.h | 2 ++
arch/powerpc/include/asm/probes.h | 3 ++-
arch/powerpc/xmon/xmon.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 89beabf5325c..5527a955fb4a 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -581,6 +581,8 @@
#define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
#define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
+#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
+#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
/* Deal with instructions that older assemblers aren't aware of */
#define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 00634e3145e7..e77a2ed7d938 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -9,8 +9,9 @@
*/
#include <linux/types.h>
#include <asm/disassemble.h>
+#include <asm/ppc-opcode.h>
-#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
+#define BREAKPOINT_INSTRUCTION PPC_RAW_TRAP() /* trap */
/* Trap definitions per ISA */
#define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index f80c714f1d49..26ef3388c24c 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -116,7 +116,7 @@ struct bpt {
static struct bpt bpts[NBPTS];
static struct bpt dabr[HBP_NUM_MAX];
static struct bpt *iabr;
-static unsigned bpinstr = 0x7fe00008; /* trap */
+static unsigned int bpinstr = PPC_RAW_TRAP();
#define BP_NUM(bp) ((bp) - bpts + 1)
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] powerpc/ppc-opcode: Define and use PPC_RAW_SETB()
2022-07-07 14:55 ` Christophe Leroy
@ 2022-07-07 14:55 ` Christophe Leroy
-1 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
We have PPC_INST_SETB then build the 'setb' instruction in the
user.
Instead, define PPC_RAW_SETB() and use it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/ppc-opcode.h | 2 +-
arch/powerpc/lib/test_emulate_step.c | 9 +++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 5527a955fb4a..7b81b37a191e 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -290,7 +290,6 @@
#define PPC_INST_STRING 0x7c00042a
#define PPC_INST_STRING_MASK 0xfc0007fe
#define PPC_INST_STRING_GEN_MASK 0xfc00067e
-#define PPC_INST_SETB 0x7c000100
#define PPC_INST_STSWI 0x7c0005aa
#define PPC_INST_STSWX 0x7c00052a
#define PPC_INST_TRECHKPT 0x7c0007dd
@@ -583,6 +582,7 @@
#define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
+#define PPC_RAW_SETB(t, bfa) (0x7c000100 | ___PPC_RT(t) | ___PPC_RA((bfa) << 2))
/* Deal with instructions that older assemblers aren't aware of */
#define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
index f2e47be05e8c..23c7805fb7b3 100644
--- a/arch/powerpc/lib/test_emulate_step.c
+++ b/arch/powerpc/lib/test_emulate_step.c
@@ -53,9 +53,6 @@
ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
PPC_RAW_ADDI(t, a, i))
-#define TEST_SETB(t, bfa) ppc_inst(PPC_INST_SETB | ___PPC_RT(t) | ___PPC_RA((bfa & 0x7) << 2))
-
-
static void __init init_pt_regs(struct pt_regs *regs)
{
static unsigned long msr;
@@ -935,21 +932,21 @@ static struct compute_test compute_tests[] = {
.subtests = {
{
.descr = "BFA = 1, CR = GT",
- .instr = TEST_SETB(20, 1),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 1)),
.regs = {
.ccr = 0x4000000,
}
},
{
.descr = "BFA = 4, CR = LT",
- .instr = TEST_SETB(20, 4),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 4)),
.regs = {
.ccr = 0x8000,
}
},
{
.descr = "BFA = 5, CR = EQ",
- .instr = TEST_SETB(20, 5),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 5)),
.regs = {
.ccr = 0x200,
}
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] powerpc/ppc-opcode: Define and use PPC_RAW_SETB()
@ 2022-07-07 14:55 ` Christophe Leroy
0 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2022-07-07 14:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
We have PPC_INST_SETB then build the 'setb' instruction in the
user.
Instead, define PPC_RAW_SETB() and use it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/ppc-opcode.h | 2 +-
arch/powerpc/lib/test_emulate_step.c | 9 +++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 5527a955fb4a..7b81b37a191e 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -290,7 +290,6 @@
#define PPC_INST_STRING 0x7c00042a
#define PPC_INST_STRING_MASK 0xfc0007fe
#define PPC_INST_STRING_GEN_MASK 0xfc00067e
-#define PPC_INST_SETB 0x7c000100
#define PPC_INST_STSWI 0x7c0005aa
#define PPC_INST_STSWX 0x7c00052a
#define PPC_INST_TRECHKPT 0x7c0007dd
@@ -583,6 +582,7 @@
#define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
+#define PPC_RAW_SETB(t, bfa) (0x7c000100 | ___PPC_RT(t) | ___PPC_RA((bfa) << 2))
/* Deal with instructions that older assemblers aren't aware of */
#define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
index f2e47be05e8c..23c7805fb7b3 100644
--- a/arch/powerpc/lib/test_emulate_step.c
+++ b/arch/powerpc/lib/test_emulate_step.c
@@ -53,9 +53,6 @@
ppc_inst_prefix(PPC_PREFIX_MLS | __PPC_PRFX_R(pr) | IMM_H(i), \
PPC_RAW_ADDI(t, a, i))
-#define TEST_SETB(t, bfa) ppc_inst(PPC_INST_SETB | ___PPC_RT(t) | ___PPC_RA((bfa & 0x7) << 2))
-
-
static void __init init_pt_regs(struct pt_regs *regs)
{
static unsigned long msr;
@@ -935,21 +932,21 @@ static struct compute_test compute_tests[] = {
.subtests = {
{
.descr = "BFA = 1, CR = GT",
- .instr = TEST_SETB(20, 1),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 1)),
.regs = {
.ccr = 0x4000000,
}
},
{
.descr = "BFA = 4, CR = LT",
- .instr = TEST_SETB(20, 4),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 4)),
.regs = {
.ccr = 0x8000,
}
},
{
.descr = "BFA = 5, CR = EQ",
- .instr = TEST_SETB(20, 5),
+ .instr = ppc_inst(PPC_RAW_SETB(20, 5)),
.regs = {
.ccr = 0x200,
}
--
2.36.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] powerpc/probes: Remove ppc_opcode_t
2022-07-07 14:55 ` Christophe Leroy
` (2 preceding siblings ...)
(?)
@ 2022-07-29 13:02 ` Michael Ellerman
-1 siblings, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2022-07-29 13:02 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
Cc: linuxppc-dev, linux-kernel
On Thu, 7 Jul 2022 16:55:14 +0200, Christophe Leroy wrote:
> ppc_opcode_t is just an u32. There is no point in hiding u32
> behind such a typedef. Remove it.
>
>
Applied to powerpc/next.
[1/3] powerpc/probes: Remove ppc_opcode_t
https://git.kernel.org/powerpc/c/7b48377e1d9f68a1b58dfd22d40b083f38ce76a0
[2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
https://git.kernel.org/powerpc/c/d00d762daf1278641eec92d74011a7e625e84a68
[3/3] powerpc/ppc-opcode: Define and use PPC_RAW_SETB()
https://git.kernel.org/powerpc/c/de40303b54bc458d7df0d4b4ee1d296df7fe98c7
cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
2022-07-07 14:55 ` Christophe Leroy
@ 2022-08-03 8:06 ` Naveen N. Rao
-1 siblings, 0 replies; 11+ messages in thread
From: Naveen N. Rao @ 2022-08-03 8:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
Paul Mackerras
Cc: linux-kernel, linuxppc-dev
Christophe Leroy wrote:
> Add and use PPC_RAW_TRAP() instead of opencoding.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> arch/powerpc/include/asm/ppc-opcode.h | 2 ++
> arch/powerpc/include/asm/probes.h | 3 ++-
> arch/powerpc/xmon/xmon.c | 2 +-
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
> index 89beabf5325c..5527a955fb4a 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -581,6 +581,8 @@
>
> #define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
> #define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
> +#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
Shouldn't that be 0x7c000008 ?
- Naveen
> +#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
>
> /* Deal with instructions that older assemblers aren't aware of */
> #define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
> diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
> index 00634e3145e7..e77a2ed7d938 100644
> --- a/arch/powerpc/include/asm/probes.h
> +++ b/arch/powerpc/include/asm/probes.h
> @@ -9,8 +9,9 @@
> */
> #include <linux/types.h>
> #include <asm/disassemble.h>
> +#include <asm/ppc-opcode.h>
>
> -#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
> +#define BREAKPOINT_INSTRUCTION PPC_RAW_TRAP() /* trap */
>
> /* Trap definitions per ISA */
> #define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index f80c714f1d49..26ef3388c24c 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -116,7 +116,7 @@ struct bpt {
> static struct bpt bpts[NBPTS];
> static struct bpt dabr[HBP_NUM_MAX];
> static struct bpt *iabr;
> -static unsigned bpinstr = 0x7fe00008; /* trap */
> +static unsigned int bpinstr = PPC_RAW_TRAP();
>
> #define BP_NUM(bp) ((bp) - bpts + 1)
>
> --
> 2.36.1
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
@ 2022-08-03 8:06 ` Naveen N. Rao
0 siblings, 0 replies; 11+ messages in thread
From: Naveen N. Rao @ 2022-08-03 8:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
Paul Mackerras
Cc: linuxppc-dev, linux-kernel
Christophe Leroy wrote:
> Add and use PPC_RAW_TRAP() instead of opencoding.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> arch/powerpc/include/asm/ppc-opcode.h | 2 ++
> arch/powerpc/include/asm/probes.h | 3 ++-
> arch/powerpc/xmon/xmon.c | 2 +-
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
> index 89beabf5325c..5527a955fb4a 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -581,6 +581,8 @@
>
> #define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
> #define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
> +#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
Shouldn't that be 0x7c000008 ?
- Naveen
> +#define PPC_RAW_TRAP() PPC_RAW_TW(31, 0, 0)
>
> /* Deal with instructions that older assemblers aren't aware of */
> #define PPC_BCCTR_FLUSH stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
> diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
> index 00634e3145e7..e77a2ed7d938 100644
> --- a/arch/powerpc/include/asm/probes.h
> +++ b/arch/powerpc/include/asm/probes.h
> @@ -9,8 +9,9 @@
> */
> #include <linux/types.h>
> #include <asm/disassemble.h>
> +#include <asm/ppc-opcode.h>
>
> -#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
> +#define BREAKPOINT_INSTRUCTION PPC_RAW_TRAP() /* trap */
>
> /* Trap definitions per ISA */
> #define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index f80c714f1d49..26ef3388c24c 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -116,7 +116,7 @@ struct bpt {
> static struct bpt bpts[NBPTS];
> static struct bpt dabr[HBP_NUM_MAX];
> static struct bpt *iabr;
> -static unsigned bpinstr = 0x7fe00008; /* trap */
> +static unsigned int bpinstr = PPC_RAW_TRAP();
>
> #define BP_NUM(bp) ((bp) - bpts + 1)
>
> --
> 2.36.1
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
2022-08-03 8:06 ` Naveen N. Rao
@ 2022-08-03 10:38 ` Michael Ellerman
-1 siblings, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2022-08-03 10:38 UTC (permalink / raw)
To: Naveen N. Rao, Benjamin Herrenschmidt, Christophe Leroy, Paul Mackerras
Cc: linux-kernel, linuxppc-dev
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com> writes:
> Christophe Leroy wrote:
>> Add and use PPC_RAW_TRAP() instead of opencoding.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> arch/powerpc/include/asm/ppc-opcode.h | 2 ++
>> arch/powerpc/include/asm/probes.h | 3 ++-
>> arch/powerpc/xmon/xmon.c | 2 +-
>> 3 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
>> index 89beabf5325c..5527a955fb4a 100644
>> --- a/arch/powerpc/include/asm/ppc-opcode.h
>> +++ b/arch/powerpc/include/asm/ppc-opcode.h
>> @@ -581,6 +581,8 @@
>>
>> #define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
>> #define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
>> +#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
>
> Shouldn't that be 0x7c000008 ?
Yes, my script agrees.
https://github.com/mpe/misc-scripts/blob/master/ppc/ppc-instruction-encode
$ ./ppc-instruction-encode 0:31 6:t0 11:ra 16:rb 21:4 31:
.long 0x7c000008
t0 << 21
ra << 16
rb << 11
I guess the only user is PPC_RAW_TRAP() which passes t0 = 31, so that's
why nothing has broken.
Send a fixup? :)
cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW()
@ 2022-08-03 10:38 ` Michael Ellerman
0 siblings, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2022-08-03 10:38 UTC (permalink / raw)
To: Naveen N. Rao, Benjamin Herrenschmidt, Christophe Leroy, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com> writes:
> Christophe Leroy wrote:
>> Add and use PPC_RAW_TRAP() instead of opencoding.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> arch/powerpc/include/asm/ppc-opcode.h | 2 ++
>> arch/powerpc/include/asm/probes.h | 3 ++-
>> arch/powerpc/xmon/xmon.c | 2 +-
>> 3 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
>> index 89beabf5325c..5527a955fb4a 100644
>> --- a/arch/powerpc/include/asm/ppc-opcode.h
>> +++ b/arch/powerpc/include/asm/ppc-opcode.h
>> @@ -581,6 +581,8 @@
>>
>> #define PPC_RAW_BRANCH(offset) (0x48000000 | PPC_LI(offset))
>> #define PPC_RAW_BL(offset) (0x48000001 | PPC_LI(offset))
>> +#define PPC_RAW_TW(t0, a, b) (0x7f000008 | ___PPC_RS(t0) | ___PPC_RA(a) | ___PPC_RB(b))
>
> Shouldn't that be 0x7c000008 ?
Yes, my script agrees.
https://github.com/mpe/misc-scripts/blob/master/ppc/ppc-instruction-encode
$ ./ppc-instruction-encode 0:31 6:t0 11:ra 16:rb 21:4 31:
.long 0x7c000008
t0 << 21
ra << 16
rb << 11
I guess the only user is PPC_RAW_TRAP() which passes t0 = 31, so that's
why nothing has broken.
Send a fixup? :)
cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-08-03 10:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 14:55 [PATCH 1/3] powerpc/probes: Remove ppc_opcode_t Christophe Leroy
2022-07-07 14:55 ` Christophe Leroy
2022-07-07 14:55 ` [PATCH 2/3] powerpc/ppc-opcode: Define and use PPC_RAW_TRAP() and PPC_RAW_TW() Christophe Leroy
2022-07-07 14:55 ` Christophe Leroy
2022-08-03 8:06 ` Naveen N. Rao
2022-08-03 8:06 ` Naveen N. Rao
2022-08-03 10:38 ` Michael Ellerman
2022-08-03 10:38 ` Michael Ellerman
2022-07-07 14:55 ` [PATCH 3/3] powerpc/ppc-opcode: Define and use PPC_RAW_SETB() Christophe Leroy
2022-07-07 14:55 ` Christophe Leroy
2022-07-29 13:02 ` [PATCH 1/3] powerpc/probes: Remove ppc_opcode_t Michael Ellerman
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.