Skip to content

Commit 16a3011

Browse files
libipt, ptdump: ignore unknown CFE packets
The current spec defines 12 types of CFE packets. It reserves an additional 18 types for future use. CFE packets provide additional events, but are not strictly necessary for decoding the trace, nor for understanding it. It is therefore better to ignore unknown CFE packets than to fail decode. Signed-off-by: Markus Metzger <[email protected]>
1 parent 9a5c738 commit 16a3011

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

libipt/src/pt_event_decoder.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3566,7 +3566,27 @@ static int pt_evt_decode_cfe(struct pt_event_decoder *decoder,
35663566
return pt_evt_fetch_packet(decoder);
35673567
}
35683568

3569-
return -pte_bad_packet;
3569+
/* Decoding EVD is supposed to only enqueue supported CFE types. */
3570+
if (ev)
3571+
return -pte_internal;
3572+
3573+
/* Ignore unknown CFE types.
3574+
*
3575+
* They provide additional information but they are not essential for
3576+
* decoding the trace. It is better to continue without that
3577+
* information than to fail.
3578+
*
3579+
* Since CFE may consume a subsequent FUP, we need to ignore that, too.
3580+
*/
3581+
if (packet->ip) {
3582+
ev = pt_evq_enqueue(&decoder->evq, evb_fup_bound);
3583+
if (!ev)
3584+
return -pte_nomem;
3585+
3586+
ev->type = ptev_ignore;
3587+
}
3588+
3589+
return 1;
35703590
}
35713591

35723592
static int pt_evt_decode_evd(struct pt_event_decoder *decoder,

ptdump/src/ptdump.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,13 +1394,13 @@ static int print_packet(struct ptdump_buffer *buffer, uint64_t offset,
13941394
case pt_cfe_vmexit:
13951395
case pt_cfe_shutdown:
13961396
case pt_cfe_uiret:
1397-
print_field(buffer->payload.standard, "%u%s",
1398-
packet->payload.cfe.type,
1399-
packet->payload.cfe.ip ? ", ip" : "");
1400-
return 0;
1397+
break;
14011398
}
14021399

1403-
return diag("unknown cfe type", offset, -pte_bad_packet);
1400+
print_field(buffer->payload.standard, "%u%s",
1401+
packet->payload.cfe.type,
1402+
packet->payload.cfe.ip ? ", ip" : "");
1403+
return 0;
14041404

14051405
case ppt_evd:
14061406
print_field(buffer->opcode, "evd");

test/src/ptet.ptt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ l12: nop
9797
; @pt p45: cfe(9: 14, ip)
9898
; @pt p46: fup(1: %l13)
9999
l13: nop
100+
; @pt p47: cfe(31, ip)
101+
; @pt p48: fup(1: %l14)
102+
l14: nop
103+
; @pt p49: cfe(31)
100104

101105
; @pt .exp(ptdump)
102106
;%0p0 psb
@@ -146,6 +150,9 @@ l13: nop
146150
;%0p44 evd 31: 0
147151
;%0p45 cfe 9: 14, ip
148152
;%0p46 fup 1: %?l13.2
153+
;%0p47 cfe 31, ip
154+
;%0p48 fup 1: %?l14.2
155+
;%0p49 cfe 31
149156

150157

151158
; @pt .exp(ptxed)

0 commit comments

Comments
 (0)