* [PATCH] Use DT_TRAMP_SP_SLOT() for BPF stack scratch space in trampoline
@ 2025-02-21 20:09 eugene.loh
2025-02-21 20:20 ` [DTrace-devel] " Kris Van Hees
0 siblings, 1 reply; 2+ messages in thread
From: eugene.loh @ 2025-02-21 20:09 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@oracle.com>
We might as well get this code right, even if this "fix" is
arguably irrelevant for two reasons:
*) The offset just so happens to be -96 before and after the
change anyhow, just by coincidence.
*) The fix is on a code path that is not currently in use.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
libdtrace/dt_cg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 846f0fe2e..cc64a3a13 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -594,11 +594,11 @@ dt_cg_tramp_copy_pc_from_regs(dt_pcb_t *pcb)
/* test just a single byte */
emit(dlp, BPF_MOV_IMM(BPF_REG_2, 1));
- /* safe to write to FP+DT_STK_SP_BASE, which becomes the clause stack */
+ /* write to scratch space */
emit(dlp, BPF_MOV_REG(BPF_REG_1, BPF_REG_FP));
- emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, DT_STK_SP_BASE));
+ emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, DT_TRAMP_SP_SLOT(0)));
- /* bpf_probe_read_kernel(%fp + DT_STK_SP, 1, PC) */
+ /* bpf_probe_read_kernel(%fp + DT_TRAMP_SP_SLOT(0), 1, PC) */
dt_regset_xalloc(drp, BPF_REG_0);
emit(dlp, BPF_CALL_HELPER(BPF_FUNC_probe_read_kernel));
--
2.43.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [DTrace-devel] [PATCH] Use DT_TRAMP_SP_SLOT() for BPF stack scratch space in trampoline
2025-02-21 20:09 [PATCH] Use DT_TRAMP_SP_SLOT() for BPF stack scratch space in trampoline eugene.loh
@ 2025-02-21 20:20 ` Kris Van Hees
0 siblings, 0 replies; 2+ messages in thread
From: Kris Van Hees @ 2025-02-21 20:20 UTC (permalink / raw)
To: eugene.loh; +Cc: dtrace, dtrace-devel
On Fri, Feb 21, 2025 at 03:09:24PM -0500, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> We might as well get this code right, even if this "fix" is
> arguably irrelevant for two reasons:
>
> *) The offset just so happens to be -96 before and after the
> change anyhow, just by coincidence.
>
> *) The fix is on a code path that is not currently in use.
>
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> libdtrace/dt_cg.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index 846f0fe2e..cc64a3a13 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -594,11 +594,11 @@ dt_cg_tramp_copy_pc_from_regs(dt_pcb_t *pcb)
> /* test just a single byte */
> emit(dlp, BPF_MOV_IMM(BPF_REG_2, 1));
>
> - /* safe to write to FP+DT_STK_SP_BASE, which becomes the clause stack */
> + /* write to scratch space */
> emit(dlp, BPF_MOV_REG(BPF_REG_1, BPF_REG_FP));
> - emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, DT_STK_SP_BASE));
> + emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, DT_TRAMP_SP_SLOT(0)));
>
> - /* bpf_probe_read_kernel(%fp + DT_STK_SP, 1, PC) */
> + /* bpf_probe_read_kernel(%fp + DT_TRAMP_SP_SLOT(0), 1, PC) */
> dt_regset_xalloc(drp, BPF_REG_0);
> emit(dlp, BPF_CALL_HELPER(BPF_FUNC_probe_read_kernel));
>
> --
> 2.43.5
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-21 20:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 20:09 [PATCH] Use DT_TRAMP_SP_SLOT() for BPF stack scratch space in trampoline eugene.loh
2025-02-21 20:20 ` [DTrace-devel] " Kris Van Hees
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox