Skip to contentSkip to conversation

riscv: provide riscv-specific is_trap_insn()

PATCH Superseded Nam Cao 5 participants 14 messages Aug 27, 2023 – Aug 31, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nam Cao

author
#0 lore raw

PATCH 1/1 riscv: provide riscv-specific is_trap_insn()

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

Fixes 74784081aac8 ("riscv: Add uprobes supported")
---
 arch/riscv/kernel/probes/uprobes.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/riscv/kernel/probes/uprobes.c +10 -0
index 194f166b2cc4..91f4ce101cd1 100644
@@ -3,6 +3,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
+#include <asm/insn.h>
 
 #include "decode-insn.h"
 
@@ -17,6 +18,15 @@ bool is_swbp_insn(uprobe_opcode_t *insn)
 #endif
 }
 
+bool is_trap_insn(uprobe_opcode_t *insn)
+{
+#ifdef CONFIG_RISCV_ISA_C
+	if (riscv_insn_is_c_ebreak(*insn))
+		return true;
+#endif
+	return riscv_insn_is_ebreak(*insn);
+}
+
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
 {
 	return instruction_pointer(regs);
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

Regardless, your patch fixes the hang:

[1] https://lore.kernel.org/linux-riscv/ZOum50Py8Vki+Nd3@nam-dell/

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

author
#2 lore raw
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 5 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

Best regards,
Nam

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

author
#3 lore raw
Quoted 23 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 4 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Quoted 5 lines
Quoted 3 lines

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

Best regards,
Nam

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

#4 lore raw
Quoted 27 lines · Nam Cao
Quoted 26 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 7 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

Quoted 8 lines
Quoted 2 lines

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

FWIW, I can still install the uprobe at an ebreak with you patch. It's not hit, but succeeds to install.

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

author
#5 lore raw
Quoted 32 lines · Björn Töpel
Quoted 30 lines · Nam Cao
Quoted 28 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 7 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

Quoted 8 lines
Quoted 5 lines

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

FWIW, I can still install the uprobe at an ebreak with you patch. It's not hit, but succeeds to install.

It seems uprobes install failures are completely silent (see uprobe_mmap() in kernel/events/uprobes.c). So I think although uprobes install seems fine, it actually is not.

Best regards,
Nam

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

#6 lore raw
Quoted 39 lines · Nam Cao
Quoted 38 lines · Björn Töpel
Quoted 35 lines · Nam Cao
Quoted 23 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 4 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Quoted 5 lines
Quoted 3 lines

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

Quoted 6 lines
Quoted 2 lines

FWIW, I can still install the uprobe at an ebreak with you patch. It's not hit, but succeeds to install.

It seems uprobes install failures are completely silent (see uprobe_mmap() in kernel/events/uprobes.c). So I think although uprobes install seems fine, it actually is not.

Huh, so there's no check if the instruction is a valid one at event register point?

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

author
#7 lore raw
Quoted 45 lines · Björn Töpel
Quoted 42 lines · Nam Cao
Quoted 40 lines · Björn Töpel
Quoted 27 lines · Nam Cao
Quoted 26 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 7 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

Quoted 8 lines
Quoted 2 lines

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

FWIW, I can still install the uprobe at an ebreak with you patch. It's not hit, but succeeds to install.

Quoted 6 lines
Quoted 3 lines

It seems uprobes install failures are completely silent (see uprobe_mmap() in kernel/events/uprobes.c). So I think although uprobes install seems fine, it actually is not.

Huh, so there's no check if the instruction is a valid one at event register point?

There are some checks (eg. if the probe is within the binary), but they are not complete.

The actual checks for the validity of the instruction is not done until installation.

Best regards,
Nam

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

author
#8 lore raw
Quoted 51 lines · Nam Cao
Quoted 49 lines · Björn Töpel
Quoted 45 lines · Nam Cao
Quoted 32 lines · Björn Töpel
Quoted 30 lines · Nam Cao
Quoted 28 lines · Nam Cao
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Quoted 4 lines
Quoted 2 lines

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

I took this for a spin, and it indeed fixes this new hang! Nice!

Great! Thanks for testing it.

Quoted 7 lines

However, when I tried setting an uprobe on the ebreak instruction (offset 0x118) from your example [1], the probe does not show up in the trace buffer.

Any ideas?

From my understanding, both uprobes and kprobes refuse to install break points

into existing trap instructions. Otherwise, we may conflict with something else that is also using trap instructions.

Quoted 8 lines
Quoted 5 lines

I just realize you probably ask this because uprobe can still be installed before applying the patch. But I think that is another bug that my patch also accidentally fix: uprobes should not install breakpoint into ebreak instructions, but it incorrectly does so because it does not even know about the existence of 32-bit ebreak.

FWIW, I can still install the uprobe at an ebreak with you patch. It's not hit, but succeeds to install.

It seems uprobes install failures are completely silent (see uprobe_mmap() in kernel/events/uprobes.c). So I think although uprobes install seems fine, it actually is not.

Quoted 5 lines
Quoted 2 lines

Huh, so there's no check if the instruction is a valid one at event register point?

There are some checks (eg. if the probe is within the binary), but they are not complete.

Oh wait, ignore that, just tested, this is also not checked.

Quoted 5 lines

The actual checks for the validity of the instruction is not done until installation.

Best regards,
Nam

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

#9 lore raw
In reply to Nam Cao
Quoted 32 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

Fixes 74784081aac8 ("riscv: Add uprobes supported")
---
 arch/riscv/kernel/probes/uprobes.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/riscv/kernel/probes/uprobes.c +1 -0
index 194f166b2cc4..91f4ce101cd1 100644
@@ -3,6 +3,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
+#include <asm/insn.h>
 
 #include "decode-insn.h"
 

arch/riscv/kernel/probes/uprobes.c bool is_swbp_insn(uprobe_opcode_t *insn) · line 23

Quoted 6 lines
arch/riscv/kernel/probes/uprobes.c +3 -0
@@ -17,6 +18,15 @@ bool is_swbp_insn(uprobe_opcode_t *insn)
 #endif
 }
 
+bool is_trap_insn(uprobe_opcode_t *insn)
+{
+#ifdef CONFIG_RISCV_ISA_C

Can we remove the CONFIG_RISCV_ISA_C? As you said, "uprobes expects is_trap_insn() to return true for any trap instructions". So userspace wouldn't be limited by CONFIG_RISCV_ISA_C.

Quoted 12 lines
arch/riscv/kernel/probes/uprobes.c +6 -1
+       if (riscv_insn_is_c_ebreak(*insn))
+               return true;
+#endif
+       return riscv_insn_is_ebreak(*insn);
+}
+
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
 {
        return instruction_pointer(regs);
--

2.34.1

Signature · 7 lines
Best Regards
 Guo Ren

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#10 lore raw
Quoted 36 lines · Guo Ren
Quoted 35 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

Fixes 74784081aac8 ("riscv: Add uprobes supported")
---
 arch/riscv/kernel/probes/uprobes.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/riscv/kernel/probes/uprobes.c +1 -0
index 194f166b2cc4..91f4ce101cd1 100644
@@ -3,6 +3,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
+#include <asm/insn.h>
 
 #include "decode-insn.h"
 
@@ -17,6 +18,15 @@ bool is_swbp_insn(uprobe_opcode_t *insn)
 #endif
 }
 
Quoted 7 lines

arch/riscv/kernel/probes/uprobes.c bool is_swbp_insn(uprobe_opcode_t *insn) · line 23

Quoted 3 lines
arch/riscv/kernel/probes/uprobes.c +3 -0
+bool is_trap_insn(uprobe_opcode_t *insn)
+{
+#ifdef CONFIG_RISCV_ISA_C

Can we remove the CONFIG_RISCV_ISA_C? As you said, "uprobes expects is_trap_insn() to return true for any trap instructions". So userspace wouldn't be limited by CONFIG_RISCV_ISA_C.

Isn't the RISCV_ISA_C required because there's a different encoding for EBREAK vs C_EBREAK? That said, this should be using IS_ENABLED() not #ifdef, since the definition for riscv_insn_is_c_ebreak() is provided unconditionally afaict.

Quoted 13 lines
Quoted 11 lines
arch/riscv/kernel/probes/uprobes.c +6 -1
+       if (riscv_insn_is_c_ebreak(*insn))
+               return true;
+#endif
+       return riscv_insn_is_ebreak(*insn);
+}
+
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
 {
        return instruction_pointer(regs);
--
Quoted 2 lines

2.34.1

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

author
#11 lore raw
Quoted 45 lines · Conor Dooley
Quoted 36 lines · Guo Ren
Quoted 35 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

Fixes 74784081aac8 ("riscv: Add uprobes supported")
---
 arch/riscv/kernel/probes/uprobes.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/riscv/kernel/probes/uprobes.c +1 -0
index 194f166b2cc4..91f4ce101cd1 100644
@@ -3,6 +3,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
+#include <asm/insn.h>
 
 #include "decode-insn.h"
 
@@ -17,6 +18,15 @@ bool is_swbp_insn(uprobe_opcode_t *insn)
 #endif
 }
 
Quoted 7 lines

arch/riscv/kernel/probes/uprobes.c bool is_swbp_insn(uprobe_opcode_t *insn) · line 23

Quoted 3 lines
arch/riscv/kernel/probes/uprobes.c +3 -0
+bool is_trap_insn(uprobe_opcode_t *insn)
+{
+#ifdef CONFIG_RISCV_ISA_C

Can we remove the CONFIG_RISCV_ISA_C? As you said, "uprobes expects is_trap_insn() to return true for any trap instructions". So userspace wouldn't be limited by CONFIG_RISCV_ISA_C.

Quoted 2 lines

Isn't the RISCV_ISA_C required because there's a different encoding for EBREAK vs C_EBREAK?

riscv_insn_is_c_ebreak() can be used without enabling RISCV_ISA_C, so no it's not required.

Best regards,
Nam

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

author
#12 lore raw
In reply to Conor Dooley
Quoted 45 lines · Conor Dooley
Quoted 36 lines · Guo Ren
Quoted 35 lines · Nam Cao

uprobes expects is_trap_insn() to return true for any trap instructions, not just the one used for installing uprobe. The current default implementation only returns true for 16-bit c.ebreak if C extension is enabled. This can confuse uprobes if a 32-bit ebreak generates a trap exception from userspace: uprobes asks is_trap_insn() who says there is no trap, so uprobes assume a probe was there before but has been removed, and return to the trap instruction. This cause an infinite loop of entering and exiting trap handler.

Instead of using the default implementation, implement this function speficially for riscv which checks for both ebreak and c.ebreak.

Fixes 74784081aac8 ("riscv: Add uprobes supported")
---
 arch/riscv/kernel/probes/uprobes.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/riscv/kernel/probes/uprobes.c +1 -0
index 194f166b2cc4..91f4ce101cd1 100644
@@ -3,6 +3,7 @@
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
 #include <linux/uprobes.h>
+#include <asm/insn.h>
 
 #include "decode-insn.h"
 
@@ -17,6 +18,15 @@ bool is_swbp_insn(uprobe_opcode_t *insn)
 #endif
 }
 
Quoted 7 lines

arch/riscv/kernel/probes/uprobes.c bool is_swbp_insn(uprobe_opcode_t *insn) · line 23

Quoted 3 lines
arch/riscv/kernel/probes/uprobes.c +3 -0
+bool is_trap_insn(uprobe_opcode_t *insn)
+{
+#ifdef CONFIG_RISCV_ISA_C

Can we remove the CONFIG_RISCV_ISA_C? As you said, "uprobes expects is_trap_insn() to return true for any trap instructions". So userspace wouldn't be limited by CONFIG_RISCV_ISA_C.

Quoted 4 lines

Isn't the RISCV_ISA_C required because there's a different encoding for EBREAK vs C_EBREAK? That said, this should be using IS_ENABLED() not #ifdef, since the definition for riscv_insn_is_c_ebreak() is provided unconditionally afaict.

Sorry, was too quick that I missed the last sentence.

Now I'm not sure what you mean. But I agree with Guo Ren here, users can use compressed instructions but kernel does not have it enabled. So we should always check c.ebreak regardless of RISCV_ISA_C.

Best regards,
Nam

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