Skip to contentSkip to conversation

RISC-V: probes: Treat the instruction stream as host-endian

PATCH In review Palmer Dabbelt 2 participants 2 messages Jan 23, 2021 RISC-V

lore
Share & tools
lore

Palmer Dabbelt

author maintainer
#0 lore raw

PATCH 1/1 RISC-V: probes: Treat the instruction stream as host-endian

From: Palmer Dabbelt <[email protected]>

Neither of these are actually correct: the instruction stream is defined (for versions of the ISA manual newer than 2.2) as a stream of 16-bit little-endian parcels, which is different than just being little-endian. In theory we should represent this as a type, but we don't have any concrete plans for the big endian stuff so it doesn't seem worth the time -- we've got variants of this all over the place.

Instead I'm just dropping the unnecessary type conversion, which is a NOP on LE systems but causes an sparse error as the types are all mixed up.

---
 arch/riscv/kernel/probes/decode-insn.c | 2 +-
 arch/riscv/kernel/probes/kprobes.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/probes/decode-insn.c +1 -1
index 0876c304ca77..0ed043acc882 100644
@@ -16,7 +16,7 @@
 enum probe_insn __kprobes
 riscv_probe_decode_insn(probe_opcode_t *addr, struct arch_probe_insn *api)
 {
-	probe_opcode_t insn = le32_to_cpu(*addr);
+	probe_opcode_t insn = *addr;
 
 	/*
 	 * Reject instructions list:
arch/riscv/kernel/probes/kprobes.c +1 -1
index e60893bd87db..a2ec18662fee 100644
@@ -57,7 +57,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	}
 
 	/* copy instruction */
-	p->opcode = le32_to_cpu(*p->addr);
+	p->opcode = *p->addr;
 
 	/* decode instruction */
 	switch (riscv_probe_decode_insn(p->addr, &p->ainsn.api)) {
Signature · 7 lines
2.30.0.280.ga3ce27912f-goog


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Acked-by on v1 1/1
#1 lore raw
Quoted 38 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

Neither of these are actually correct: the instruction stream is defined (for versions of the ISA manual newer than 2.2) as a stream of 16-bit little-endian parcels, which is different than just being little-endian. In theory we should represent this as a type, but we don't have any concrete plans for the big endian stuff so it doesn't seem worth the time -- we've got variants of this all over the place.

Instead I'm just dropping the unnecessary type conversion, which is a NOP on LE systems but causes an sparse error as the types are all mixed up.

---
  arch/riscv/kernel/probes/decode-insn.c | 2 +-
  arch/riscv/kernel/probes/kprobes.c     | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/probes/decode-insn.c +1 -1
index 0876c304ca77..0ed043acc882 100644
@@ -16,7 +16,7 @@
  enum probe_insn __kprobes
  riscv_probe_decode_insn(probe_opcode_t *addr, struct arch_probe_insn *api)
  {
-	probe_opcode_t insn = le32_to_cpu(*addr);
+	probe_opcode_t insn = *addr;
 
  	/*
  	 * Reject instructions list:
arch/riscv/kernel/probes/kprobes.c +0 -0
index e60893bd87db..a2ec18662fee 100644

arch/riscv/kernel/probes/kprobes.c int __kprobes arch_prepare_kprobe(struct kprobe *p) · line 63

Quoted 8 lines
arch/riscv/kernel/probes/kprobes.c +1 -1
@@ -57,7 +57,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
  	}
 
  	/* copy instruction */
-	p->opcode = le32_to_cpu(*p->addr);
+	p->opcode = *p->addr;
 
  	/* decode instruction */
  	switch (riscv_probe_decode_insn(p->addr, &p->ainsn.api)) {

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv