Skip to content

Commit 62aa406

Browse files
zyd2001markus-metzger
authored andcommitted
libipt, block: proceed with cache when filling reaches an existing entry
Signed-off-by: Yida Zhang <[email protected]>
1 parent 60dc2df commit 62aa406

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

libipt/src/pt_block_decoder.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
static int pt_blk_proceed_trailing_event(struct pt_block_decoder *,
4646
struct pt_block *);
4747

48+
static int pt_blk_proceed_no_event_cached(struct pt_block_decoder *,
49+
struct pt_block *,
50+
struct pt_block_cache *,
51+
const struct pt_mapped_section *);
52+
4853
static int pt_blk_set_trig_anchor(struct pt_block_decoder *decoder)
4954
{
5055
if (!decoder)
@@ -2249,6 +2254,7 @@ pt_blk_proceed_no_event_fill_cache(struct pt_block_decoder *decoder,
22492254
uint64_t nip, dip, ioff, noff;
22502255
int64_t disp;
22512256
int status;
2257+
int fill_cache;
22522258

22532259
if (!decoder || !steps)
22542260
return -pte_internal;
@@ -2436,7 +2442,8 @@ pt_blk_proceed_no_event_fill_cache(struct pt_block_decoder *decoder,
24362442
* On our way back, we add a cache entry for this instruction based on
24372443
* the cache entry of the succeeding instruction.
24382444
*/
2439-
if (!pt_bce_is_valid(bce)) {
2445+
fill_cache = !pt_bce_is_valid(bce);
2446+
if (fill_cache) {
24402447
/* If we exceeded the maximum number of allowed steps, we insert
24412448
* a trampoline to the next instruction.
24422449
*
@@ -2515,7 +2522,15 @@ pt_blk_proceed_no_event_fill_cache(struct pt_block_decoder *decoder,
25152522
* Cache updates are atomic so even if the two versions were not
25162523
* identical, we wouldn't care because they are both correct.
25172524
*/
2518-
return pt_bcache_add(bcache, ioff, bce);
2525+
status = pt_bcache_add(bcache, ioff, bce);
2526+
if (status < 0)
2527+
return status;
2528+
2529+
/* Filling the cache may have extended @block, so we cannot proceed. */
2530+
if (fill_cache)
2531+
return status;
2532+
2533+
return pt_blk_proceed_no_event_cached(decoder, block, bcache, msec);
25192534
}
25202535

25212536
/* Proceed at a potentially truncated instruction.

0 commit comments

Comments
 (0)