xref: /freebsd/contrib/processor-trace/libipt/test/src/ptunit-query.c (revision 47dd1d1b619cc035b82b49a91a25544309ff95ae)
1 /*
2  * Copyright (c) 2013-2018, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *  * Redistributions of source code must retain the above copyright notice,
8  *    this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright notice,
10  *    this list of conditions and the following disclaimer in the documentation
11  *    and/or other materials provided with the distribution.
12  *  * Neither the name of Intel Corporation nor the names of its contributors
13  *    may be used to endorse or promote products derived from this software
14  *    without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "ptunit.h"
30 
31 #include "pt_last_ip.h"
32 #include "pt_decoder_function.h"
33 #include "pt_query_decoder.h"
34 #include "pt_encoder.h"
35 #include "pt_opcodes.h"
36 
37 
38 /* A query testing fixture. */
39 
40 struct ptu_decoder_fixture {
41 	/* The test fixture initialization and finalization functions. */
42 	struct ptunit_result (*init)(struct ptu_decoder_fixture *);
43 	struct ptunit_result (*fini)(struct ptu_decoder_fixture *);
44 
45 	/* Encode an optional header for the test to read over. */
46 	struct ptunit_result (*header)(struct ptu_decoder_fixture *);
47 
48 	/* The trace buffer. */
49 	uint8_t buffer[1024];
50 
51 	/* The configuration under test. */
52 	struct pt_config config;
53 
54 	/* A encoder and query decoder for the above configuration. */
55 	struct pt_encoder encoder;
56 	struct pt_query_decoder decoder;
57 
58 	/* For tracking last-ip in tests. */
59 	struct pt_last_ip last_ip;
60 };
61 
62 /* An invalid address. */
63 static const uint64_t pt_dfix_bad_ip = (1ull << 62) - 1;
64 
65 /* A sign-extended address. */
66 static const uint64_t pt_dfix_sext_ip = 0xffffff00ff00ff00ull;
67 
68 /* The highest possible address. */
69 static const uint64_t pt_dfix_max_ip = (1ull << 47) - 1;
70 
71 /* The highest possible cr3 value. */
72 static const uint64_t pt_dfix_max_cr3 = ((1ull << 47) - 1) & ~0x1f;
73 
74 /* Synchronize the decoder at the beginning of the trace stream, avoiding the
75  * initial PSB header.
76  */
77 static struct ptunit_result ptu_sync_decoder(struct pt_query_decoder *decoder)
78 {
79 	ptu_ptr(decoder);
80 	decoder->enabled = 1;
81 
82 	(void) pt_df_fetch(&decoder->next, decoder->pos, &decoder->config);
83 	return ptu_passed();
84 }
85 
86 /* Cut off the last encoded packet. */
87 static struct ptunit_result cutoff(struct pt_query_decoder *decoder,
88 				   const struct pt_encoder *encoder)
89 {
90 	uint8_t *pos;
91 
92 	ptu_ptr(decoder);
93 	ptu_ptr(encoder);
94 
95 	pos = encoder->pos;
96 	ptu_ptr(pos);
97 
98 	pos -= 1;
99 	ptu_ptr_le(decoder->config.begin, pos);
100 
101 	decoder->config.end = pos;
102 	return ptu_passed();
103 }
104 
105 static struct ptunit_result indir_not_synced(struct ptu_decoder_fixture *dfix)
106 {
107 	struct pt_query_decoder *decoder = &dfix->decoder;
108 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
109 	int errcode;
110 
111 	errcode = pt_qry_indirect_branch(decoder, &addr);
112 	ptu_int_eq(errcode, -pte_nosync);
113 	ptu_uint_eq(addr, ip);
114 
115 	return ptu_passed();
116 }
117 
118 static struct ptunit_result cond_not_synced(struct ptu_decoder_fixture *dfix)
119 {
120 	struct pt_query_decoder *decoder = &dfix->decoder;
121 	int errcode, tnt = 0xbc, taken = tnt;
122 
123 	errcode = pt_qry_cond_branch(decoder, &taken);
124 	ptu_int_eq(errcode, -pte_nosync);
125 	ptu_int_eq(taken, tnt);
126 
127 	return ptu_passed();
128 }
129 
130 static struct ptunit_result event_not_synced(struct ptu_decoder_fixture *dfix)
131 {
132 	struct pt_query_decoder *decoder = &dfix->decoder;
133 	struct pt_event event;
134 	int errcode;
135 
136 	errcode = pt_qry_event(decoder, &event, sizeof(event));
137 	ptu_int_eq(errcode, -pte_nosync);
138 
139 	return ptu_passed();
140 }
141 
142 static struct ptunit_result sync_backward(struct ptu_decoder_fixture *dfix)
143 {
144 	struct pt_query_decoder *decoder = &dfix->decoder;
145 	struct pt_encoder *encoder = &dfix->encoder;
146 	uint64_t sync[3], offset, ip;
147 	int errcode;
148 
149 	/* Check that we can use repeated pt_qry_sync_backward() to iterate over
150 	 * synchronization points in backwards order.
151 	 */
152 
153 	errcode = pt_enc_get_offset(encoder, &sync[0]);
154 	ptu_int_ge(errcode, 0);
155 
156 	pt_encode_psb(encoder);
157 	pt_encode_mode_exec(encoder, ptem_64bit);
158 	pt_encode_psbend(encoder);
159 
160 	errcode = pt_enc_get_offset(encoder, &sync[1]);
161 	ptu_int_ge(errcode, 0);
162 
163 	pt_encode_psb(encoder);
164 	pt_encode_mode_exec(encoder, ptem_64bit);
165 	pt_encode_psbend(encoder);
166 
167 	errcode = pt_enc_get_offset(encoder, &sync[2]);
168 	ptu_int_ge(errcode, 0);
169 
170 	pt_encode_psb(encoder);
171 	pt_encode_mode_exec(encoder, ptem_64bit);
172 	pt_encode_psbend(encoder);
173 
174 	/* Synchronize repeatedly and check that we reach each PSB in the
175 	 * correct order.
176 	 */
177 
178 	errcode = pt_qry_sync_backward(decoder, &ip);
179 	ptu_int_ge(errcode, 0);
180 
181 	errcode = pt_qry_get_sync_offset(decoder, &offset);
182 	ptu_int_eq(errcode, 0);
183 	ptu_uint_eq(offset, sync[2]);
184 
185 	errcode = pt_qry_sync_backward(decoder, &ip);
186 	ptu_int_ge(errcode, 0);
187 
188 	errcode = pt_qry_get_sync_offset(decoder, &offset);
189 	ptu_int_eq(errcode, 0);
190 	ptu_uint_eq(offset, sync[1]);
191 
192 	errcode = pt_qry_sync_backward(decoder, &ip);
193 	ptu_int_ge(errcode, 0);
194 
195 	errcode = pt_qry_get_sync_offset(decoder, &offset);
196 	ptu_int_eq(errcode, 0);
197 	ptu_uint_eq(offset, sync[0]);
198 
199 	errcode = pt_qry_sync_backward(decoder, &ip);
200 	ptu_int_eq(errcode, -pte_eos);
201 
202 	return ptu_passed();
203 }
204 
205 static struct ptunit_result
206 sync_backward_empty_end(struct ptu_decoder_fixture *dfix)
207 {
208 	struct pt_query_decoder *decoder = &dfix->decoder;
209 	struct pt_encoder *encoder = &dfix->encoder;
210 	uint64_t sync[3], offset, ip;
211 	int errcode;
212 
213 	/* Check that we can use repeated pt_qry_sync_backward() to iterate over
214 	 * synchronization points in backwards order.
215 	 *
216 	 * There's an empty PSB+ at the end.  We skip it.
217 	 */
218 
219 	errcode = pt_enc_get_offset(encoder, &sync[0]);
220 	ptu_int_ge(errcode, 0);
221 
222 	pt_encode_psb(encoder);
223 	pt_encode_mode_exec(encoder, ptem_64bit);
224 	pt_encode_psbend(encoder);
225 
226 	errcode = pt_enc_get_offset(encoder, &sync[1]);
227 	ptu_int_ge(errcode, 0);
228 
229 	pt_encode_psb(encoder);
230 	pt_encode_mode_exec(encoder, ptem_64bit);
231 	pt_encode_psbend(encoder);
232 
233 	errcode = pt_enc_get_offset(encoder, &sync[2]);
234 	ptu_int_ge(errcode, 0);
235 
236 	pt_encode_psb(encoder);
237 	pt_encode_psbend(encoder);
238 
239 	/* Synchronize repeatedly and check that we reach each PSB in the
240 	 * correct order.
241 	 */
242 
243 	errcode = pt_qry_sync_backward(decoder, &ip);
244 	ptu_int_ge(errcode, 0);
245 
246 	errcode = pt_qry_get_sync_offset(decoder, &offset);
247 	ptu_int_eq(errcode, 0);
248 	ptu_uint_eq(offset, sync[1]);
249 
250 	errcode = pt_qry_sync_backward(decoder, &ip);
251 	ptu_int_ge(errcode, 0);
252 
253 	errcode = pt_qry_get_sync_offset(decoder, &offset);
254 	ptu_int_eq(errcode, 0);
255 	ptu_uint_eq(offset, sync[0]);
256 
257 	errcode = pt_qry_sync_backward(decoder, &ip);
258 	ptu_int_eq(errcode, -pte_eos);
259 
260 	return ptu_passed();
261 }
262 
263 static struct ptunit_result
264 sync_backward_empty_mid(struct ptu_decoder_fixture *dfix)
265 {
266 	struct pt_query_decoder *decoder = &dfix->decoder;
267 	struct pt_encoder *encoder = &dfix->encoder;
268 	uint64_t sync[3], offset, ip;
269 	int errcode;
270 
271 	/* Check that we can use repeated pt_qry_sync_backward() to iterate over
272 	 * synchronization points in backwards order.
273 	 *
274 	 * There's an empty PSB+ in the middle.  We skip it.
275 	 */
276 
277 	errcode = pt_enc_get_offset(encoder, &sync[0]);
278 	ptu_int_ge(errcode, 0);
279 
280 	pt_encode_psb(encoder);
281 	pt_encode_mode_exec(encoder, ptem_64bit);
282 	pt_encode_psbend(encoder);
283 
284 	errcode = pt_enc_get_offset(encoder, &sync[1]);
285 	ptu_int_ge(errcode, 0);
286 
287 	pt_encode_psb(encoder);
288 	pt_encode_psbend(encoder);
289 
290 	errcode = pt_enc_get_offset(encoder, &sync[2]);
291 	ptu_int_ge(errcode, 0);
292 
293 	pt_encode_psb(encoder);
294 	pt_encode_mode_exec(encoder, ptem_64bit);
295 	pt_encode_psbend(encoder);
296 
297 	/* Synchronize repeatedly and check that we reach each PSB in the
298 	 * correct order.
299 	 */
300 
301 	errcode = pt_qry_sync_backward(decoder, &ip);
302 	ptu_int_ge(errcode, 0);
303 
304 	errcode = pt_qry_get_sync_offset(decoder, &offset);
305 	ptu_int_eq(errcode, 0);
306 	ptu_uint_eq(offset, sync[2]);
307 
308 	errcode = pt_qry_sync_backward(decoder, &ip);
309 	ptu_int_ge(errcode, 0);
310 
311 	errcode = pt_qry_get_sync_offset(decoder, &offset);
312 	ptu_int_eq(errcode, 0);
313 	ptu_uint_eq(offset, sync[0]);
314 
315 	errcode = pt_qry_sync_backward(decoder, &ip);
316 	ptu_int_eq(errcode, -pte_eos);
317 
318 	return ptu_passed();
319 }
320 
321 static struct ptunit_result
322 sync_backward_empty_begin(struct ptu_decoder_fixture *dfix)
323 {
324 	struct pt_query_decoder *decoder = &dfix->decoder;
325 	struct pt_encoder *encoder = &dfix->encoder;
326 	uint64_t sync[3], offset, ip;
327 	int errcode;
328 
329 	/* Check that we can use repeated pt_qry_sync_backward() to iterate over
330 	 * synchronization points in backwards order.
331 	 *
332 	 * There's an empty PSB+ at the beginning.  We skip it.
333 	 */
334 
335 	errcode = pt_enc_get_offset(encoder, &sync[0]);
336 	ptu_int_ge(errcode, 0);
337 
338 	pt_encode_psb(encoder);
339 	pt_encode_psbend(encoder);
340 
341 	errcode = pt_enc_get_offset(encoder, &sync[1]);
342 	ptu_int_ge(errcode, 0);
343 
344 	pt_encode_psb(encoder);
345 	pt_encode_mode_exec(encoder, ptem_64bit);
346 	pt_encode_psbend(encoder);
347 
348 	errcode = pt_enc_get_offset(encoder, &sync[2]);
349 	ptu_int_ge(errcode, 0);
350 
351 	pt_encode_psb(encoder);
352 	pt_encode_mode_exec(encoder, ptem_64bit);
353 	pt_encode_psbend(encoder);
354 
355 	/* Synchronize repeatedly and check that we reach each PSB in the
356 	 * correct order.
357 	 */
358 
359 	errcode = pt_qry_sync_backward(decoder, &ip);
360 	ptu_int_ge(errcode, 0);
361 
362 	errcode = pt_qry_get_sync_offset(decoder, &offset);
363 	ptu_int_eq(errcode, 0);
364 	ptu_uint_eq(offset, sync[2]);
365 
366 	errcode = pt_qry_sync_backward(decoder, &ip);
367 	ptu_int_ge(errcode, 0);
368 
369 	errcode = pt_qry_get_sync_offset(decoder, &offset);
370 	ptu_int_eq(errcode, 0);
371 	ptu_uint_eq(offset, sync[1]);
372 
373 	errcode = pt_qry_sync_backward(decoder, &ip);
374 	ptu_int_eq(errcode, -pte_eos);
375 
376 	return ptu_passed();
377 }
378 
379 static struct ptunit_result
380 decode_sync_backward(struct ptu_decoder_fixture *dfix)
381 {
382 	struct pt_query_decoder *decoder = &dfix->decoder;
383 	struct pt_encoder *encoder = &dfix->encoder;
384 	struct pt_event event;
385 	uint64_t sync[2], offset, ip;
386 	int errcode;
387 
388 	/* Check that we can use sync_backward to re-sync at the current trace
389 	 * segment as well as to find the previous trace segment.
390 	 */
391 
392 	errcode = pt_enc_get_offset(encoder, &sync[0]);
393 	ptu_int_ge(errcode, 0);
394 
395 	pt_encode_psb(encoder);
396 	pt_encode_mode_exec(encoder, ptem_64bit);
397 	pt_encode_psbend(encoder);
398 
399 	errcode = pt_enc_get_offset(encoder, &sync[1]);
400 	ptu_int_ge(errcode, 0);
401 
402 	pt_encode_psb(encoder);
403 	pt_encode_mode_exec(encoder, ptem_64bit);
404 	pt_encode_psbend(encoder);
405 
406 
407 	errcode = pt_qry_sync_forward(decoder, &ip);
408 	ptu_int_ge(errcode, 0);
409 
410 	errcode = pt_qry_get_sync_offset(decoder, &offset);
411 	ptu_int_eq(errcode, 0);
412 	ptu_uint_eq(offset, sync[0]);
413 
414 	errcode = pt_qry_event(decoder, &event, sizeof(event));
415 	ptu_int_ge(errcode, 0);
416 	ptu_int_eq(event.type, ptev_exec_mode);
417 
418 	errcode = pt_qry_event(decoder, &event, sizeof(event));
419 	ptu_int_ge(errcode, 0);
420 	ptu_int_eq(event.type, ptev_exec_mode);
421 
422 	errcode = pt_qry_sync_backward(decoder, &ip);
423 	ptu_int_ge(errcode, 0);
424 
425 	errcode = pt_qry_get_sync_offset(decoder, &offset);
426 	ptu_int_eq(errcode, 0);
427 	ptu_uint_eq(offset, sync[1]);
428 
429 	errcode = pt_qry_sync_backward(decoder, &ip);
430 	ptu_int_ge(errcode, 0);
431 
432 	errcode = pt_qry_get_sync_offset(decoder, &offset);
433 	ptu_int_eq(errcode, 0);
434 	ptu_uint_eq(offset, sync[0]);
435 
436 	errcode = pt_qry_sync_backward(decoder, &ip);
437 	ptu_int_eq(errcode, -pte_eos);
438 
439 	return ptu_passed();
440 }
441 
442 static struct ptunit_result indir_null(struct ptu_decoder_fixture *dfix)
443 {
444 	struct pt_query_decoder *decoder = &dfix->decoder;
445 	struct pt_config *config = &decoder->config;
446 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
447 	int errcode;
448 
449 	errcode = pt_qry_indirect_branch(NULL, &addr);
450 	ptu_int_eq(errcode, -pte_invalid);
451 	ptu_uint_eq(addr, ip);
452 
453 	errcode = pt_qry_indirect_branch(decoder, NULL);
454 	ptu_int_eq(errcode, -pte_invalid);
455 	ptu_ptr_eq(decoder->pos, config->begin);
456 
457 	return ptu_passed();
458 }
459 
460 static struct ptunit_result indir_empty(struct ptu_decoder_fixture *dfix)
461 {
462 	struct pt_query_decoder *decoder = &dfix->decoder;
463 	struct pt_config *config = &decoder->config;
464 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
465 	int errcode;
466 
467 	decoder->pos = config->end;
468 
469 	errcode = pt_qry_indirect_branch(decoder, &addr);
470 	ptu_int_eq(errcode, -pte_eos);
471 	ptu_uint_eq(addr, ip);
472 
473 	return ptu_passed();
474 }
475 
476 static struct ptunit_result indir(struct ptu_decoder_fixture *dfix,
477 				  enum pt_ip_compression ipc)
478 {
479 	struct pt_query_decoder *decoder = &dfix->decoder;
480 	struct pt_encoder *encoder = &dfix->encoder;
481 	struct pt_packet_ip packet;
482 	uint64_t addr = pt_dfix_bad_ip;
483 	int errcode;
484 
485 	packet.ipc = ipc;
486 	packet.ip = pt_dfix_sext_ip;
487 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
488 
489 	pt_encode_tip(encoder, packet.ip, packet.ipc);
490 
491 	ptu_check(ptu_sync_decoder, decoder);
492 
493 	errcode = pt_qry_indirect_branch(decoder, &addr);
494 	if (ipc == pt_ipc_suppressed) {
495 		ptu_int_eq(errcode, pts_ip_suppressed | pts_eos);
496 		ptu_uint_eq(addr, pt_dfix_bad_ip);
497 	} else {
498 		ptu_int_eq(errcode, pts_eos);
499 		ptu_uint_eq(addr, dfix->last_ip.ip);
500 	}
501 
502 	return ptu_passed();
503 }
504 
505 static struct ptunit_result indir_tnt(struct ptu_decoder_fixture *dfix,
506 				      enum pt_ip_compression ipc)
507 {
508 	struct pt_query_decoder *decoder = &dfix->decoder;
509 	struct pt_encoder *encoder = &dfix->encoder;
510 	struct pt_packet_ip packet;
511 	uint64_t addr = pt_dfix_bad_ip;
512 	int errcode;
513 
514 	packet.ipc = ipc;
515 	packet.ip = pt_dfix_sext_ip;
516 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
517 
518 	pt_encode_tnt_8(encoder, 0ull, 1);
519 	pt_encode_tip(encoder, packet.ip, packet.ipc);
520 
521 	ptu_check(ptu_sync_decoder, decoder);
522 
523 	errcode = pt_qry_indirect_branch(decoder, &addr);
524 	if (ipc == pt_ipc_suppressed) {
525 		ptu_int_eq(errcode, pts_ip_suppressed);
526 		ptu_uint_eq(addr, pt_dfix_bad_ip);
527 	} else {
528 		ptu_int_eq(errcode, 0);
529 		ptu_uint_eq(addr, dfix->last_ip.ip);
530 	}
531 
532 	return ptu_passed();
533 }
534 
535 static struct ptunit_result indir_cutoff_fail(struct ptu_decoder_fixture *dfix)
536 {
537 	struct pt_query_decoder *decoder = &dfix->decoder;
538 	struct pt_encoder *encoder = &dfix->encoder;
539 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
540 	int errcode;
541 
542 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
543 
544 	ptu_check(cutoff, decoder, encoder);
545 	ptu_check(ptu_sync_decoder, decoder);
546 
547 	errcode = pt_qry_indirect_branch(decoder, &addr);
548 	ptu_int_eq(errcode, -pte_eos);
549 	ptu_uint_eq(addr, ip);
550 
551 	return ptu_passed();
552 }
553 
554 static struct ptunit_result
555 indir_skip_tnt_fail(struct ptu_decoder_fixture *dfix)
556 {
557 	struct pt_query_decoder *decoder = &dfix->decoder;
558 	struct pt_encoder *encoder = &dfix->encoder;
559 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
560 	int errcode;
561 
562 	pt_encode_tnt_8(encoder, 0, 1);
563 	pt_encode_tnt_8(encoder, 0, 1);
564 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
565 
566 	ptu_check(ptu_sync_decoder, decoder);
567 
568 	errcode = pt_qry_indirect_branch(decoder, &addr);
569 	ptu_int_eq(errcode, -pte_bad_query);
570 	ptu_uint_eq(addr, ip);
571 
572 	return ptu_passed();
573 }
574 
575 static struct ptunit_result
576 indir_skip_tip_pge_fail(struct ptu_decoder_fixture *dfix)
577 {
578 	struct pt_query_decoder *decoder = &dfix->decoder;
579 	struct pt_encoder *encoder = &dfix->encoder;
580 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
581 	const uint8_t *pos;
582 	int errcode;
583 
584 	pos = encoder->pos;
585 	pt_encode_tip_pge(encoder, 0, pt_ipc_sext_48);
586 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
587 
588 	ptu_check(ptu_sync_decoder, decoder);
589 
590 	errcode = pt_qry_indirect_branch(decoder, &addr);
591 	ptu_int_eq(errcode, -pte_bad_query);
592 	ptu_ptr_eq(decoder->pos, pos);
593 	ptu_uint_eq(addr, ip);
594 
595 	return ptu_passed();
596 }
597 
598 static struct ptunit_result
599 indir_skip_tip_pgd_fail(struct ptu_decoder_fixture *dfix)
600 {
601 	struct pt_query_decoder *decoder = &dfix->decoder;
602 	struct pt_encoder *encoder = &dfix->encoder;
603 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
604 	const uint8_t *pos;
605 	int errcode;
606 
607 	pos = encoder->pos;
608 	pt_encode_tip_pgd(encoder, 0, pt_ipc_sext_48);
609 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
610 
611 	ptu_check(ptu_sync_decoder, decoder);
612 
613 	errcode = pt_qry_indirect_branch(decoder, &addr);
614 	ptu_int_eq(errcode, -pte_bad_query);
615 	ptu_ptr_eq(decoder->pos, pos);
616 	ptu_uint_eq(addr, ip);
617 
618 	return ptu_passed();
619 }
620 
621 static struct ptunit_result
622 indir_skip_fup_tip_fail(struct ptu_decoder_fixture *dfix)
623 {
624 	struct pt_query_decoder *decoder = &dfix->decoder;
625 	struct pt_encoder *encoder = &dfix->encoder;
626 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
627 	const uint8_t *pos;
628 	int errcode;
629 
630 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
631 	pos = encoder->pos;
632 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
633 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
634 
635 	ptu_check(ptu_sync_decoder, decoder);
636 
637 	errcode = pt_qry_indirect_branch(decoder, &addr);
638 	ptu_int_eq(errcode, -pte_bad_query);
639 	ptu_ptr_eq(decoder->pos, pos);
640 	ptu_uint_eq(addr, ip);
641 
642 	return ptu_passed();
643 }
644 
645 static struct ptunit_result
646 indir_skip_fup_tip_pgd_fail(struct ptu_decoder_fixture *dfix)
647 {
648 	struct pt_query_decoder *decoder = &dfix->decoder;
649 	struct pt_encoder *encoder = &dfix->encoder;
650 	uint64_t ip = pt_dfix_bad_ip, addr = ip;
651 	const uint8_t *pos;
652 	int errcode;
653 
654 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
655 	pos = encoder->pos;
656 	pt_encode_tip_pgd(encoder, 0, pt_ipc_sext_48);
657 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
658 
659 	ptu_check(ptu_sync_decoder, decoder);
660 
661 	errcode = pt_qry_indirect_branch(decoder, &addr);
662 	ptu_int_eq(errcode, -pte_bad_query);
663 	ptu_ptr_eq(decoder->pos, pos);
664 	ptu_uint_eq(addr, ip);
665 
666 	return ptu_passed();
667 }
668 
669 static struct ptunit_result cond_null(struct ptu_decoder_fixture *dfix)
670 {
671 	struct pt_query_decoder *decoder = &dfix->decoder;
672 	struct pt_config *config = &decoder->config;
673 	int errcode, tnt = 0xbc, taken = tnt;
674 
675 	errcode = pt_qry_cond_branch(NULL, &taken);
676 	ptu_int_eq(errcode, -pte_invalid);
677 	ptu_int_eq(taken, tnt);
678 
679 	errcode = pt_qry_cond_branch(decoder, NULL);
680 	ptu_int_eq(errcode, -pte_invalid);
681 	ptu_ptr_eq(decoder->pos, config->begin);
682 
683 	return ptu_passed();
684 }
685 
686 static struct ptunit_result cond_empty(struct ptu_decoder_fixture *dfix)
687 {
688 	struct pt_query_decoder *decoder = &dfix->decoder;
689 	struct pt_config *config = &decoder->config;
690 	int errcode, tnt = 0xbc, taken = tnt;
691 
692 	decoder->pos = config->end;
693 
694 	errcode = pt_qry_cond_branch(decoder, &taken);
695 	ptu_int_eq(errcode, -pte_eos);
696 	ptu_int_eq(taken, tnt);
697 
698 	return ptu_passed();
699 }
700 
701 static struct ptunit_result cond(struct ptu_decoder_fixture *dfix)
702 {
703 	struct pt_query_decoder *decoder = &dfix->decoder;
704 	struct pt_encoder *encoder = &dfix->encoder;
705 	int errcode, tnt = 0xbc, taken = tnt;
706 
707 	pt_encode_tnt_8(encoder, 0x02, 3);
708 
709 	ptu_check(ptu_sync_decoder, decoder);
710 
711 	errcode = pt_qry_cond_branch(decoder, &taken);
712 	ptu_int_eq(errcode, 0);
713 	ptu_int_eq(taken, 0);
714 
715 	taken = tnt;
716 	errcode = pt_qry_cond_branch(decoder, &taken);
717 	ptu_int_eq(errcode, 0);
718 	ptu_int_eq(taken, 1);
719 
720 	taken = tnt;
721 	errcode = pt_qry_cond_branch(decoder, &taken);
722 	ptu_int_eq(errcode, pts_eos);
723 	ptu_int_eq(taken, 0);
724 
725 	taken = tnt;
726 	errcode = pt_qry_cond_branch(decoder, &taken);
727 	ptu_int_eq(errcode, -pte_eos);
728 	ptu_int_eq(taken, tnt);
729 
730 	return ptu_passed();
731 }
732 
733 static struct ptunit_result cond_skip_tip_fail(struct ptu_decoder_fixture *dfix)
734 {
735 	struct pt_query_decoder *decoder = &dfix->decoder;
736 	struct pt_encoder *encoder = &dfix->encoder;
737 	int errcode, tnt = 0xbc, taken = tnt;
738 	const uint8_t *pos;
739 
740 	pos = encoder->pos;
741 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
742 	pt_encode_tnt_8(encoder, 0, 1);
743 
744 	ptu_check(ptu_sync_decoder, decoder);
745 
746 	errcode = pt_qry_cond_branch(decoder, &taken);
747 	ptu_int_eq(errcode, -pte_bad_query);
748 	ptu_ptr_eq(decoder->pos, pos);
749 	ptu_int_eq(taken, tnt);
750 
751 	return ptu_passed();
752 }
753 
754 static struct ptunit_result
755 cond_skip_tip_pge_fail(struct ptu_decoder_fixture *dfix)
756 {
757 	struct pt_query_decoder *decoder = &dfix->decoder;
758 	struct pt_encoder *encoder = &dfix->encoder;
759 	int errcode, tnt = 0xbc, taken = tnt;
760 	const uint8_t *pos;
761 
762 	pos = encoder->pos;
763 	pt_encode_tip_pge(encoder, 0, pt_ipc_sext_48);
764 	pt_encode_tnt_8(encoder, 0, 1);
765 
766 	ptu_check(ptu_sync_decoder, decoder);
767 
768 	errcode = pt_qry_cond_branch(decoder, &taken);
769 	ptu_int_eq(errcode, -pte_bad_query);
770 	ptu_ptr_eq(decoder->pos, pos);
771 	ptu_int_eq(taken, tnt);
772 
773 	return ptu_passed();
774 }
775 
776 static struct ptunit_result
777 cond_skip_tip_pgd_fail(struct ptu_decoder_fixture *dfix)
778 {
779 	struct pt_query_decoder *decoder = &dfix->decoder;
780 	struct pt_encoder *encoder = &dfix->encoder;
781 	int errcode, tnt = 0xbc, taken = tnt;
782 	const uint8_t *pos;
783 
784 	pos = encoder->pos;
785 	pt_encode_tip_pgd(encoder, 0, pt_ipc_sext_48);
786 	pt_encode_tnt_8(encoder, 0, 1);
787 
788 	ptu_check(ptu_sync_decoder, decoder);
789 
790 	errcode = pt_qry_cond_branch(decoder, &taken);
791 	ptu_int_eq(errcode, -pte_bad_query);
792 	ptu_ptr_eq(decoder->pos, pos);
793 	ptu_int_eq(taken, tnt);
794 
795 	return ptu_passed();
796 }
797 
798 static struct ptunit_result
799 cond_skip_fup_tip_fail(struct ptu_decoder_fixture *dfix)
800 {
801 	struct pt_query_decoder *decoder = &dfix->decoder;
802 	struct pt_encoder *encoder = &dfix->encoder;
803 	int errcode, tnt = 0xbc, taken = tnt;
804 	const uint8_t *pos;
805 
806 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
807 	pos = encoder->pos;
808 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
809 	pt_encode_tnt_8(encoder, 0, 1);
810 
811 	ptu_check(ptu_sync_decoder, decoder);
812 
813 	errcode = pt_qry_cond_branch(decoder, &taken);
814 	ptu_int_eq(errcode, -pte_bad_query);
815 	ptu_ptr_eq(decoder->pos, pos);
816 	ptu_int_eq(taken, tnt);
817 
818 	return ptu_passed();
819 }
820 
821 static struct ptunit_result
822 cond_skip_fup_tip_pgd_fail(struct ptu_decoder_fixture *dfix)
823 {
824 	struct pt_query_decoder *decoder = &dfix->decoder;
825 	struct pt_encoder *encoder = &dfix->encoder;
826 	int errcode, tnt = 0xbc, taken = tnt;
827 	const uint8_t *pos;
828 
829 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
830 	pos = encoder->pos;
831 	pt_encode_tip_pgd(encoder, 0, pt_ipc_sext_48);
832 	pt_encode_tnt_8(encoder, 0, 1);
833 
834 	ptu_check(ptu_sync_decoder, decoder);
835 
836 	errcode = pt_qry_cond_branch(decoder, &taken);
837 	ptu_int_eq(errcode, -pte_bad_query);
838 	ptu_ptr_eq(decoder->pos, pos);
839 	ptu_int_eq(taken, tnt);
840 
841 	return ptu_passed();
842 }
843 
844 static struct ptunit_result event_null(struct ptu_decoder_fixture *dfix)
845 {
846 	struct pt_query_decoder *decoder = &dfix->decoder;
847 	struct pt_config *config = &decoder->config;
848 	struct pt_event event;
849 	int errcode;
850 
851 	errcode = pt_qry_event(NULL, &event, sizeof(event));
852 	ptu_int_eq(errcode, -pte_invalid);
853 
854 	errcode = pt_qry_event(decoder, NULL, sizeof(event));
855 	ptu_int_eq(errcode, -pte_invalid);
856 	ptu_ptr_eq(decoder->pos, config->begin);
857 
858 	return ptu_passed();
859 }
860 
861 static struct ptunit_result event_bad_size(struct ptu_decoder_fixture *dfix)
862 {
863 	struct pt_query_decoder *decoder = &dfix->decoder;
864 	struct pt_event event;
865 	int errcode;
866 
867 	errcode = pt_qry_event(decoder, &event, 4);
868 	ptu_int_eq(errcode, -pte_invalid);
869 
870 	return ptu_passed();
871 }
872 
873 static struct ptunit_result event_small_size(struct ptu_decoder_fixture *dfix)
874 {
875 	struct pt_query_decoder *decoder = &dfix->decoder;
876 	struct pt_encoder *encoder = &dfix->encoder;
877 	union {
878 		struct pt_event event;
879 		uint8_t buffer[41];
880 	} variant;
881 	int errcode;
882 
883 	memset(variant.buffer, 0xcd, sizeof(variant.buffer));
884 
885 	pt_encode_tip_pge(encoder, 0ull, pt_ipc_sext_48);
886 
887 	ptu_check(ptu_sync_decoder, decoder);
888 
889 	errcode = pt_qry_event(decoder, &variant.event, 40);
890 	ptu_int_eq(errcode, pts_eos);
891 	ptu_int_eq(variant.event.type, ptev_enabled);
892 	ptu_uint_eq(variant.buffer[40], 0xcd);
893 
894 	return ptu_passed();
895 }
896 
897 static struct ptunit_result event_big_size(struct ptu_decoder_fixture *dfix)
898 {
899 	struct pt_query_decoder *decoder = &dfix->decoder;
900 	struct pt_encoder *encoder = &dfix->encoder;
901 	union {
902 		struct pt_event event;
903 		uint8_t buffer[1024];
904 	} variant;
905 	int errcode;
906 
907 	memset(variant.buffer, 0xcd, sizeof(variant.buffer));
908 
909 	pt_encode_tip_pge(encoder, 0ull, pt_ipc_sext_48);
910 
911 	ptu_check(ptu_sync_decoder, decoder);
912 
913 	errcode = pt_qry_event(decoder, &variant.event, sizeof(variant.buffer));
914 	ptu_int_eq(errcode, pts_eos);
915 	ptu_int_eq(variant.event.type, ptev_enabled);
916 	ptu_uint_eq(variant.buffer[sizeof(variant.event)], 0xcd);
917 
918 	return ptu_passed();
919 }
920 
921 static struct ptunit_result event_empty(struct ptu_decoder_fixture *dfix)
922 {
923 	struct pt_query_decoder *decoder = &dfix->decoder;
924 	struct pt_config *config = &decoder->config;
925 	struct pt_event event;
926 	int errcode;
927 
928 	decoder->pos = config->end;
929 
930 	errcode = pt_qry_event(decoder, &event, sizeof(event));
931 	ptu_int_eq(errcode, -pte_eos);
932 
933 	return ptu_passed();
934 }
935 
936 static struct ptunit_result event_enabled(struct ptu_decoder_fixture *dfix,
937 					  enum pt_ip_compression ipc,
938 					  uint64_t tsc)
939 {
940 	struct pt_query_decoder *decoder = &dfix->decoder;
941 	struct pt_encoder *encoder = &dfix->encoder;
942 	struct pt_packet_ip packet;
943 	struct pt_event event;
944 	int errcode;
945 
946 	packet.ipc = ipc;
947 	packet.ip = pt_dfix_max_ip;
948 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
949 
950 	pt_encode_tip_pge(encoder, packet.ip, packet.ipc);
951 
952 	ptu_check(ptu_sync_decoder, decoder);
953 
954 	errcode = pt_qry_event(decoder, &event, sizeof(event));
955 	if (ipc == pt_ipc_suppressed)
956 		ptu_int_eq(errcode, -pte_bad_packet);
957 	else {
958 		ptu_int_eq(errcode, pts_eos);
959 		ptu_int_eq(event.type, ptev_enabled);
960 		ptu_uint_eq(event.variant.enabled.ip, dfix->last_ip.ip);
961 
962 		if (!tsc)
963 			ptu_int_eq(event.has_tsc, 0);
964 		else {
965 			ptu_int_eq(event.has_tsc, 1);
966 			ptu_uint_eq(event.tsc, tsc);
967 		}
968 	}
969 
970 	return ptu_passed();
971 }
972 
973 static struct ptunit_result
974 event_enabled_cutoff_fail(struct ptu_decoder_fixture *dfix)
975 {
976 	struct pt_query_decoder *decoder = &dfix->decoder;
977 	struct pt_encoder *encoder = &dfix->encoder;
978 	struct pt_event event;
979 	int errcode;
980 
981 	pt_encode_tip_pge(encoder, 0, pt_ipc_sext_48);
982 
983 	ptu_check(cutoff, decoder, encoder);
984 	ptu_check(ptu_sync_decoder, decoder);
985 
986 	errcode = pt_qry_event(decoder, &event, sizeof(event));
987 	ptu_int_eq(errcode, -pte_eos);
988 
989 	return ptu_passed();
990 }
991 
992 static struct ptunit_result event_disabled(struct ptu_decoder_fixture *dfix,
993 					   enum pt_ip_compression ipc,
994 					   uint64_t tsc)
995 {
996 	struct pt_query_decoder *decoder = &dfix->decoder;
997 	struct pt_encoder *encoder = &dfix->encoder;
998 	struct pt_packet_ip packet;
999 	struct pt_event event;
1000 	int errcode;
1001 
1002 	packet.ipc = ipc;
1003 	packet.ip = pt_dfix_sext_ip;
1004 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1005 
1006 	pt_encode_tip_pgd(encoder, packet.ip, packet.ipc);
1007 
1008 	ptu_check(ptu_sync_decoder, decoder);
1009 
1010 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1011 	ptu_int_eq(errcode, pts_eos);
1012 	if (ipc == pt_ipc_suppressed)
1013 		ptu_uint_ne(event.ip_suppressed, 0);
1014 	else {
1015 		ptu_uint_eq(event.ip_suppressed, 0);
1016 		ptu_uint_eq(event.variant.disabled.ip, dfix->last_ip.ip);
1017 	}
1018 	ptu_int_eq(event.type, ptev_disabled);
1019 
1020 	if (!tsc)
1021 		ptu_int_eq(event.has_tsc, 0);
1022 	else {
1023 		ptu_int_eq(event.has_tsc, 1);
1024 		ptu_uint_eq(event.tsc, tsc);
1025 	}
1026 
1027 	return ptu_passed();
1028 }
1029 
1030 static struct ptunit_result
1031 event_disabled_cutoff_fail(struct ptu_decoder_fixture *dfix)
1032 {
1033 	struct pt_query_decoder *decoder = &dfix->decoder;
1034 	struct pt_encoder *encoder = &dfix->encoder;
1035 	struct pt_event event;
1036 	int errcode;
1037 
1038 	pt_encode_tip_pgd(encoder, 0, pt_ipc_update_32);
1039 
1040 	ptu_check(cutoff, decoder, encoder);
1041 	ptu_check(ptu_sync_decoder, decoder);
1042 
1043 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1044 	ptu_int_eq(errcode, -pte_eos);
1045 
1046 	return ptu_passed();
1047 }
1048 
1049 static struct ptunit_result
1050 event_async_disabled(struct ptu_decoder_fixture *dfix,
1051 		     enum pt_ip_compression ipc, uint64_t tsc)
1052 {
1053 	struct pt_query_decoder *decoder = &dfix->decoder;
1054 	struct pt_encoder *encoder = &dfix->encoder;
1055 	struct pt_packet_ip fup, tip;
1056 	struct pt_event event;
1057 	int errcode;
1058 
1059 	fup.ipc = pt_ipc_sext_48;
1060 	fup.ip = pt_dfix_max_ip;
1061 	pt_last_ip_update_ip(&dfix->last_ip, &fup, &dfix->config);
1062 
1063 	tip.ipc = ipc;
1064 	tip.ip = pt_dfix_sext_ip;
1065 	pt_last_ip_update_ip(&dfix->last_ip, &tip, &dfix->config);
1066 
1067 	pt_encode_fup(encoder, fup.ip, fup.ipc);
1068 	pt_encode_tip_pgd(encoder, tip.ip, tip.ipc);
1069 
1070 	ptu_check(ptu_sync_decoder, decoder);
1071 
1072 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1073 	ptu_int_eq(errcode, pts_eos);
1074 	if (ipc == pt_ipc_suppressed)
1075 		ptu_uint_ne(event.ip_suppressed, 0);
1076 	else {
1077 		ptu_uint_eq(event.ip_suppressed, 0);
1078 		ptu_uint_eq(event.variant.async_disabled.ip, dfix->last_ip.ip);
1079 	}
1080 	ptu_int_eq(event.type, ptev_async_disabled);
1081 	ptu_uint_eq(event.variant.async_disabled.at, fup.ip);
1082 
1083 	if (!tsc)
1084 		ptu_int_eq(event.has_tsc, 0);
1085 	else {
1086 		ptu_int_eq(event.has_tsc, 1);
1087 		ptu_uint_eq(event.tsc, tsc);
1088 	}
1089 
1090 	return ptu_passed();
1091 }
1092 
1093 static struct ptunit_result
1094 event_async_disabled_suppressed_fail(struct ptu_decoder_fixture *dfix)
1095 {
1096 	struct pt_query_decoder *decoder = &dfix->decoder;
1097 	struct pt_encoder *encoder = &dfix->encoder;
1098 	struct pt_event event;
1099 	int errcode;
1100 
1101 	pt_encode_fup(encoder, 0, pt_ipc_suppressed);
1102 	pt_encode_tip_pgd(encoder, 0, pt_ipc_sext_48);
1103 
1104 	ptu_check(ptu_sync_decoder, decoder);
1105 
1106 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1107 	ptu_int_eq(errcode, -pte_ip_suppressed);
1108 
1109 	return ptu_passed();
1110 }
1111 
1112 static struct ptunit_result
1113 event_async_disabled_cutoff_fail_a(struct ptu_decoder_fixture *dfix)
1114 {
1115 	struct pt_query_decoder *decoder = &dfix->decoder;
1116 	struct pt_encoder *encoder = &dfix->encoder;
1117 	struct pt_event event;
1118 	uint64_t at = pt_dfix_sext_ip;
1119 	int errcode;
1120 
1121 	pt_encode_fup(encoder, at, pt_ipc_sext_48);
1122 	pt_encode_tip_pgd(encoder, 0, pt_ipc_update_16);
1123 
1124 	ptu_check(cutoff, decoder, encoder);
1125 	ptu_check(ptu_sync_decoder, decoder);
1126 
1127 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1128 	ptu_int_eq(errcode, -pte_eos);
1129 
1130 	return ptu_passed();
1131 }
1132 
1133 static struct ptunit_result
1134 event_async_disabled_cutoff_fail_b(struct ptu_decoder_fixture *dfix)
1135 {
1136 	struct pt_query_decoder *decoder = &dfix->decoder;
1137 	struct pt_encoder *encoder = &dfix->encoder;
1138 	struct pt_event event;
1139 	int errcode;
1140 
1141 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
1142 
1143 	ptu_check(cutoff, decoder, encoder);
1144 	ptu_check(ptu_sync_decoder, decoder);
1145 
1146 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1147 	ptu_int_eq(errcode, -pte_eos);
1148 
1149 	return ptu_passed();
1150 }
1151 
1152 static struct ptunit_result
1153 event_async_branch_suppressed_fail(struct ptu_decoder_fixture *dfix)
1154 {
1155 	struct pt_query_decoder *decoder = &dfix->decoder;
1156 	struct pt_encoder *encoder = &dfix->encoder;
1157 	struct pt_event event;
1158 	int errcode;
1159 
1160 	pt_encode_fup(encoder, 0, pt_ipc_suppressed);
1161 
1162 	ptu_check(ptu_sync_decoder, decoder);
1163 
1164 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1165 	ptu_int_eq(errcode, -pte_ip_suppressed);
1166 
1167 	return ptu_passed();
1168 }
1169 
1170 static struct ptunit_result event_async_branch(struct ptu_decoder_fixture *dfix,
1171 					       enum pt_ip_compression ipc,
1172 					       uint64_t tsc)
1173 {
1174 	struct pt_query_decoder *decoder = &dfix->decoder;
1175 	struct pt_encoder *encoder = &dfix->encoder;
1176 	struct pt_packet_ip fup, tip;
1177 	struct pt_event event;
1178 	int errcode;
1179 
1180 	fup.ipc = pt_ipc_sext_48;
1181 	fup.ip = pt_dfix_max_ip;
1182 	pt_last_ip_update_ip(&dfix->last_ip, &fup, &dfix->config);
1183 
1184 	tip.ipc = ipc;
1185 	tip.ip = pt_dfix_sext_ip;
1186 	pt_last_ip_update_ip(&dfix->last_ip, &tip, &dfix->config);
1187 
1188 	pt_encode_fup(encoder, fup.ip, fup.ipc);
1189 	pt_encode_tip(encoder, tip.ip, tip.ipc);
1190 
1191 	ptu_check(ptu_sync_decoder, decoder);
1192 
1193 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1194 	ptu_int_eq(errcode, pts_eos);
1195 	if (ipc == pt_ipc_suppressed)
1196 		ptu_uint_ne(event.ip_suppressed, 0);
1197 	else {
1198 		ptu_uint_eq(event.ip_suppressed, 0);
1199 		ptu_uint_eq(event.variant.async_branch.to, dfix->last_ip.ip);
1200 	}
1201 	ptu_int_eq(event.type, ptev_async_branch);
1202 	ptu_uint_eq(event.variant.async_branch.from, fup.ip);
1203 
1204 	if (!tsc)
1205 		ptu_int_eq(event.has_tsc, 0);
1206 	else {
1207 		ptu_int_eq(event.has_tsc, 1);
1208 		ptu_uint_eq(event.tsc, tsc);
1209 	}
1210 
1211 	return ptu_passed();
1212 }
1213 
1214 static struct ptunit_result
1215 event_async_branch_cutoff_fail_a(struct ptu_decoder_fixture *dfix)
1216 {
1217 	struct pt_query_decoder *decoder = &dfix->decoder;
1218 	struct pt_encoder *encoder = &dfix->encoder;
1219 	struct pt_event event;
1220 	int errcode;
1221 
1222 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
1223 	pt_encode_tip_pgd(encoder, 0, pt_ipc_update_16);
1224 
1225 	ptu_check(cutoff, decoder, encoder);
1226 	ptu_check(ptu_sync_decoder, decoder);
1227 
1228 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1229 	ptu_int_eq(errcode, -pte_eos);
1230 
1231 	return ptu_passed();
1232 }
1233 
1234 static struct ptunit_result
1235 event_async_branch_cutoff_fail_b(struct ptu_decoder_fixture *dfix)
1236 {
1237 	struct pt_query_decoder *decoder = &dfix->decoder;
1238 	struct pt_encoder *encoder = &dfix->encoder;
1239 	struct pt_event event;
1240 	int errcode;
1241 
1242 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
1243 
1244 	ptu_check(cutoff, decoder, encoder);
1245 	ptu_check(ptu_sync_decoder, decoder);
1246 
1247 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1248 	ptu_int_eq(errcode, -pte_eos);
1249 
1250 	return ptu_passed();
1251 }
1252 
1253 static struct ptunit_result event_paging(struct ptu_decoder_fixture *dfix,
1254 					 uint8_t flags, uint64_t tsc)
1255 {
1256 	struct pt_query_decoder *decoder = &dfix->decoder;
1257 	struct pt_encoder *encoder = &dfix->encoder;
1258 	struct pt_event event;
1259 	uint64_t cr3 = pt_dfix_max_cr3;
1260 	int errcode;
1261 
1262 	pt_encode_pip(encoder, cr3, flags);
1263 
1264 	ptu_check(ptu_sync_decoder, decoder);
1265 
1266 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1267 	ptu_int_eq(errcode, pts_eos);
1268 	ptu_int_eq(event.type, ptev_paging);
1269 	ptu_uint_eq(event.variant.paging.cr3, cr3);
1270 	ptu_uint_eq(event.variant.paging.non_root, (flags & pt_pl_pip_nr) != 0);
1271 
1272 	if (!tsc)
1273 		ptu_int_eq(event.has_tsc, 0);
1274 	else {
1275 		ptu_int_eq(event.has_tsc, 1);
1276 		ptu_uint_eq(event.tsc, tsc);
1277 	}
1278 
1279 	return ptu_passed();
1280 }
1281 
1282 static struct ptunit_result
1283 event_paging_cutoff_fail(struct ptu_decoder_fixture *dfix)
1284 {
1285 	struct pt_query_decoder *decoder = &dfix->decoder;
1286 	struct pt_encoder *encoder = &dfix->encoder;
1287 	struct pt_event event;
1288 	int errcode;
1289 
1290 	pt_encode_pip(encoder, 0, 0);
1291 
1292 	ptu_check(cutoff, decoder, encoder);
1293 	ptu_check(ptu_sync_decoder, decoder);
1294 
1295 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1296 	ptu_int_eq(errcode, -pte_eos);
1297 
1298 	return ptu_passed();
1299 }
1300 
1301 static struct ptunit_result
1302 event_async_paging(struct ptu_decoder_fixture *dfix, uint8_t flags,
1303 		   uint64_t tsc)
1304 {
1305 	struct pt_query_decoder *decoder = &dfix->decoder;
1306 	struct pt_encoder *encoder = &dfix->encoder;
1307 	struct pt_event event;
1308 	uint64_t to = pt_dfix_sext_ip, from = to & ~0xffffull;
1309 	uint64_t cr3 = pt_dfix_max_cr3;
1310 	int errcode;
1311 
1312 	pt_encode_fup(encoder, from, pt_ipc_sext_48);
1313 	pt_encode_pip(encoder, cr3, flags);
1314 	pt_encode_tip(encoder, to, pt_ipc_update_16);
1315 
1316 	ptu_check(ptu_sync_decoder, decoder);
1317 
1318 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1319 	ptu_int_eq(errcode, pts_event_pending);
1320 	ptu_int_eq(event.type, ptev_async_branch);
1321 	ptu_uint_eq(event.variant.async_branch.from, from);
1322 	ptu_uint_eq(event.variant.async_branch.to, to);
1323 
1324 	if (!tsc)
1325 		ptu_int_eq(event.has_tsc, 0);
1326 	else {
1327 		ptu_int_eq(event.has_tsc, 1);
1328 		ptu_uint_eq(event.tsc, tsc);
1329 	}
1330 
1331 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1332 	ptu_int_eq(errcode, pts_eos);
1333 	ptu_int_eq(event.type, ptev_async_paging);
1334 	ptu_uint_eq(event.variant.async_paging.cr3, cr3);
1335 	ptu_uint_eq(event.variant.async_paging.non_root,
1336 		    (flags & pt_pl_pip_nr) != 0);
1337 	ptu_uint_eq(event.variant.async_paging.ip, to);
1338 
1339 	if (!tsc)
1340 		ptu_int_eq(event.has_tsc, 0);
1341 	else {
1342 		ptu_int_eq(event.has_tsc, 1);
1343 		ptu_uint_eq(event.tsc, tsc);
1344 	}
1345 
1346 	return ptu_passed();
1347 }
1348 
1349 static struct ptunit_result
1350 event_async_paging_suppressed(struct ptu_decoder_fixture *dfix, uint8_t flags,
1351 			      uint64_t tsc)
1352 {
1353 	struct pt_query_decoder *decoder = &dfix->decoder;
1354 	struct pt_encoder *encoder = &dfix->encoder;
1355 	struct pt_event event;
1356 	uint64_t from = pt_dfix_sext_ip, cr3 = pt_dfix_max_cr3;
1357 	int errcode;
1358 
1359 	pt_encode_fup(encoder, from, pt_ipc_sext_48);
1360 	pt_encode_pip(encoder, cr3, flags);
1361 	pt_encode_tip(encoder, 0, pt_ipc_suppressed);
1362 
1363 	ptu_check(ptu_sync_decoder, decoder);
1364 
1365 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1366 	ptu_int_eq(errcode, pts_event_pending);
1367 	ptu_uint_ne(event.ip_suppressed, 0);
1368 	ptu_int_eq(event.type, ptev_async_branch);
1369 	ptu_uint_eq(event.variant.async_branch.from, from);
1370 
1371 	if (!tsc)
1372 		ptu_int_eq(event.has_tsc, 0);
1373 	else {
1374 		ptu_int_eq(event.has_tsc, 1);
1375 		ptu_uint_eq(event.tsc, tsc);
1376 	}
1377 
1378 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1379 	ptu_int_eq(errcode, pts_eos);
1380 	ptu_uint_ne(event.ip_suppressed, 0);
1381 	ptu_int_eq(event.type, ptev_async_paging);
1382 	ptu_uint_eq(event.variant.async_paging.cr3, cr3);
1383 	ptu_uint_eq(event.variant.async_paging.non_root,
1384 		    (flags & pt_pl_pip_nr) != 0);
1385 
1386 	if (!tsc)
1387 		ptu_int_eq(event.has_tsc, 0);
1388 	else {
1389 		ptu_int_eq(event.has_tsc, 1);
1390 		ptu_uint_eq(event.tsc, tsc);
1391 	}
1392 
1393 	return ptu_passed();
1394 }
1395 
1396 static struct ptunit_result
1397 event_async_paging_cutoff_fail(struct ptu_decoder_fixture *dfix)
1398 {
1399 	struct pt_query_decoder *decoder = &dfix->decoder;
1400 	struct pt_encoder *encoder = &dfix->encoder;
1401 	struct pt_event event;
1402 	int errcode;
1403 
1404 	pt_encode_fup(encoder, 0, pt_ipc_sext_48);
1405 	pt_encode_pip(encoder, 0, 0);
1406 
1407 	ptu_check(cutoff, decoder, encoder);
1408 	ptu_check(ptu_sync_decoder, decoder);
1409 
1410 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1411 	ptu_int_eq(errcode, -pte_eos);
1412 
1413 	return ptu_passed();
1414 }
1415 
1416 static struct ptunit_result event_overflow_fup(struct ptu_decoder_fixture *dfix,
1417 					       enum pt_ip_compression ipc,
1418 					       uint64_t tsc)
1419 {
1420 	struct pt_query_decoder *decoder = &dfix->decoder;
1421 	struct pt_encoder *encoder = &dfix->encoder;
1422 	struct pt_event event;
1423 	struct pt_packet_ip packet;
1424 	int errcode;
1425 
1426 	packet.ipc = ipc;
1427 	packet.ip = 0xccull;
1428 
1429 	pt_last_ip_init(&dfix->last_ip);
1430 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1431 
1432 	pt_encode_ovf(encoder);
1433 	pt_encode_fup(encoder, packet.ip, packet.ipc);
1434 
1435 	ptu_check(ptu_sync_decoder, decoder);
1436 
1437 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1438 	switch (ipc) {
1439 	case pt_ipc_suppressed:
1440 		ptu_int_eq(errcode, -pte_noip);
1441 		break;
1442 
1443 	case pt_ipc_update_16:
1444 	case pt_ipc_update_32:
1445 	case pt_ipc_update_48:
1446 	case pt_ipc_sext_48:
1447 	case pt_ipc_full:
1448 		ptu_int_eq(errcode, pts_eos);
1449 		ptu_int_eq(event.type, ptev_overflow);
1450 		ptu_uint_eq(event.variant.overflow.ip, dfix->last_ip.ip);
1451 
1452 		if (!tsc)
1453 			ptu_int_eq(event.has_tsc, 0);
1454 		else {
1455 			ptu_int_eq(event.has_tsc, 1);
1456 			ptu_uint_eq(event.tsc, tsc);
1457 		}
1458 		break;
1459 	}
1460 
1461 	return ptu_passed();
1462 }
1463 
1464 static struct ptunit_result
1465 event_overflow_tip_pge(struct ptu_decoder_fixture *dfix,
1466 		       enum pt_ip_compression ipc, uint64_t tsc)
1467 {
1468 	struct pt_query_decoder *decoder = &dfix->decoder;
1469 	struct pt_encoder *encoder = &dfix->encoder;
1470 	struct pt_event event;
1471 	struct pt_packet_ip packet;
1472 	int errcode;
1473 
1474 	packet.ipc = ipc;
1475 	packet.ip = 0xccull;
1476 
1477 	pt_last_ip_init(&dfix->last_ip);
1478 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1479 
1480 	pt_encode_ovf(encoder);
1481 	pt_encode_tip_pge(encoder, packet.ip, packet.ipc);
1482 
1483 	ptu_check(ptu_sync_decoder, decoder);
1484 
1485 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1486 	ptu_int_eq(errcode, pts_event_pending);
1487 	ptu_int_eq(event.type, ptev_overflow);
1488 	ptu_uint_ne(event.ip_suppressed, 0);
1489 
1490 	if (!tsc)
1491 		ptu_int_eq(event.has_tsc, 0);
1492 	else {
1493 		ptu_int_eq(event.has_tsc, 1);
1494 		ptu_uint_eq(event.tsc, tsc);
1495 	}
1496 
1497 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1498 	switch (ipc) {
1499 	case pt_ipc_suppressed:
1500 		ptu_int_eq(errcode, -pte_bad_packet);
1501 		break;
1502 
1503 	case pt_ipc_update_16:
1504 	case pt_ipc_update_32:
1505 	case pt_ipc_update_48:
1506 	case pt_ipc_sext_48:
1507 	case pt_ipc_full:
1508 		ptu_int_eq(errcode, pts_eos);
1509 		ptu_int_eq(event.type, ptev_enabled);
1510 		ptu_uint_eq(event.variant.enabled.ip, dfix->last_ip.ip);
1511 
1512 		if (!tsc)
1513 			ptu_int_eq(event.has_tsc, 0);
1514 		else {
1515 			ptu_int_eq(event.has_tsc, 1);
1516 			ptu_uint_eq(event.tsc, tsc);
1517 		}
1518 		break;
1519 	}
1520 
1521 	return ptu_passed();
1522 }
1523 
1524 static struct ptunit_result
1525 event_overflow_cutoff_fail(struct ptu_decoder_fixture *dfix)
1526 {
1527 	struct pt_query_decoder *decoder = &dfix->decoder;
1528 	struct pt_encoder *encoder = &dfix->encoder;
1529 	struct pt_event event;
1530 	int errcode;
1531 
1532 	pt_encode_ovf(encoder);
1533 
1534 	ptu_check(cutoff, decoder, encoder);
1535 	ptu_check(ptu_sync_decoder, decoder);
1536 
1537 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1538 	ptu_int_eq(errcode, -pte_eos);
1539 
1540 	return ptu_passed();
1541 }
1542 
1543 static struct ptunit_result event_stop(struct ptu_decoder_fixture *dfix,
1544 				       uint64_t tsc)
1545 {
1546 	struct pt_query_decoder *decoder = &dfix->decoder;
1547 	struct pt_encoder *encoder = &dfix->encoder;
1548 	struct pt_event event;
1549 	int errcode;
1550 
1551 	pt_encode_stop(encoder);
1552 
1553 	ptu_sync_decoder(decoder);
1554 
1555 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1556 	ptu_int_eq(errcode, pts_eos);
1557 	ptu_int_eq(event.type, ptev_stop);
1558 
1559 	if (!tsc)
1560 		ptu_int_eq(event.has_tsc, 0);
1561 	else {
1562 		ptu_int_eq(event.has_tsc, 1);
1563 		ptu_uint_eq(event.tsc, tsc);
1564 	}
1565 
1566 	return ptu_passed();
1567 }
1568 
1569 static struct ptunit_result
1570 event_exec_mode_tip(struct ptu_decoder_fixture *dfix,
1571 		    enum pt_ip_compression ipc, uint64_t tsc)
1572 {
1573 	struct pt_query_decoder *decoder = &dfix->decoder;
1574 	struct pt_encoder *encoder = &dfix->encoder;
1575 	enum pt_exec_mode mode = ptem_16bit;
1576 	struct pt_packet_ip packet;
1577 	struct pt_event event;
1578 	uint64_t addr = 0ull;
1579 	int errcode;
1580 
1581 	packet.ipc = ipc;
1582 	packet.ip = pt_dfix_max_ip;
1583 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1584 
1585 	pt_encode_mode_exec(encoder, mode);
1586 	pt_encode_tip(encoder, packet.ip, packet.ipc);
1587 
1588 	ptu_check(ptu_sync_decoder, decoder);
1589 
1590 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1591 	ptu_int_eq(errcode, 0);
1592 	if (ipc == pt_ipc_suppressed)
1593 		ptu_uint_ne(event.ip_suppressed, 0);
1594 	else {
1595 		ptu_uint_eq(event.ip_suppressed, 0);
1596 		ptu_uint_eq(event.variant.exec_mode.ip, dfix->last_ip.ip);
1597 	}
1598 	ptu_int_eq(event.type, ptev_exec_mode);
1599 	ptu_int_eq(event.variant.exec_mode.mode, mode);
1600 
1601 	if (!tsc)
1602 		ptu_int_eq(event.has_tsc, 0);
1603 	else {
1604 		ptu_int_eq(event.has_tsc, 1);
1605 		ptu_uint_eq(event.tsc, tsc);
1606 	}
1607 
1608 	errcode = pt_qry_indirect_branch(decoder, &addr);
1609 	if (ipc == pt_ipc_suppressed)
1610 		ptu_int_eq(errcode, pts_ip_suppressed | pts_eos);
1611 	else {
1612 		ptu_int_eq(errcode, pts_eos);
1613 		ptu_uint_eq(addr, dfix->last_ip.ip);
1614 	}
1615 
1616 	return ptu_passed();
1617 }
1618 
1619 static struct ptunit_result
1620 event_exec_mode_tip_cutoff_fail(struct ptu_decoder_fixture *dfix)
1621 {
1622 	struct pt_query_decoder *decoder = &dfix->decoder;
1623 	struct pt_encoder *encoder = &dfix->encoder;
1624 	struct pt_event event;
1625 	int errcode;
1626 
1627 	pt_encode_mode_exec(encoder, ptem_32bit);
1628 	pt_encode_tip(encoder, 0, pt_ipc_update_16);
1629 
1630 	ptu_check(cutoff, decoder, encoder);
1631 	ptu_check(ptu_sync_decoder, decoder);
1632 
1633 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1634 	ptu_int_eq(errcode, -pte_eos);
1635 
1636 	return ptu_passed();
1637 }
1638 
1639 static struct ptunit_result
1640 event_exec_mode_tip_pge(struct ptu_decoder_fixture *dfix,
1641 			enum pt_ip_compression ipc, uint64_t tsc)
1642 {
1643 	struct pt_query_decoder *decoder = &dfix->decoder;
1644 	struct pt_encoder *encoder = &dfix->encoder;
1645 	enum pt_exec_mode mode = ptem_16bit;
1646 	struct pt_packet_ip packet;
1647 	struct pt_event event;
1648 	uint64_t addr = 0ull;
1649 	int errcode;
1650 
1651 	packet.ipc = ipc;
1652 	packet.ip = pt_dfix_max_ip;
1653 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1654 
1655 	pt_encode_mode_exec(encoder, mode);
1656 	pt_encode_tip_pge(encoder, packet.ip, packet.ipc);
1657 
1658 	ptu_check(ptu_sync_decoder, decoder);
1659 	decoder->enabled = 0;
1660 
1661 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1662 	if (ipc == pt_ipc_suppressed) {
1663 		ptu_int_eq(errcode, -pte_bad_packet);
1664 		ptu_uint_eq(addr, 0ull);
1665 	} else {
1666 		ptu_int_eq(errcode, pts_event_pending);
1667 		ptu_int_eq(event.type, ptev_enabled);
1668 		ptu_uint_eq(event.variant.enabled.ip, dfix->last_ip.ip);
1669 
1670 		if (!tsc)
1671 			ptu_int_eq(event.has_tsc, 0);
1672 		else {
1673 			ptu_int_eq(event.has_tsc, 1);
1674 			ptu_uint_eq(event.tsc, tsc);
1675 		}
1676 
1677 		errcode = pt_qry_event(decoder, &event, sizeof(event));
1678 		ptu_int_eq(errcode, pts_eos);
1679 		ptu_int_eq(event.type, ptev_exec_mode);
1680 		ptu_int_eq(event.variant.exec_mode.mode, mode);
1681 		ptu_uint_eq(event.variant.exec_mode.ip, dfix->last_ip.ip);
1682 
1683 		if (!tsc)
1684 			ptu_int_eq(event.has_tsc, 0);
1685 		else {
1686 			ptu_int_eq(event.has_tsc, 1);
1687 			ptu_uint_eq(event.tsc, tsc);
1688 		}
1689 	}
1690 
1691 	return ptu_passed();
1692 }
1693 
1694 static struct ptunit_result
1695 event_exec_mode_tip_pge_cutoff_fail(struct ptu_decoder_fixture *dfix)
1696 {
1697 	struct pt_query_decoder *decoder = &dfix->decoder;
1698 	struct pt_encoder *encoder = &dfix->encoder;
1699 	struct pt_event event;
1700 	int errcode;
1701 
1702 	pt_encode_mode_exec(encoder, ptem_16bit);
1703 	pt_encode_tip_pge(encoder, 0, pt_ipc_sext_48);
1704 
1705 	ptu_check(cutoff, decoder, encoder);
1706 	ptu_check(ptu_sync_decoder, decoder);
1707 
1708 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1709 	ptu_int_eq(errcode, -pte_eos);
1710 
1711 	return ptu_passed();
1712 }
1713 
1714 static struct ptunit_result
1715 event_exec_mode_cutoff_fail(struct ptu_decoder_fixture *dfix)
1716 {
1717 	struct pt_query_decoder *decoder = &dfix->decoder;
1718 	struct pt_encoder *encoder = &dfix->encoder;
1719 	struct pt_event event;
1720 	int errcode;
1721 
1722 	pt_encode_mode_exec(encoder, ptem_64bit);
1723 
1724 	ptu_check(cutoff, decoder, encoder);
1725 	ptu_check(ptu_sync_decoder, decoder);
1726 
1727 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1728 	ptu_int_eq(errcode, -pte_eos);
1729 
1730 	return ptu_passed();
1731 }
1732 
1733 static struct ptunit_result event_tsx_fup(struct ptu_decoder_fixture *dfix,
1734 					  enum pt_ip_compression ipc,
1735 					  uint8_t flags, uint64_t tsc)
1736 {
1737 	struct pt_query_decoder *decoder = &dfix->decoder;
1738 	struct pt_encoder *encoder = &dfix->encoder;
1739 	struct pt_packet_ip fup, tip;
1740 	struct pt_event event;
1741 	uint64_t addr = 0;
1742 	int errcode;
1743 
1744 	fup.ipc = ipc;
1745 	fup.ip = pt_dfix_max_ip;
1746 	pt_last_ip_update_ip(&dfix->last_ip, &fup, &dfix->config);
1747 
1748 	tip.ipc = pt_ipc_sext_48;
1749 	tip.ip = pt_dfix_sext_ip;
1750 
1751 	pt_encode_mode_tsx(encoder, flags);
1752 	pt_encode_fup(encoder, fup.ip, fup.ipc);
1753 	pt_encode_tip(encoder, tip.ip, tip.ipc);
1754 
1755 	ptu_check(ptu_sync_decoder, decoder);
1756 
1757 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1758 	ptu_int_eq(errcode, 0);
1759 	if (ipc == pt_ipc_suppressed)
1760 		ptu_uint_ne(event.ip_suppressed, 0);
1761 	else {
1762 		ptu_uint_eq(event.ip_suppressed, 0);
1763 		ptu_uint_eq(event.variant.tsx.ip, dfix->last_ip.ip);
1764 	}
1765 	ptu_int_eq(event.type, ptev_tsx);
1766 	ptu_int_eq(event.variant.tsx.speculative,
1767 		   (flags & pt_mob_tsx_intx) != 0);
1768 	ptu_int_eq(event.variant.tsx.aborted,
1769 		   (flags & pt_mob_tsx_abrt) != 0);
1770 
1771 	if (!tsc)
1772 		ptu_int_eq(event.has_tsc, 0);
1773 	else {
1774 		ptu_int_eq(event.has_tsc, 1);
1775 		ptu_uint_eq(event.tsc, tsc);
1776 	}
1777 
1778 	errcode = pt_qry_indirect_branch(decoder, &addr);
1779 	ptu_int_eq(errcode, pts_eos);
1780 	ptu_uint_eq(addr, tip.ip);
1781 
1782 	return ptu_passed();
1783 }
1784 
1785 static struct ptunit_result
1786 event_tsx_fup_cutoff_fail(struct ptu_decoder_fixture *dfix)
1787 {
1788 	struct pt_query_decoder *decoder = &dfix->decoder;
1789 	struct pt_encoder *encoder = &dfix->encoder;
1790 	struct pt_event event;
1791 	int errcode;
1792 
1793 	pt_encode_mode_tsx(encoder, 0);
1794 	pt_encode_fup(encoder, 0, pt_ipc_update_16);
1795 
1796 	ptu_check(cutoff, decoder, encoder);
1797 	ptu_check(ptu_sync_decoder, decoder);
1798 
1799 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1800 	ptu_int_eq(errcode, -pte_eos);
1801 
1802 	return ptu_passed();
1803 }
1804 
1805 static struct ptunit_result
1806 event_tsx_cutoff_fail(struct ptu_decoder_fixture *dfix)
1807 {
1808 	struct pt_query_decoder *decoder = &dfix->decoder;
1809 	struct pt_encoder *encoder = &dfix->encoder;
1810 	struct pt_event event;
1811 	int errcode;
1812 
1813 	pt_encode_mode_tsx(encoder, 0);
1814 
1815 	ptu_check(cutoff, decoder, encoder);
1816 	ptu_check(ptu_sync_decoder, decoder);
1817 
1818 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1819 	ptu_int_eq(errcode, -pte_eos);
1820 
1821 	return ptu_passed();
1822 }
1823 
1824 static struct ptunit_result
1825 event_skip_tip_fail(struct ptu_decoder_fixture *dfix)
1826 {
1827 	struct pt_query_decoder *decoder = &dfix->decoder;
1828 	struct pt_encoder *encoder = &dfix->encoder;
1829 	struct pt_event event;
1830 	const uint8_t *pos;
1831 	int errcode;
1832 
1833 	pos = encoder->pos;
1834 	pt_encode_tip(encoder, 0, pt_ipc_sext_48);
1835 	/* We omit the actual event - we don't get that far, anyway. */
1836 
1837 	ptu_check(ptu_sync_decoder, decoder);
1838 
1839 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1840 	ptu_int_eq(errcode, -pte_bad_query);
1841 	ptu_ptr_eq(decoder->pos, pos);
1842 
1843 	return ptu_passed();
1844 }
1845 
1846 static struct ptunit_result
1847 event_skip_tnt_8_fail(struct ptu_decoder_fixture *dfix)
1848 {
1849 	struct pt_query_decoder *decoder = &dfix->decoder;
1850 	struct pt_encoder *encoder = &dfix->encoder;
1851 	struct pt_event event;
1852 	int errcode;
1853 
1854 	pt_encode_tnt_8(encoder, 0, 1);
1855 	pt_encode_tnt_8(encoder, 0, 1);
1856 	/* We omit the actual event - we don't get that far, anyway. */
1857 
1858 	ptu_check(ptu_sync_decoder, decoder);
1859 
1860 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1861 	ptu_int_eq(errcode, -pte_bad_query);
1862 	/* The fail position depends on the fixture's header. */
1863 
1864 	return ptu_passed();
1865 }
1866 
1867 static struct ptunit_result
1868 event_skip_tnt_64_fail(struct ptu_decoder_fixture *dfix)
1869 {
1870 	struct pt_query_decoder *decoder = &dfix->decoder;
1871 	struct pt_encoder *encoder = &dfix->encoder;
1872 	struct pt_event event;
1873 	int errcode;
1874 
1875 	pt_encode_tnt_64(encoder, 0, 1);
1876 	pt_encode_tnt_64(encoder, 0, 1);
1877 	/* We omit the actual event - we don't get that far, anyway. */
1878 
1879 	ptu_check(ptu_sync_decoder, decoder);
1880 
1881 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1882 	ptu_int_eq(errcode, -pte_bad_query);
1883 	/* The fail position depends on the fixture's header. */
1884 
1885 	return ptu_passed();
1886 }
1887 
1888 static struct ptunit_result sync_event(struct ptu_decoder_fixture *dfix,
1889 				       enum pt_ip_compression ipc)
1890 {
1891 	struct pt_query_decoder *decoder = &dfix->decoder;
1892 	struct pt_encoder *encoder = &dfix->encoder;
1893 	struct pt_packet_ip packet;
1894 	struct pt_event event;
1895 	uint64_t addr = 0ull;
1896 	int errcode;
1897 
1898 	packet.ipc = ipc;
1899 	packet.ip = 0xccull;
1900 
1901 	pt_last_ip_init(&dfix->last_ip);
1902 	pt_last_ip_update_ip(&dfix->last_ip, &packet, &dfix->config);
1903 
1904 	pt_encode_psb(encoder);
1905 	pt_encode_mode_tsx(encoder, pt_mob_tsx_intx);
1906 	pt_encode_fup(encoder, packet.ip, packet.ipc);
1907 	pt_encode_psbend(encoder);
1908 
1909 	errcode = pt_qry_sync_forward(decoder, &addr);
1910 	switch (ipc) {
1911 	case pt_ipc_suppressed:
1912 		ptu_int_eq(errcode, (pts_event_pending | pts_ip_suppressed));
1913 		break;
1914 
1915 	case pt_ipc_update_16:
1916 	case pt_ipc_update_32:
1917 	case pt_ipc_update_48:
1918 	case pt_ipc_sext_48:
1919 	case pt_ipc_full:
1920 		ptu_int_eq(errcode, pts_event_pending);
1921 		ptu_uint_eq(addr, dfix->last_ip.ip);
1922 		break;
1923 	}
1924 
1925 	errcode = pt_qry_event(decoder, &event, sizeof(event));
1926 	ptu_int_eq(errcode, pts_eos);
1927 	ptu_uint_ne(event.status_update, 0);
1928 	if (ipc == pt_ipc_suppressed)
1929 		ptu_uint_ne(event.ip_suppressed, 0);
1930 	else {
1931 		ptu_uint_eq(event.ip_suppressed, 0);
1932 		ptu_uint_eq(event.variant.tsx.ip, dfix->last_ip.ip);
1933 	}
1934 	ptu_int_eq(event.type, ptev_tsx);
1935 	ptu_int_eq(event.variant.tsx.speculative, 1);
1936 	ptu_int_eq(event.variant.tsx.aborted, 0);
1937 	ptu_int_eq(event.has_tsc, 0);
1938 
1939 	return ptu_passed();
1940 }
1941 
1942 static struct ptunit_result
1943 sync_event_cutoff_fail(struct ptu_decoder_fixture *dfix)
1944 {
1945 	struct pt_query_decoder *decoder = &dfix->decoder;
1946 	struct pt_encoder *encoder = &dfix->encoder;
1947 	uint64_t addr;
1948 	int errcode;
1949 
1950 	pt_encode_psb(encoder);
1951 	pt_encode_psbend(encoder);
1952 
1953 	ptu_check(cutoff, decoder, encoder);
1954 
1955 	errcode = pt_qry_sync_forward(decoder, &addr);
1956 	ptu_int_eq(errcode, -pte_eos);
1957 
1958 	return ptu_passed();
1959 }
1960 
1961 static struct ptunit_result
1962 sync_event_incomplete_fail(struct ptu_decoder_fixture *dfix)
1963 {
1964 	struct pt_query_decoder *decoder = &dfix->decoder;
1965 	struct pt_encoder *encoder = &dfix->encoder;
1966 	uint64_t addr;
1967 	int errcode;
1968 
1969 	pt_encode_psb(encoder);
1970 
1971 	errcode = pt_qry_sync_forward(decoder, &addr);
1972 	ptu_int_eq(errcode, -pte_eos);
1973 
1974 	return ptu_passed();
1975 }
1976 
1977 static struct ptunit_result sync_ovf_event(struct ptu_decoder_fixture *dfix,
1978 					   enum pt_ip_compression ipc)
1979 {
1980 	struct pt_query_decoder *decoder = &dfix->decoder;
1981 	struct pt_encoder *encoder = &dfix->encoder;
1982 	struct pt_packet_ip fup, ovf;
1983 	struct pt_event event;
1984 	uint64_t addr = 0;
1985 	int errcode;
1986 
1987 	fup.ipc = pt_ipc_sext_48;
1988 	fup.ip = pt_dfix_max_ip;
1989 
1990 	ovf.ipc = ipc;
1991 	ovf.ip = 0xccull;
1992 
1993 	pt_last_ip_init(&dfix->last_ip);
1994 	pt_last_ip_update_ip(&dfix->last_ip, &ovf, &dfix->config);
1995 
1996 	pt_encode_psb(encoder);
1997 	pt_encode_fup(encoder, fup.ip, fup.ipc);
1998 	pt_encode_mode_tsx(encoder, 0);
1999 	pt_encode_tsc(encoder, 0x1000);
2000 	pt_encode_ovf(encoder);
2001 	pt_encode_fup(encoder, ovf.ip, ovf.ipc);
2002 
2003 	errcode = pt_qry_sync_forward(decoder, &addr);
2004 	ptu_int_eq(errcode, pts_event_pending);
2005 	ptu_uint_eq(addr, fup.ip);
2006 
2007 	errcode = pt_qry_event(decoder, &event, sizeof(event));
2008 	ptu_int_eq(errcode, pts_event_pending);
2009 	ptu_uint_ne(event.status_update, 0);
2010 	ptu_int_eq(event.type, ptev_tsx);
2011 	ptu_int_eq(event.variant.tsx.speculative, 0);
2012 	ptu_int_eq(event.variant.tsx.aborted, 0);
2013 	ptu_uint_eq(event.variant.tsx.ip, fup.ip);
2014 	ptu_int_eq(event.has_tsc, 1);
2015 	ptu_uint_eq(event.tsc, 0x1000);
2016 
2017 	errcode = pt_qry_event(decoder, &event, sizeof(event));
2018 	switch (ipc) {
2019 	case pt_ipc_suppressed:
2020 		ptu_int_eq(errcode, -pte_noip);
2021 		return ptu_passed();
2022 
2023 	case pt_ipc_update_16:
2024 	case pt_ipc_update_32:
2025 	case pt_ipc_update_48:
2026 	case pt_ipc_sext_48:
2027 	case pt_ipc_full:
2028 		ptu_int_eq(errcode, pts_eos);
2029 		ptu_int_eq(event.type, ptev_overflow);
2030 		ptu_uint_eq(event.variant.overflow.ip, dfix->last_ip.ip);
2031 		ptu_int_eq(event.has_tsc, 1);
2032 		ptu_uint_eq(event.tsc, 0x1000);
2033 		break;
2034 	}
2035 
2036 	return ptu_passed();
2037 }
2038 
2039 static struct ptunit_result
2040 sync_ovf_event_cutoff_fail(struct ptu_decoder_fixture *dfix)
2041 {
2042 	struct pt_query_decoder *decoder = &dfix->decoder;
2043 	struct pt_encoder *encoder = &dfix->encoder;
2044 	uint64_t addr;
2045 	int errcode;
2046 
2047 	pt_encode_psb(encoder);
2048 	pt_encode_ovf(encoder);
2049 
2050 	ptu_check(cutoff, decoder, encoder);
2051 
2052 	errcode = pt_qry_sync_forward(decoder, &addr);
2053 	ptu_int_eq(errcode, -pte_eos);
2054 
2055 	return ptu_passed();
2056 }
2057 
2058 static struct ptunit_result time_null_fail(struct ptu_decoder_fixture *dfix)
2059 {
2060 	struct pt_query_decoder *decoder = &dfix->decoder;
2061 	uint64_t tsc;
2062 	int errcode;
2063 
2064 	errcode = pt_qry_time(NULL, NULL, NULL, NULL);
2065 	ptu_int_eq(errcode, -pte_invalid);
2066 
2067 	errcode = pt_qry_time(decoder, NULL, NULL, NULL);
2068 	ptu_int_eq(errcode, -pte_invalid);
2069 
2070 	errcode = pt_qry_time(NULL, &tsc, NULL, NULL);
2071 	ptu_int_eq(errcode, -pte_invalid);
2072 
2073 	return ptu_passed();
2074 }
2075 
2076 static struct ptunit_result time_initial(struct ptu_decoder_fixture *dfix)
2077 {
2078 	struct pt_query_decoder *decoder = &dfix->decoder;
2079 	uint64_t tsc;
2080 	int errcode;
2081 
2082 	errcode = pt_qry_time(decoder, &tsc, NULL, NULL);
2083 	ptu_int_eq(errcode, -pte_no_time);
2084 
2085 	return ptu_passed();
2086 }
2087 
2088 static struct ptunit_result time(struct ptu_decoder_fixture *dfix)
2089 {
2090 	struct pt_query_decoder *decoder = &dfix->decoder;
2091 	uint64_t tsc, exp;
2092 	int errcode;
2093 
2094 	exp = 0x11223344556677ull;
2095 
2096 	decoder->last_time.have_tsc = 1;
2097 	decoder->last_time.tsc = exp;
2098 
2099 	errcode = pt_qry_time(decoder, &tsc, NULL, NULL);
2100 	ptu_int_eq(errcode, 0);
2101 	ptu_uint_eq(tsc, exp);
2102 
2103 	return ptu_passed();
2104 }
2105 
2106 static struct ptunit_result cbr_null(struct ptu_decoder_fixture *dfix)
2107 {
2108 	struct pt_query_decoder *decoder = &dfix->decoder;
2109 	uint32_t cbr;
2110 	int errcode;
2111 
2112 	errcode = pt_qry_core_bus_ratio(NULL, NULL);
2113 	ptu_int_eq(errcode, -pte_invalid);
2114 
2115 	errcode = pt_qry_core_bus_ratio(decoder, NULL);
2116 	ptu_int_eq(errcode, -pte_invalid);
2117 
2118 	errcode = pt_qry_core_bus_ratio(NULL, &cbr);
2119 	ptu_int_eq(errcode, -pte_invalid);
2120 
2121 	return ptu_passed();
2122 }
2123 
2124 static struct ptunit_result cbr_initial(struct ptu_decoder_fixture *dfix)
2125 {
2126 	struct pt_query_decoder *decoder = &dfix->decoder;
2127 	uint32_t cbr;
2128 	int errcode;
2129 
2130 	errcode = pt_qry_core_bus_ratio(decoder, &cbr);
2131 	ptu_int_eq(errcode, -pte_no_cbr);
2132 
2133 	return ptu_passed();
2134 }
2135 
2136 static struct ptunit_result cbr(struct ptu_decoder_fixture *dfix)
2137 {
2138 	struct pt_query_decoder *decoder = &dfix->decoder;
2139 	uint32_t cbr;
2140 	int errcode;
2141 
2142 	decoder->last_time.have_cbr = 1;
2143 	decoder->last_time.cbr = 42;
2144 
2145 	errcode = pt_qry_core_bus_ratio(decoder, &cbr);
2146 	ptu_int_eq(errcode, 0);
2147 	ptu_uint_eq(cbr, 42);
2148 
2149 	return ptu_passed();
2150 }
2151 
2152 /* Test that end-of-stream is indicated correctly when the stream ends with a
2153  * partial non-query-relevant packet.
2154  */
2155 static struct ptunit_result indir_cyc_cutoff(struct ptu_decoder_fixture *dfix)
2156 {
2157 	struct pt_query_decoder *decoder = &dfix->decoder;
2158 	struct pt_encoder *encoder = &dfix->encoder;
2159 	uint64_t ip;
2160 	int errcode;
2161 
2162 	pt_encode_tip(encoder, 0xa000ull, pt_ipc_full);
2163 	pt_encode_cyc(encoder, 0xfff);
2164 
2165 	ptu_check(cutoff, decoder, encoder);
2166 	ptu_check(ptu_sync_decoder, decoder);
2167 
2168 	errcode = pt_qry_indirect_branch(decoder, &ip);
2169 	ptu_int_eq(errcode, pts_eos);
2170 
2171 	return ptu_passed();
2172 }
2173 
2174 /* Test that end-of-stream is indicated correctly when the stream ends with a
2175  * partial non-query-relevant packet.
2176  */
2177 static struct ptunit_result cond_cyc_cutoff(struct ptu_decoder_fixture *dfix)
2178 {
2179 	struct pt_query_decoder *decoder = &dfix->decoder;
2180 	struct pt_encoder *encoder = &dfix->encoder;
2181 	int errcode, taken;
2182 
2183 	pt_encode_tnt_8(encoder, 0, 1);
2184 	pt_encode_cyc(encoder, 0xfff);
2185 
2186 	ptu_check(cutoff, decoder, encoder);
2187 	ptu_check(ptu_sync_decoder, decoder);
2188 
2189 	errcode = pt_qry_cond_branch(decoder, &taken);
2190 	ptu_int_eq(errcode, pts_eos);
2191 
2192 	return ptu_passed();
2193 }
2194 
2195 /* Test that end-of-stream is indicated correctly when the stream ends with a
2196  * partial non-query-relevant packet.
2197  */
2198 static struct ptunit_result event_cyc_cutoff(struct ptu_decoder_fixture *dfix)
2199 {
2200 	struct pt_query_decoder *decoder = &dfix->decoder;
2201 	struct pt_encoder *encoder = &dfix->encoder;
2202 	struct pt_event event;
2203 	int errcode;
2204 
2205 	pt_encode_tip_pgd(encoder, 0ull, pt_ipc_full);
2206 	pt_encode_cyc(encoder, 0xffff);
2207 
2208 	ptu_check(cutoff, decoder, encoder);
2209 	ptu_check(ptu_sync_decoder, decoder);
2210 
2211 	errcode = pt_qry_event(decoder, &event, sizeof(event));
2212 	ptu_int_eq(errcode, pts_eos);
2213 
2214 	return ptu_passed();
2215 }
2216 
2217 static struct ptunit_result ptu_dfix_init(struct ptu_decoder_fixture *dfix)
2218 {
2219 	struct pt_config *config = &dfix->config;
2220 	int errcode;
2221 
2222 	(void) memset(dfix->buffer, 0, sizeof(dfix->buffer));
2223 
2224 	pt_config_init(config);
2225 
2226 	config->begin = dfix->buffer;
2227 	config->end = dfix->buffer + sizeof(dfix->buffer);
2228 
2229 	errcode = pt_encoder_init(&dfix->encoder, config);
2230 	ptu_int_eq(errcode, 0);
2231 
2232 	errcode = pt_qry_decoder_init(&dfix->decoder, config);
2233 	ptu_int_eq(errcode, 0);
2234 
2235 	dfix->decoder.ip.ip = pt_dfix_bad_ip;
2236 	dfix->decoder.ip.have_ip = 1;
2237 	dfix->decoder.ip.suppressed = 0;
2238 
2239 	dfix->last_ip = dfix->decoder.ip;
2240 
2241 	if (dfix->header)
2242 		dfix->header(dfix);
2243 
2244 	return ptu_passed();
2245 }
2246 
2247 static struct ptunit_result ptu_dfix_fini(struct ptu_decoder_fixture *dfix)
2248 {
2249 	pt_qry_decoder_fini(&dfix->decoder);
2250 	pt_encoder_fini(&dfix->encoder);
2251 
2252 	return ptu_passed();
2253 }
2254 
2255 /* Synchronize the decoder at the beginnig of an empty buffer. */
2256 static struct ptunit_result
2257 ptu_dfix_header_sync(struct ptu_decoder_fixture *dfix)
2258 {
2259 	struct pt_query_decoder *decoder = &dfix->decoder;
2260 
2261 	/* Synchronize the decoder at the beginning of the buffer. */
2262 	decoder->pos = decoder->config.begin;
2263 
2264 	return ptu_passed();
2265 }
2266 
2267 /* Synchronize the decoder at the beginnig of a buffer containing packets that
2268  * should be skipped for unconditional indirect branch queries.
2269  */
2270 static struct ptunit_result
2271 ptu_dfix_header_indir(struct ptu_decoder_fixture *dfix)
2272 {
2273 	struct pt_query_decoder *decoder = &dfix->decoder;
2274 	struct pt_encoder *encoder = &dfix->encoder;
2275 
2276 	pt_encode_pad(encoder);
2277 	pt_encode_mtc(encoder, 1);
2278 	pt_encode_pad(encoder);
2279 	pt_encode_tsc(encoder, 0);
2280 
2281 	/* Synchronize the decoder at the beginning of the buffer. */
2282 	decoder->pos = decoder->config.begin;
2283 
2284 	return ptu_passed();
2285 }
2286 
2287 /* Synchronize the decoder at the beginnig of a buffer containing packets that
2288  * should be skipped for unconditional indirect branch queries including a PSB.
2289  */
2290 static struct ptunit_result
2291 ptu_dfix_header_indir_psb(struct ptu_decoder_fixture *dfix)
2292 {
2293 	struct pt_query_decoder *decoder = &dfix->decoder;
2294 	struct pt_encoder *encoder = &dfix->encoder;
2295 
2296 	/* The psb must be empty since the tests won't skip status events.
2297 	 * On the other hand, we do need to provide an address since tests
2298 	 * may want to update last-ip, which requires a last-ip, of course.
2299 	 */
2300 	pt_encode_pad(encoder);
2301 	pt_encode_tsc(encoder, 0);
2302 	pt_encode_psb(encoder);
2303 	pt_encode_mtc(encoder, 1);
2304 	pt_encode_pad(encoder);
2305 	pt_encode_tsc(encoder, 0);
2306 	pt_encode_fup(encoder, pt_dfix_sext_ip, pt_ipc_sext_48);
2307 	pt_encode_psbend(encoder);
2308 	pt_encode_mtc(encoder, 1);
2309 	pt_encode_pad(encoder);
2310 
2311 	/* Synchronize the decoder at the beginning of the buffer. */
2312 	decoder->pos = decoder->config.begin;
2313 
2314 	return ptu_passed();
2315 }
2316 
2317 /* Synchronize the decoder at the beginnig of a buffer containing packets that
2318  * should be skipped for conditional branch queries.
2319  */
2320 static struct ptunit_result
2321 ptu_dfix_header_cond(struct ptu_decoder_fixture *dfix)
2322 {
2323 	struct pt_query_decoder *decoder = &dfix->decoder;
2324 	struct pt_encoder *encoder = &dfix->encoder;
2325 
2326 	/* The psb must be empty since the tests won't skip status events.
2327 	 * On the other hand, we do need to provide an address since tests
2328 	 * may want to update last-ip, which requires a last-ip, of course.
2329 	 */
2330 	pt_encode_pad(encoder);
2331 	pt_encode_mtc(encoder, 1);
2332 	pt_encode_psb(encoder);
2333 	pt_encode_tsc(encoder, 0);
2334 	pt_encode_pad(encoder);
2335 	pt_encode_fup(encoder, pt_dfix_sext_ip, pt_ipc_sext_48);
2336 	pt_encode_psbend(encoder);
2337 	pt_encode_pad(encoder);
2338 	pt_encode_tsc(encoder, 0);
2339 	pt_encode_pad(encoder);
2340 
2341 	/* Synchronize the decoder at the beginning of the buffer. */
2342 	decoder->pos = decoder->config.begin;
2343 
2344 	return ptu_passed();
2345 }
2346 
2347 /* Synchronize the decoder at the beginnig of a buffer containing packets that
2348  * should be skipped for event queries.
2349  */
2350 static struct ptunit_result
2351 ptu_dfix_header_event(struct ptu_decoder_fixture *dfix)
2352 {
2353 	struct pt_query_decoder *decoder = &dfix->decoder;
2354 	struct pt_encoder *encoder = &dfix->encoder;
2355 
2356 	pt_encode_pad(encoder);
2357 	pt_encode_mtc(encoder, 1);
2358 	pt_encode_pad(encoder);
2359 	pt_encode_tsc(encoder, 0x1000);
2360 
2361 	/* Synchronize the decoder at the beginning of the buffer. */
2362 	decoder->pos = decoder->config.begin;
2363 
2364 	return ptu_passed();
2365 }
2366 
2367 /* Synchronize the decoder at the beginnig of a buffer containing packets that
2368  * should be skipped for event queries including a PSB.
2369  */
2370 static struct ptunit_result
2371 ptu_dfix_header_event_psb(struct ptu_decoder_fixture *dfix)
2372 {
2373 	struct pt_query_decoder *decoder = &dfix->decoder;
2374 	struct pt_encoder *encoder = &dfix->encoder;
2375 
2376 	/* The psb must be empty since the tests won't skip status events.
2377 	 * On the other hand, we do need to provide an address since tests
2378 	 * may want to update last-ip, which requires a last-ip, of course.
2379 	 */
2380 	pt_encode_pad(encoder);
2381 	pt_encode_tsc(encoder, 0);
2382 	pt_encode_psb(encoder);
2383 	pt_encode_mtc(encoder, 1);
2384 	pt_encode_pad(encoder);
2385 	pt_encode_tsc(encoder, 0x1000);
2386 	pt_encode_fup(encoder, pt_dfix_sext_ip, pt_ipc_sext_48);
2387 	pt_encode_psbend(encoder);
2388 	pt_encode_mtc(encoder, 1);
2389 	pt_encode_pad(encoder);
2390 
2391 	/* Synchronize the decoder at the beginning of the buffer. */
2392 	decoder->pos = decoder->config.begin;
2393 
2394 	return ptu_passed();
2395 }
2396 
2397 static struct ptu_decoder_fixture dfix_raw;
2398 static struct ptu_decoder_fixture dfix_empty;
2399 static struct ptu_decoder_fixture dfix_indir;
2400 static struct ptu_decoder_fixture dfix_indir_psb;
2401 static struct ptu_decoder_fixture dfix_cond;
2402 static struct ptu_decoder_fixture dfix_event;
2403 static struct ptu_decoder_fixture dfix_event_psb;
2404 
2405 static void init_fixtures(void)
2406 {
2407 	dfix_raw.init = ptu_dfix_init;
2408 	dfix_raw.fini = ptu_dfix_fini;
2409 
2410 	dfix_empty = dfix_raw;
2411 	dfix_empty.header = ptu_dfix_header_sync;
2412 
2413 	dfix_indir = dfix_raw;
2414 	dfix_indir.header = ptu_dfix_header_indir;
2415 
2416 	dfix_indir_psb = dfix_raw;
2417 	dfix_indir_psb.header = ptu_dfix_header_indir_psb;
2418 
2419 	dfix_cond = dfix_raw;
2420 	dfix_cond.header = ptu_dfix_header_cond;
2421 
2422 	dfix_event = dfix_raw;
2423 	dfix_event.header = ptu_dfix_header_event;
2424 
2425 	dfix_event_psb = dfix_raw;
2426 	dfix_event_psb.header = ptu_dfix_header_event_psb;
2427 }
2428 
2429 int main(int argc, char **argv)
2430 {
2431 	struct ptunit_suite suite;
2432 
2433 	init_fixtures();
2434 
2435 	suite = ptunit_mk_suite(argc, argv);
2436 
2437 	ptu_run_f(suite, indir_not_synced, dfix_raw);
2438 	ptu_run_f(suite, cond_not_synced, dfix_raw);
2439 	ptu_run_f(suite, event_not_synced, dfix_raw);
2440 
2441 	ptu_run_f(suite, sync_backward, dfix_raw);
2442 	ptu_run_f(suite, sync_backward_empty_end, dfix_raw);
2443 	ptu_run_f(suite, sync_backward_empty_mid, dfix_raw);
2444 	ptu_run_f(suite, sync_backward_empty_begin, dfix_raw);
2445 	ptu_run_f(suite, decode_sync_backward, dfix_raw);
2446 
2447 	ptu_run_f(suite, indir_null, dfix_empty);
2448 	ptu_run_f(suite, indir_empty, dfix_empty);
2449 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_suppressed);
2450 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_update_16);
2451 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_update_32);
2452 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_update_48);
2453 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_sext_48);
2454 	ptu_run_fp(suite, indir, dfix_empty, pt_ipc_full);
2455 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_suppressed);
2456 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_update_16);
2457 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_update_32);
2458 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_update_48);
2459 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_sext_48);
2460 	ptu_run_fp(suite, indir_tnt, dfix_empty, pt_ipc_full);
2461 	ptu_run_f(suite, indir_cutoff_fail, dfix_empty);
2462 	ptu_run_f(suite, indir_skip_tnt_fail, dfix_empty);
2463 	ptu_run_f(suite, indir_skip_tip_pge_fail, dfix_empty);
2464 	ptu_run_f(suite, indir_skip_tip_pgd_fail, dfix_empty);
2465 	ptu_run_f(suite, indir_skip_fup_tip_fail, dfix_empty);
2466 	ptu_run_f(suite, indir_skip_fup_tip_pgd_fail, dfix_empty);
2467 
2468 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_suppressed);
2469 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_update_16);
2470 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_update_32);
2471 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_update_48);
2472 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_sext_48);
2473 	ptu_run_fp(suite, indir, dfix_indir, pt_ipc_full);
2474 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_suppressed);
2475 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_update_16);
2476 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_update_32);
2477 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_update_48);
2478 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_sext_48);
2479 	ptu_run_fp(suite, indir_tnt, dfix_indir, pt_ipc_full);
2480 	ptu_run_f(suite, indir_cutoff_fail, dfix_indir);
2481 	ptu_run_f(suite, indir_skip_tnt_fail, dfix_indir);
2482 	ptu_run_f(suite, indir_skip_tip_pge_fail, dfix_indir);
2483 	ptu_run_f(suite, indir_skip_tip_pgd_fail, dfix_indir);
2484 	ptu_run_f(suite, indir_skip_fup_tip_fail, dfix_indir);
2485 	ptu_run_f(suite, indir_skip_fup_tip_pgd_fail, dfix_indir);
2486 
2487 	ptu_run_fp(suite, indir, dfix_indir_psb, pt_ipc_suppressed);
2488 	ptu_run_fp(suite, indir, dfix_indir_psb, pt_ipc_sext_48);
2489 	ptu_run_fp(suite, indir, dfix_indir_psb, pt_ipc_full);
2490 	ptu_run_fp(suite, indir_tnt, dfix_indir_psb, pt_ipc_suppressed);
2491 	ptu_run_fp(suite, indir_tnt, dfix_indir_psb, pt_ipc_sext_48);
2492 	ptu_run_fp(suite, indir_tnt, dfix_indir_psb, pt_ipc_full);
2493 	ptu_run_f(suite, indir_cutoff_fail, dfix_indir_psb);
2494 	ptu_run_f(suite, indir_skip_tnt_fail, dfix_indir_psb);
2495 	ptu_run_f(suite, indir_skip_tip_pge_fail, dfix_indir_psb);
2496 	ptu_run_f(suite, indir_skip_tip_pgd_fail, dfix_indir_psb);
2497 	ptu_run_f(suite, indir_skip_fup_tip_fail, dfix_indir_psb);
2498 	ptu_run_f(suite, indir_skip_fup_tip_pgd_fail, dfix_indir_psb);
2499 
2500 	ptu_run_f(suite, cond_null, dfix_empty);
2501 	ptu_run_f(suite, cond_empty, dfix_empty);
2502 	ptu_run_f(suite, cond, dfix_empty);
2503 	ptu_run_f(suite, cond_skip_tip_fail, dfix_empty);
2504 	ptu_run_f(suite, cond_skip_tip_pge_fail, dfix_empty);
2505 	ptu_run_f(suite, cond_skip_tip_pgd_fail, dfix_empty);
2506 	ptu_run_f(suite, cond_skip_fup_tip_fail, dfix_empty);
2507 	ptu_run_f(suite, cond_skip_fup_tip_pgd_fail, dfix_empty);
2508 
2509 	ptu_run_f(suite, cond, dfix_cond);
2510 	ptu_run_f(suite, cond_skip_tip_fail, dfix_cond);
2511 	ptu_run_f(suite, cond_skip_tip_pge_fail, dfix_cond);
2512 	ptu_run_f(suite, cond_skip_tip_pgd_fail, dfix_cond);
2513 	ptu_run_f(suite, cond_skip_fup_tip_fail, dfix_cond);
2514 	ptu_run_f(suite, cond_skip_fup_tip_pgd_fail, dfix_cond);
2515 
2516 	ptu_run_f(suite, event_null, dfix_empty);
2517 	ptu_run_f(suite, event_bad_size, dfix_empty);
2518 	ptu_run_f(suite, event_small_size, dfix_empty);
2519 	ptu_run_f(suite, event_big_size, dfix_empty);
2520 	ptu_run_f(suite, event_empty, dfix_empty);
2521 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_suppressed, 0);
2522 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_update_16, 0);
2523 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_update_32, 0);
2524 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_update_48, 0);
2525 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_sext_48, 0);
2526 	ptu_run_fp(suite, event_enabled, dfix_empty, pt_ipc_full, 0);
2527 	ptu_run_f(suite, event_enabled_cutoff_fail, dfix_empty);
2528 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_suppressed, 0);
2529 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_update_16, 0);
2530 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_update_32, 0);
2531 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_update_48, 0);
2532 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_sext_48, 0);
2533 	ptu_run_fp(suite, event_disabled, dfix_empty, pt_ipc_full, 0);
2534 	ptu_run_f(suite, event_disabled_cutoff_fail, dfix_empty);
2535 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_suppressed,
2536 		   0);
2537 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_update_16,
2538 		   0);
2539 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_update_32,
2540 		   0);
2541 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_update_48,
2542 		   0);
2543 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_sext_48, 0);
2544 	ptu_run_fp(suite, event_async_disabled, dfix_empty, pt_ipc_full, 0);
2545 	ptu_run_f(suite, event_async_disabled_suppressed_fail, dfix_empty);
2546 	ptu_run_f(suite, event_async_disabled_cutoff_fail_a, dfix_empty);
2547 	ptu_run_f(suite, event_async_disabled_cutoff_fail_b, dfix_empty);
2548 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_suppressed, 0);
2549 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_update_16, 0);
2550 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_update_32, 0);
2551 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_update_48, 0);
2552 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_sext_48, 0);
2553 	ptu_run_fp(suite, event_async_branch, dfix_empty, pt_ipc_full, 0);
2554 	ptu_run_f(suite, event_async_branch_suppressed_fail, dfix_empty);
2555 	ptu_run_f(suite, event_async_branch_cutoff_fail_a, dfix_empty);
2556 	ptu_run_f(suite, event_async_branch_cutoff_fail_b, dfix_empty);
2557 	ptu_run_fp(suite, event_paging, dfix_empty, 0, 0);
2558 	ptu_run_fp(suite, event_paging, dfix_empty, pt_pl_pip_nr, 0);
2559 	ptu_run_f(suite, event_paging_cutoff_fail, dfix_empty);
2560 	ptu_run_fp(suite, event_async_paging, dfix_empty, 0, 0);
2561 	ptu_run_fp(suite, event_async_paging, dfix_empty, pt_pl_pip_nr, 0);
2562 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_empty, 0, 0);
2563 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_empty,
2564 		   pt_pl_pip_nr, 0);
2565 	ptu_run_f(suite, event_async_paging_cutoff_fail, dfix_empty);
2566 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_suppressed, 0);
2567 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_update_16, 0);
2568 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_update_32, 0);
2569 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_update_48, 0);
2570 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_sext_48, 0);
2571 	ptu_run_fp(suite, event_overflow_fup, dfix_empty, pt_ipc_full, 0);
2572 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty,
2573 		   pt_ipc_suppressed, 0);
2574 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty, pt_ipc_update_16,
2575 		   0);
2576 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty, pt_ipc_update_32,
2577 		   0);
2578 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty, pt_ipc_update_48,
2579 		   0);
2580 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty, pt_ipc_sext_48,
2581 		   0);
2582 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_empty, pt_ipc_full,
2583 		   0);
2584 	ptu_run_f(suite, event_overflow_cutoff_fail, dfix_empty);
2585 	ptu_run_fp(suite, event_stop, dfix_empty, 0);
2586 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_suppressed,
2587 		   0);
2588 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_update_16, 0);
2589 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_update_32, 0);
2590 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_update_48, 0);
2591 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_sext_48, 0);
2592 	ptu_run_fp(suite, event_exec_mode_tip, dfix_empty, pt_ipc_full, 0);
2593 	ptu_run_f(suite, event_exec_mode_tip_cutoff_fail, dfix_empty);
2594 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty,
2595 		   pt_ipc_suppressed, 0);
2596 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty,
2597 		   pt_ipc_update_16, 0);
2598 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty,
2599 		   pt_ipc_update_32, 0);
2600 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty,
2601 		   pt_ipc_update_48, 0);
2602 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty, pt_ipc_sext_48,
2603 		   0);
2604 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_empty, pt_ipc_full,
2605 		   0);
2606 	ptu_run_f(suite, event_exec_mode_tip_pge_cutoff_fail, dfix_empty);
2607 	ptu_run_f(suite, event_exec_mode_cutoff_fail, dfix_empty);
2608 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_suppressed,
2609 		   pt_mob_tsx_intx, 0);
2610 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_update_16, 0, 0);
2611 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_update_32,
2612 		   pt_mob_tsx_intx, 0);
2613 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_update_48,
2614 		   pt_mob_tsx_intx, 0);
2615 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_sext_48, 0, 0);
2616 	ptu_run_fp(suite, event_tsx_fup, dfix_empty, pt_ipc_full, 0, 0);
2617 	ptu_run_f(suite, event_tsx_fup_cutoff_fail, dfix_empty);
2618 	ptu_run_f(suite, event_tsx_cutoff_fail, dfix_empty);
2619 	ptu_run_f(suite, event_skip_tip_fail, dfix_empty);
2620 	ptu_run_f(suite, event_skip_tnt_8_fail, dfix_empty);
2621 	ptu_run_f(suite, event_skip_tnt_64_fail, dfix_empty);
2622 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_suppressed);
2623 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_update_16);
2624 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_update_32);
2625 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_update_48);
2626 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_sext_48);
2627 	ptu_run_fp(suite, sync_event, dfix_empty, pt_ipc_full);
2628 	ptu_run_f(suite, sync_event_cutoff_fail, dfix_empty);
2629 	ptu_run_f(suite, sync_event_incomplete_fail, dfix_empty);
2630 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_suppressed);
2631 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_update_16);
2632 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_update_32);
2633 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_update_48);
2634 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_sext_48);
2635 	ptu_run_fp(suite, sync_ovf_event, dfix_empty, pt_ipc_full);
2636 	ptu_run_f(suite, sync_ovf_event_cutoff_fail, dfix_empty);
2637 
2638 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_suppressed, 0x1000);
2639 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_update_16, 0x1000);
2640 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_update_32, 0x1000);
2641 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_update_48, 0x1000);
2642 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_sext_48, 0x1000);
2643 	ptu_run_fp(suite, event_enabled, dfix_event, pt_ipc_full, 0x1000);
2644 	ptu_run_f(suite, event_enabled_cutoff_fail, dfix_event);
2645 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_suppressed,
2646 		   0x1000);
2647 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_update_16, 0x1000);
2648 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_update_32, 0x1000);
2649 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_update_48, 0x1000);
2650 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_sext_48, 0x1000);
2651 	ptu_run_fp(suite, event_disabled, dfix_event, pt_ipc_full, 0x1000);
2652 	ptu_run_f(suite, event_disabled_cutoff_fail, dfix_event);
2653 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_suppressed,
2654 		   0x1000);
2655 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_update_16,
2656 		   0x1000);
2657 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_update_32,
2658 		   0x1000);
2659 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_update_48,
2660 		   0x1000);
2661 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_sext_48,
2662 		   0x1000);
2663 	ptu_run_fp(suite, event_async_disabled, dfix_event, pt_ipc_full,
2664 		   0x1000);
2665 	ptu_run_f(suite, event_async_disabled_suppressed_fail, dfix_event);
2666 	ptu_run_f(suite, event_async_disabled_cutoff_fail_a, dfix_event);
2667 	ptu_run_f(suite, event_async_disabled_cutoff_fail_b, dfix_event);
2668 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_suppressed,
2669 		   0x1000);
2670 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_update_16,
2671 		   0x1000);
2672 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_update_32,
2673 		   0x1000);
2674 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_update_48,
2675 		   0x1000);
2676 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_sext_48,
2677 		   0x1000);
2678 	ptu_run_fp(suite, event_async_branch, dfix_event, pt_ipc_full,
2679 		   0x1000);
2680 	ptu_run_f(suite, event_async_branch_suppressed_fail, dfix_event);
2681 	ptu_run_f(suite, event_async_branch_cutoff_fail_a, dfix_event);
2682 	ptu_run_f(suite, event_async_branch_cutoff_fail_b, dfix_event);
2683 	ptu_run_fp(suite, event_paging, dfix_event, 0, 0x1000);
2684 	ptu_run_fp(suite, event_paging, dfix_event, pt_pl_pip_nr, 0x1000);
2685 	ptu_run_f(suite, event_paging_cutoff_fail, dfix_event);
2686 	ptu_run_fp(suite, event_async_paging, dfix_event, 0, 0x1000);
2687 	ptu_run_fp(suite, event_async_paging, dfix_event, pt_pl_pip_nr, 0x1000);
2688 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_event, 0, 0x1000);
2689 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_event,
2690 		   pt_pl_pip_nr, 0x1000);
2691 	ptu_run_f(suite, event_async_paging_cutoff_fail, dfix_event);
2692 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_suppressed,
2693 		   0x1000);
2694 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_update_16,
2695 		   0x1000);
2696 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_update_32,
2697 		   0x1000);
2698 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_update_48,
2699 		   0x1000);
2700 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_sext_48,
2701 		   0x1000);
2702 	ptu_run_fp(suite, event_overflow_fup, dfix_event, pt_ipc_full,
2703 		   0x1000);
2704 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event,
2705 		   pt_ipc_suppressed, 0x1000);
2706 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event, pt_ipc_update_16,
2707 		   0x1000);
2708 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event, pt_ipc_update_32,
2709 		   0x1000);
2710 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event, pt_ipc_update_48,
2711 		   0x1000);
2712 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event, pt_ipc_sext_48,
2713 		   0x1000);
2714 	ptu_run_fp(suite, event_overflow_tip_pge, dfix_event, pt_ipc_full,
2715 		   0x1000);
2716 	ptu_run_f(suite, event_overflow_cutoff_fail, dfix_event);
2717 	ptu_run_fp(suite, event_stop, dfix_event, 0x1000);
2718 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_suppressed,
2719 		   0x1000);
2720 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_update_16,
2721 		   0x1000);
2722 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_update_32,
2723 		   0x1000);
2724 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_update_48,
2725 		   0x1000);
2726 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_sext_48,
2727 		   0x1000);
2728 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event, pt_ipc_full,
2729 		   0x1000);
2730 	ptu_run_f(suite, event_exec_mode_tip_cutoff_fail, dfix_event);
2731 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event,
2732 		   pt_ipc_suppressed, 0x1000);
2733 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event,
2734 		   pt_ipc_update_16, 0x1000);
2735 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event,
2736 		   pt_ipc_update_32, 0x1000);
2737 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event,
2738 		   pt_ipc_update_48, 0x1000);
2739 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event, pt_ipc_sext_48,
2740 		   0x1000);
2741 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event, pt_ipc_full,
2742 		   0x1000);
2743 	ptu_run_f(suite, event_exec_mode_tip_pge_cutoff_fail, dfix_event);
2744 	ptu_run_f(suite, event_exec_mode_cutoff_fail, dfix_event);
2745 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_suppressed, 0,
2746 		   0x1000);
2747 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_update_16,
2748 		   pt_mob_tsx_intx, 0x1000);
2749 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_update_32, 0,
2750 		   0x1000);
2751 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_update_48, 0,
2752 		   0x1000);
2753 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_sext_48,
2754 		   pt_mob_tsx_intx, 0x1000);
2755 	ptu_run_fp(suite, event_tsx_fup, dfix_event, pt_ipc_full,
2756 		   pt_mob_tsx_intx, 0x1000);
2757 	ptu_run_f(suite, event_tsx_fup_cutoff_fail, dfix_event);
2758 	ptu_run_f(suite, event_tsx_cutoff_fail, dfix_event);
2759 	ptu_run_f(suite, event_skip_tip_fail, dfix_event);
2760 	ptu_run_f(suite, event_skip_tnt_8_fail, dfix_event);
2761 	ptu_run_f(suite, event_skip_tnt_64_fail, dfix_event);
2762 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_suppressed);
2763 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_update_16);
2764 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_update_32);
2765 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_update_48);
2766 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_sext_48);
2767 	ptu_run_fp(suite, sync_event, dfix_event, pt_ipc_full);
2768 	ptu_run_f(suite, sync_event_cutoff_fail, dfix_event);
2769 	ptu_run_f(suite, sync_event_incomplete_fail, dfix_event);
2770 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_suppressed);
2771 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_update_16);
2772 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_update_32);
2773 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_update_48);
2774 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_sext_48);
2775 	ptu_run_fp(suite, sync_ovf_event, dfix_event, pt_ipc_full);
2776 	ptu_run_f(suite, sync_ovf_event_cutoff_fail, dfix_event);
2777 
2778 	ptu_run_fp(suite, event_enabled, dfix_event_psb, pt_ipc_suppressed,
2779 		   0x1000);
2780 	ptu_run_fp(suite, event_enabled, dfix_event_psb, pt_ipc_sext_48,
2781 		   0x1000);
2782 	ptu_run_fp(suite, event_enabled, dfix_event_psb, pt_ipc_full,
2783 		   0x1000);
2784 	ptu_run_f(suite, event_enabled_cutoff_fail, dfix_event_psb);
2785 	ptu_run_fp(suite, event_disabled, dfix_event_psb, pt_ipc_suppressed,
2786 		   0x1000);
2787 	ptu_run_fp(suite, event_disabled, dfix_event_psb, pt_ipc_sext_48,
2788 		   0x1000);
2789 	ptu_run_fp(suite, event_disabled, dfix_event_psb, pt_ipc_full,
2790 		   0x1000);
2791 	ptu_run_f(suite, event_disabled_cutoff_fail, dfix_event_psb);
2792 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2793 		   pt_ipc_suppressed, 0x1000);
2794 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2795 		   pt_ipc_update_16, 0x1000);
2796 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2797 		   pt_ipc_update_32, 0x1000);
2798 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2799 		   pt_ipc_update_48, 0x1000);
2800 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2801 		   pt_ipc_sext_48, 0x1000);
2802 	ptu_run_fp(suite, event_async_disabled, dfix_event_psb,
2803 		   pt_ipc_full, 0x1000);
2804 	ptu_run_f(suite, event_async_disabled_suppressed_fail, dfix_event_psb);
2805 	ptu_run_f(suite, event_async_disabled_cutoff_fail_a, dfix_event_psb);
2806 	ptu_run_f(suite, event_async_disabled_cutoff_fail_b, dfix_event_psb);
2807 	ptu_run_fp(suite, event_async_branch, dfix_event_psb,
2808 		   pt_ipc_suppressed, 0x1000);
2809 	ptu_run_fp(suite, event_async_branch, dfix_event_psb, pt_ipc_update_16,
2810 		   0x1000);
2811 	ptu_run_fp(suite, event_async_branch, dfix_event_psb, pt_ipc_update_32,
2812 		   0x1000);
2813 	ptu_run_fp(suite, event_async_branch, dfix_event_psb, pt_ipc_update_48,
2814 		   0x1000);
2815 	ptu_run_fp(suite, event_async_branch, dfix_event_psb, pt_ipc_sext_48,
2816 		   0x1000);
2817 	ptu_run_fp(suite, event_async_branch, dfix_event_psb, pt_ipc_full,
2818 		   0x1000);
2819 	ptu_run_f(suite, event_async_branch_suppressed_fail, dfix_event_psb);
2820 	ptu_run_f(suite, event_async_branch_cutoff_fail_a, dfix_event_psb);
2821 	ptu_run_f(suite, event_async_branch_cutoff_fail_b, dfix_event_psb);
2822 	ptu_run_fp(suite, event_paging, dfix_event_psb, 0, 0x1000);
2823 	ptu_run_fp(suite, event_paging, dfix_event_psb, pt_pl_pip_nr, 0x1000);
2824 	ptu_run_f(suite, event_paging_cutoff_fail, dfix_event_psb);
2825 	ptu_run_fp(suite, event_async_paging, dfix_event_psb, 0, 0x1000);
2826 	ptu_run_fp(suite, event_async_paging, dfix_event_psb, pt_pl_pip_nr,
2827 		   0x1000);
2828 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_event_psb, 0,
2829 		   0x1000);
2830 	ptu_run_fp(suite, event_async_paging_suppressed, dfix_event_psb,
2831 		  pt_pl_pip_nr, 0x1000);
2832 	ptu_run_f(suite, event_async_paging_cutoff_fail, dfix_event_psb);
2833 	ptu_run_f(suite, event_overflow_cutoff_fail, dfix_event_psb);
2834 	ptu_run_fp(suite, event_stop, dfix_event_psb, 0x1000);
2835 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event_psb,
2836 		   pt_ipc_suppressed, 0x1000);
2837 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event_psb, pt_ipc_sext_48,
2838 		   0x1000);
2839 	ptu_run_fp(suite, event_exec_mode_tip, dfix_event_psb, pt_ipc_full,
2840 		   0x1000);
2841 	ptu_run_f(suite, event_exec_mode_tip_cutoff_fail, dfix_event_psb);
2842 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event_psb,
2843 		   pt_ipc_sext_48, 0x1000);
2844 	ptu_run_fp(suite, event_exec_mode_tip_pge, dfix_event_psb,
2845 		   pt_ipc_full, 0x1000);
2846 	ptu_run_f(suite, event_exec_mode_tip_pge_cutoff_fail, dfix_event_psb);
2847 	ptu_run_f(suite, event_exec_mode_cutoff_fail, dfix_event_psb);
2848 	ptu_run_fp(suite, event_tsx_fup, dfix_event_psb, pt_ipc_suppressed, 0,
2849 		   0x1000);
2850 	ptu_run_fp(suite, event_tsx_fup, dfix_event_psb, pt_ipc_sext_48,
2851 		   pt_mob_tsx_intx, 0x1000);
2852 	ptu_run_fp(suite, event_tsx_fup, dfix_event_psb, pt_ipc_full,
2853 		   pt_mob_tsx_intx, 0x1000);
2854 	ptu_run_f(suite, event_tsx_fup_cutoff_fail, dfix_event_psb);
2855 	ptu_run_f(suite, event_tsx_cutoff_fail, dfix_event_psb);
2856 	ptu_run_f(suite, event_skip_tip_fail, dfix_event_psb);
2857 	ptu_run_f(suite, event_skip_tnt_8_fail, dfix_event_psb);
2858 	ptu_run_f(suite, event_skip_tnt_64_fail, dfix_event_psb);
2859 
2860 	ptu_run_f(suite, time_null_fail, dfix_empty);
2861 	ptu_run_f(suite, time_initial, dfix_empty);
2862 	ptu_run_f(suite, time, dfix_empty);
2863 
2864 	ptu_run_f(suite, cbr_null, dfix_empty);
2865 	ptu_run_f(suite, cbr_initial, dfix_empty);
2866 	ptu_run_f(suite, cbr, dfix_empty);
2867 
2868 	ptu_run_f(suite, indir_cyc_cutoff, dfix_empty);
2869 	ptu_run_f(suite, cond_cyc_cutoff, dfix_empty);
2870 	ptu_run_f(suite, event_cyc_cutoff, dfix_empty);
2871 
2872 	return ptunit_report(&suite);
2873 }
2874