Skip to content

Commit

Permalink
bpf: add PC to fault reporting using dt_probe_error()
Browse files Browse the repository at this point in the history
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed May 25, 2023
1 parent 083a2fe commit bfaf540
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions bpf/get_bvar.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
*/
#include <linux/bpf.h>
#include <stddef.h>
Expand All @@ -23,13 +23,14 @@ extern struct bpf_map_def cpuinfo;
extern struct bpf_map_def probes;
extern struct bpf_map_def state;

extern uint64_t PC;
extern uint64_t STBSZ;
extern uint64_t STKSIZ;
extern uint64_t BOOTTM;

#define error(dctx, fault, illval) \
({ \
dt_probe_error((dctx), -1, (fault), (illval)); \
dt_probe_error((dctx), (uint64_t)&PC, (fault), (illval)); \
-1; \
})

Expand Down
3 changes: 2 additions & 1 deletion bpf/speculation.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

extern struct bpf_map_def specs;
extern struct bpf_map_def state;
extern uint64_t PC;
extern uint64_t NSPEC;

/*
Expand Down Expand Up @@ -151,7 +152,7 @@ dt_speculation_set_drainable(const dt_dctx_t *dctx, uint32_t id)
if ((spec = bpf_map_lookup_elem(&specs, &id)) == NULL) {
if (id <= (uint64_t) &NSPEC)
return 0;
dt_probe_error(dctx, -1, DTRACEFLT_ILLOP, 0);
dt_probe_error(dctx, (uint64_t)&PC, DTRACEFLT_ILLOP, 0);
return -1;
}
spec->draining = 1;
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/speculation/err.CommitWithInvalid.r
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

-- @@stderr --
dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2
dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN
2 changes: 1 addition & 1 deletion test/unittest/speculation/err.DiscardWithInvalid.r
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

-- @@stderr --
dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2
dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN
2 changes: 1 addition & 1 deletion test/unittest/speculation/tst.negcommit.r
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

-- @@stderr --
dtrace: script 'test/unittest/speculation/tst.negcommit.d' matched 2 probes
dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): illegal operation in action #1
dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): illegal operation in action #1 at BPF pc NNN

0 comments on commit bfaf540

Please sign in to comment.