Skip to content

Commit

Permalink
Make DCTX_RODATA available to BPF functions
Browse files Browse the repository at this point in the history
Use DCTX_RODATA in inet_ntoa.S.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Jan 26, 2024
1 parent 789d0bc commit d30e20d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
14 changes: 4 additions & 10 deletions bpf/inet_ntoa6.S
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
*/

#define BPF_FUNC_probe_read 4

/*
* We sadly cannot include struct declarations in assembler input files, so we
* cannot use offsetof() to programmatically determine the offset of the rodata
* member in the DTrace context (dt_ctx_t). If that structure changes, the
* following define must be updated as well.
*/
#define DCTX_RODATA 56

#define OUTPUT_LEN 40
#define INPUT_LEN 16

Expand Down Expand Up @@ -225,7 +217,9 @@ dt_inet_ntoa6:
* have the code below output the address in two parts: a 7 word
* prefix followed by a 1 word suffix.
*/
ldxdw %r6, [%r6 + DCTX_RODATA]
lddw %r1, DCTX_RODATA
add %r1, %r6
ldxdw %r6, [%r1 + 0]
ldxw %r1, [%fp + -4] /* restore tbloff */
lddw %r0, RODATA_SIZE
jge %r1, %r0, .Ldone
Expand Down
11 changes: 6 additions & 5 deletions libdtrace/dt_bpf.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -38,10 +38,11 @@ extern "C" {
#define DT_CONST_TASK_COMM 16
#define DT_CONST_MUTEX_OWNER 17
#define DT_CONST_RWLOCK_CNTS 18
#define DT_CONST_RODATA_OFF 19
#define DT_CONST_RODATA_SIZE 20
#define DT_CONST_ZERO_OFF 21
#define DT_CONST_STACK_OFF 22
#define DT_CONST_DCTX_RODATA 19
#define DT_CONST_RODATA_OFF 20
#define DT_CONST_RODATA_SIZE 21
#define DT_CONST_ZERO_OFF 22
#define DT_CONST_STACK_OFF 23

#define DT_BPF_LOG_SIZE_DEFAULT (UINT32_MAX >> 8)
#define DT_BPF_LOG_SIZE_SMALL 4096
Expand Down
3 changes: 3 additions & 0 deletions libdtrace/dt_cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
nrp->dofr_data = total_offset;
continue;
}
case DT_CONST_DCTX_RODATA:
nrp->dofr_data = DCTX_RODATA;
continue;
case DT_CONST_RODATA_OFF:
nrp->dofr_data = dtp->dt_rooffset;
continue;
Expand Down
3 changes: 2 additions & 1 deletion libdtrace/dt_dlibs.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -91,6 +91,7 @@ static const dt_ident_t dt_bpf_symbols[] = {
DT_BPF_SYMBOL_ID(TASK_COMM, DT_IDENT_SCALAR, DT_CONST_TASK_COMM),
DT_BPF_SYMBOL_ID(MUTEX_OWNER, DT_IDENT_SCALAR, DT_CONST_MUTEX_OWNER),
DT_BPF_SYMBOL_ID(RWLOCK_CNTS, DT_IDENT_SCALAR, DT_CONST_RWLOCK_CNTS),
DT_BPF_SYMBOL_ID(DCTX_RODATA, DT_IDENT_SCALAR, DT_CONST_DCTX_RODATA),
DT_BPF_SYMBOL_ID(RODATA_OFF, DT_IDENT_SCALAR, DT_CONST_RODATA_OFF),
DT_BPF_SYMBOL_ID(RODATA_SIZE, DT_IDENT_SCALAR, DT_CONST_RODATA_SIZE),
DT_BPF_SYMBOL_ID(ZERO_OFF, DT_IDENT_SCALAR, DT_CONST_ZERO_OFF),
Expand Down

0 comments on commit d30e20d

Please sign in to comment.