1/* 2 * Copyright (c) 2014-2019, 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_packet_decoder.h" 32#include "pt_query_decoder.h" 33#include "pt_encoder.h" 34#include "pt_opcodes.h" 35 36#include "intel-pt.h" 37 38#include <string.h> 39 40 41/* A test fixture providing everything needed for packet en- and de-coding. */ 42struct packet_fixture { 43 /* The trace buffer. */ 44 uint8_t buffer[64]; 45 46 /* Two packets for encoding[0] and decoding[1]. */ 47 struct pt_packet packet[2]; 48 49 /* The configuration. */ 50 struct pt_config config; 51 52 /* The encoder. */ 53 struct pt_encoder encoder; 54 55 /* The decoder. */ 56 struct pt_packet_decoder decoder; 57 58 /* The return value for an unknown decode. */ 59 int unknown; 60 61 /* The test fixture initialization and finalization functions. */ 62 struct ptunit_result (*init)(struct packet_fixture *); 63 struct ptunit_result (*fini)(struct packet_fixture *); 64}; 65 66static int pfix_decode_unknown(struct pt_packet_unknown *packet, 67 const struct pt_config *config, 68 const uint8_t *pos, void *context) 69{ 70 struct packet_fixture *pfix; 71 72 if (!packet || !config) 73 return -pte_internal; 74 75 pfix = (struct packet_fixture *) context; 76 if (!pfix) 77 return -pte_internal; 78 79 if (config->begin != pfix->buffer) 80 return -pte_internal; 81 82 if (config->end != pfix->buffer + sizeof(pfix->buffer)) 83 return -pte_internal; 84 85 if (pos != pfix->buffer) 86 return -pte_internal; 87 88 packet->priv = pfix; 89 90 return pfix->unknown; 91} 92 93static struct ptunit_result pfix_init(struct packet_fixture *pfix) 94{ 95 int errcode; 96 97 memset(pfix->buffer, 0, sizeof(pfix->buffer)); 98 memset(pfix->packet, 0, sizeof(pfix->packet)); 99 memset(&pfix->config, 0, sizeof(pfix->config)); 100 pfix->config.size = sizeof(pfix->config); 101 pfix->config.begin = pfix->buffer; 102 pfix->config.end = pfix->buffer + sizeof(pfix->buffer); 103 pfix->config.decode.callback = pfix_decode_unknown; 104 pfix->config.decode.context = pfix; 105 106 pt_encoder_init(&pfix->encoder, &pfix->config); 107 pt_pkt_decoder_init(&pfix->decoder, &pfix->config); 108 109 errcode = pt_pkt_sync_set(&pfix->decoder, 0x0ull); 110 ptu_int_eq(errcode, 0); 111 112 pfix->unknown = 0; 113 114 return ptu_passed(); 115} 116 117static struct ptunit_result pfix_fini(struct packet_fixture *pfix) 118{ 119 pt_encoder_fini(&pfix->encoder); 120 pt_pkt_decoder_fini(&pfix->decoder); 121 122 return ptu_passed(); 123} 124 125static struct ptunit_result ptu_pkt_eq(const struct pt_packet *enc, 126 const struct pt_packet *dec) 127{ 128 const uint8_t *renc, *rdec; 129 size_t byte; 130 131 ptu_ptr(enc); 132 ptu_ptr(dec); 133 134 renc = (const uint8_t *) enc; 135 rdec = (const uint8_t *) dec; 136 137 for (byte = 0; byte < sizeof(*enc); ++byte) 138 ptu_uint_eq(renc[byte], rdec[byte]); 139 140 return ptu_passed(); 141} 142 143static struct ptunit_result pfix_test(struct packet_fixture *pfix) 144{ 145 int size; 146 147 size = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 148 ptu_int_gt(size, 0); 149 150 pfix->packet[0].size = (uint8_t) size; 151 152 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 153 sizeof(pfix->packet[1])); 154 ptu_int_gt(size, 0); 155 156 return ptu_pkt_eq(&pfix->packet[0], &pfix->packet[1]); 157} 158 159static struct ptunit_result no_payload(struct packet_fixture *pfix, 160 enum pt_packet_type type) 161{ 162 pfix->packet[0].type = type; 163 164 ptu_test(pfix_test, pfix); 165 166 return ptu_passed(); 167} 168 169static struct ptunit_result unknown(struct packet_fixture *pfix, int exp) 170{ 171 int size; 172 173 pfix->buffer[0] = pt_opc_bad; 174 pfix->unknown = exp; 175 176 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 177 sizeof(pfix->packet[1])); 178 ptu_int_eq(size, pfix->unknown); 179 180 if (size >= 0) { 181 ptu_int_eq(pfix->packet[1].type, ppt_unknown); 182 ptu_uint_eq(pfix->packet[1].size, (uint8_t) size); 183 ptu_ptr_eq(pfix->packet[1].payload.unknown.packet, 184 pfix->buffer); 185 ptu_ptr_eq(pfix->packet[1].payload.unknown.priv, pfix); 186 } 187 188 return ptu_passed(); 189} 190 191static struct ptunit_result unknown_ext(struct packet_fixture *pfix, int exp) 192{ 193 int size; 194 195 pfix->buffer[0] = pt_opc_ext; 196 pfix->buffer[1] = pt_ext_bad; 197 pfix->unknown = exp; 198 199 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 200 sizeof(pfix->packet[1])); 201 ptu_int_eq(size, pfix->unknown); 202 203 if (size >= 0) { 204 ptu_int_eq(pfix->packet[1].type, ppt_unknown); 205 ptu_uint_eq(pfix->packet[1].size, (uint8_t) size); 206 ptu_ptr_eq(pfix->packet[1].payload.unknown.packet, 207 pfix->buffer); 208 ptu_ptr_eq(pfix->packet[1].payload.unknown.priv, pfix); 209 } 210 211 return ptu_passed(); 212} 213 214static struct ptunit_result unknown_ext2(struct packet_fixture *pfix, int exp) 215{ 216 int size; 217 218 pfix->buffer[0] = pt_opc_ext; 219 pfix->buffer[1] = pt_ext_ext2; 220 pfix->buffer[2] = pt_ext2_bad; 221 pfix->unknown = exp; 222 223 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 224 sizeof(pfix->packet[1])); 225 ptu_int_eq(size, exp); 226 227 if (exp >= 0) { 228 ptu_int_eq(pfix->packet[1].type, ppt_unknown); 229 ptu_uint_eq(pfix->packet[1].size, (uint8_t) size); 230 ptu_ptr_eq(pfix->packet[1].payload.unknown.packet, 231 pfix->buffer); 232 ptu_ptr_eq(pfix->packet[1].payload.unknown.priv, pfix); 233 } 234 235 return ptu_passed(); 236} 237 238static struct ptunit_result tnt_8(struct packet_fixture *pfix) 239{ 240 pfix->packet[0].type = ppt_tnt_8; 241 pfix->packet[0].payload.tnt.bit_size = 4; 242 pfix->packet[0].payload.tnt.payload = 0x5ull; 243 244 ptu_test(pfix_test, pfix); 245 246 return ptu_passed(); 247} 248 249static struct ptunit_result tnt_64(struct packet_fixture *pfix) 250{ 251 pfix->packet[0].type = ppt_tnt_64; 252 pfix->packet[0].payload.tnt.bit_size = 23; 253 pfix->packet[0].payload.tnt.payload = 0xabcdeull; 254 255 ptu_test(pfix_test, pfix); 256 257 return ptu_passed(); 258} 259 260static struct ptunit_result ip(struct packet_fixture *pfix, 261 enum pt_packet_type type, 262 enum pt_ip_compression ipc, 263 uint64_t ip) 264{ 265 pfix->packet[0].type = type; 266 pfix->packet[0].payload.ip.ipc = ipc; 267 pfix->packet[0].payload.ip.ip = ip; 268 269 ptu_test(pfix_test, pfix); 270 271 return ptu_passed(); 272} 273 274static struct ptunit_result mode_exec(struct packet_fixture *pfix, 275 enum pt_exec_mode mode) 276{ 277 struct pt_packet_mode_exec packet; 278 279 packet = pt_set_exec_mode(mode); 280 281 pfix->packet[0].type = ppt_mode; 282 pfix->packet[0].payload.mode.leaf = pt_mol_exec; 283 pfix->packet[0].payload.mode.bits.exec.csl = packet.csl; 284 pfix->packet[0].payload.mode.bits.exec.csd = packet.csd; 285 286 ptu_test(pfix_test, pfix); 287 288 return ptu_passed(); 289} 290 291static struct ptunit_result mode_tsx(struct packet_fixture *pfix) 292{ 293 pfix->packet[0].type = ppt_mode; 294 pfix->packet[0].payload.mode.leaf = pt_mol_tsx; 295 pfix->packet[0].payload.mode.bits.tsx.intx = 1; 296 297 ptu_test(pfix_test, pfix); 298 299 return ptu_passed(); 300} 301 302static struct ptunit_result pip(struct packet_fixture *pfix) 303{ 304 pfix->packet[0].type = ppt_pip; 305 pfix->packet[0].payload.pip.cr3 = 0x4200ull; 306 pfix->packet[0].payload.pip.nr = 1; 307 308 ptu_test(pfix_test, pfix); 309 310 return ptu_passed(); 311} 312 313static struct ptunit_result tsc(struct packet_fixture *pfix) 314{ 315 pfix->packet[0].type = ppt_tsc; 316 pfix->packet[0].payload.tsc.tsc = 0x42ull; 317 318 ptu_test(pfix_test, pfix); 319 320 return ptu_passed(); 321} 322 323static struct ptunit_result cbr(struct packet_fixture *pfix) 324{ 325 pfix->packet[0].type = ppt_cbr; 326 pfix->packet[0].payload.cbr.ratio = 0x23; 327 328 ptu_test(pfix_test, pfix); 329 330 return ptu_passed(); 331} 332 333static struct ptunit_result tma(struct packet_fixture *pfix) 334{ 335 pfix->packet[0].type = ppt_tma; 336 pfix->packet[0].payload.tma.ctc = 0x42; 337 pfix->packet[0].payload.tma.fc = 0x123; 338 339 ptu_test(pfix_test, pfix); 340 341 return ptu_passed(); 342} 343 344static struct ptunit_result tma_bad(struct packet_fixture *pfix) 345{ 346 int errcode; 347 348 pfix->packet[0].type = ppt_tma; 349 pfix->packet[0].payload.tma.ctc = 0x42; 350 pfix->packet[0].payload.tma.fc = 0x200; 351 352 errcode = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 353 ptu_int_eq(errcode, -pte_bad_packet); 354 355 return ptu_passed(); 356} 357 358static struct ptunit_result mtc(struct packet_fixture *pfix) 359{ 360 pfix->packet[0].type = ppt_mtc; 361 pfix->packet[0].payload.mtc.ctc = 0x23; 362 363 ptu_test(pfix_test, pfix); 364 365 return ptu_passed(); 366} 367 368static struct ptunit_result cyc(struct packet_fixture *pfix) 369{ 370 pfix->packet[0].type = ppt_cyc; 371 pfix->packet[0].payload.cyc.value = 0x23; 372 373 ptu_test(pfix_test, pfix); 374 375 return ptu_passed(); 376} 377 378static struct ptunit_result vmcs(struct packet_fixture *pfix) 379{ 380 pfix->packet[0].type = ppt_vmcs; 381 pfix->packet[0].payload.vmcs.base = 0xabcdef000ull; 382 383 ptu_test(pfix_test, pfix); 384 385 return ptu_passed(); 386} 387 388static struct ptunit_result mnt(struct packet_fixture *pfix) 389{ 390 pfix->packet[0].type = ppt_mnt; 391 pfix->packet[0].payload.mnt.payload = 0x1234567890abcdefull; 392 393 ptu_test(pfix_test, pfix); 394 395 return ptu_passed(); 396} 397 398static struct ptunit_result exstop(struct packet_fixture *pfix, int ip) 399{ 400 pfix->packet[0].type = ppt_exstop; 401 pfix->packet[0].payload.exstop.ip = ip ? 1 : 0; 402 403 ptu_test(pfix_test, pfix); 404 405 return ptu_passed(); 406} 407 408static struct ptunit_result mwait(struct packet_fixture *pfix) 409{ 410 pfix->packet[0].type = ppt_mwait; 411 pfix->packet[0].payload.mwait.hints = 0xc; 412 pfix->packet[0].payload.mwait.ext = 0x1; 413 414 ptu_test(pfix_test, pfix); 415 416 return ptu_passed(); 417} 418 419static struct ptunit_result pwre(struct packet_fixture *pfix) 420{ 421 pfix->packet[0].type = ppt_pwre; 422 pfix->packet[0].payload.pwre.state = 0x0; 423 pfix->packet[0].payload.pwre.sub_state = 0x3; 424 pfix->packet[0].payload.pwre.hw = 1; 425 426 ptu_test(pfix_test, pfix); 427 428 return ptu_passed(); 429} 430 431static struct ptunit_result pwrx(struct packet_fixture *pfix) 432{ 433 pfix->packet[0].type = ppt_pwrx; 434 pfix->packet[0].payload.pwrx.last = 0x3; 435 pfix->packet[0].payload.pwrx.deepest = 0xa; 436 pfix->packet[0].payload.pwrx.store = 1; 437 438 ptu_test(pfix_test, pfix); 439 440 return ptu_passed(); 441} 442 443static struct ptunit_result ptw(struct packet_fixture *pfix, uint8_t plc, 444 int ip) 445{ 446 uint64_t pl, mask; 447 int size; 448 449 size = pt_ptw_size(plc); 450 ptu_int_gt(size, 0); 451 452 pl = 0x1234567890abcdefull; 453 454 ptu_uint_le((size_t) size, sizeof(mask)); 455 mask = ~0ull >> ((sizeof(mask) - (size_t) size) * 8); 456 457 pfix->packet[0].type = ppt_ptw; 458 pfix->packet[0].payload.ptw.payload = pl & mask; 459 pfix->packet[0].payload.ptw.plc = plc; 460 pfix->packet[0].payload.ptw.ip = ip ? 1 : 0; 461 462 ptu_test(pfix_test, pfix); 463 464 return ptu_passed(); 465} 466 467static struct ptunit_result cutoff(struct packet_fixture *pfix, 468 enum pt_packet_type type) 469{ 470 int size; 471 472 pfix->packet[0].type = type; 473 474 size = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 475 ptu_int_gt(size, 0); 476 477 pfix->decoder.config.end = pfix->encoder.pos - 1; 478 479 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 480 sizeof(pfix->packet[1])); 481 ptu_int_eq(size, -pte_eos); 482 483 return ptu_passed(); 484} 485 486static struct ptunit_result cutoff_ip(struct packet_fixture *pfix, 487 enum pt_packet_type type) 488{ 489 int size; 490 491 pfix->packet[0].type = type; 492 pfix->packet[0].payload.ip.ipc = pt_ipc_sext_48; 493 494 size = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 495 ptu_int_gt(size, 0); 496 497 pfix->decoder.config.end = pfix->encoder.pos - 1; 498 499 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 500 sizeof(pfix->packet[1])); 501 ptu_int_eq(size, -pte_eos); 502 503 return ptu_passed(); 504} 505 506static struct ptunit_result cutoff_cyc(struct packet_fixture *pfix) 507{ 508 int size; 509 510 pfix->packet[0].type = ppt_cyc; 511 pfix->packet[0].payload.cyc.value = 0xa8; 512 513 size = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 514 ptu_int_gt(size, 0); 515 516 pfix->decoder.config.end = pfix->encoder.pos - 1; 517 518 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 519 sizeof(pfix->packet[1])); 520 ptu_int_eq(size, -pte_eos); 521 522 return ptu_passed(); 523} 524 525static struct ptunit_result cutoff_mode(struct packet_fixture *pfix, 526 enum pt_mode_leaf leaf) 527{ 528 int size; 529 530 pfix->packet[0].type = ppt_mode; 531 pfix->packet[0].payload.mode.leaf = leaf; 532 533 size = pt_enc_next(&pfix->encoder, &pfix->packet[0]); 534 ptu_int_gt(size, 0); 535 536 pfix->decoder.config.end = pfix->encoder.pos - 1; 537 538 size = pt_pkt_next(&pfix->decoder, &pfix->packet[1], 539 sizeof(pfix->packet[1])); 540 ptu_int_eq(size, -pte_eos); 541 542 return ptu_passed(); 543} 544 545int main(int argc, char **argv) 546{ 547 struct packet_fixture pfix; 548 struct ptunit_suite suite; 549 550 pfix.init = pfix_init; 551 pfix.fini = pfix_fini; 552 553 suite = ptunit_mk_suite(argc, argv); 554 555 ptu_run_fp(suite, no_payload, pfix, ppt_pad); 556 ptu_run_fp(suite, no_payload, pfix, ppt_psb); 557 ptu_run_fp(suite, no_payload, pfix, ppt_ovf); 558 ptu_run_fp(suite, no_payload, pfix, ppt_psbend); 559 ptu_run_fp(suite, no_payload, pfix, ppt_stop); 560 561 ptu_run_fp(suite, unknown, pfix, 4); 562 ptu_run_fp(suite, unknown, pfix, -pte_nomem); 563 ptu_run_fp(suite, unknown_ext, pfix, 4); 564 ptu_run_fp(suite, unknown_ext, pfix, -pte_nomem); 565 ptu_run_fp(suite, unknown_ext2, pfix, 4); 566 ptu_run_fp(suite, unknown_ext2, pfix, -pte_nomem); 567 568 ptu_run_f(suite, tnt_8, pfix); 569 ptu_run_f(suite, tnt_64, pfix); 570 571 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_suppressed, 0x0ull); 572 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_16, 0x42ull); 573 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_32, 0x4200ull); 574 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_48, 0x4200ull); 575 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_sext_48, 0x42ull); 576 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_full, 0x42ull); 577 578 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_suppressed, 0x0ull); 579 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_16, 0x42ull); 580 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_32, 0x4200ull); 581 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_update_48, 0x4200ull); 582 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_sext_48, 0x42ull); 583 ptu_run_fp(suite, ip, pfix, ppt_tip, pt_ipc_full, 0x42ull); 584 585 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_suppressed, 0x0ull); 586 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_update_16, 0x42ull); 587 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_update_32, 0x4200ull); 588 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_update_48, 0x4200ull); 589 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_sext_48, 0x42ull); 590 ptu_run_fp(suite, ip, pfix, ppt_tip_pge, pt_ipc_full, 0x42ull); 591 592 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_suppressed, 0x0ull); 593 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_update_16, 0x42ull); 594 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_update_32, 0x4200ull); 595 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_update_48, 0x4200ull); 596 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_sext_48, 0x42ull); 597 ptu_run_fp(suite, ip, pfix, ppt_tip_pgd, pt_ipc_full, 0x42ull); 598 599 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_suppressed, 0x0ull); 600 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_update_16, 0x42ull); 601 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_update_32, 0x4200ull); 602 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_update_48, 0x4200ull); 603 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_sext_48, 0x42ull); 604 ptu_run_fp(suite, ip, pfix, ppt_fup, pt_ipc_full, 0x42ull); 605 606 ptu_run_fp(suite, mode_exec, pfix, ptem_16bit); 607 ptu_run_fp(suite, mode_exec, pfix, ptem_32bit); 608 ptu_run_fp(suite, mode_exec, pfix, ptem_64bit); 609 ptu_run_f(suite, mode_tsx, pfix); 610 611 ptu_run_f(suite, pip, pfix); 612 ptu_run_f(suite, tsc, pfix); 613 ptu_run_f(suite, cbr, pfix); 614 ptu_run_f(suite, tma, pfix); 615 ptu_run_f(suite, tma_bad, pfix); 616 ptu_run_f(suite, mtc, pfix); 617 ptu_run_f(suite, cyc, pfix); 618 ptu_run_f(suite, vmcs, pfix); 619 ptu_run_f(suite, mnt, pfix); 620 ptu_run_fp(suite, exstop, pfix, 0); 621 ptu_run_fp(suite, exstop, pfix, 1); 622 ptu_run_f(suite, mwait, pfix); 623 ptu_run_f(suite, pwre, pfix); 624 ptu_run_f(suite, pwrx, pfix); 625 ptu_run_fp(suite, ptw, pfix, 0, 1); 626 ptu_run_fp(suite, ptw, pfix, 1, 0); 627 628 ptu_run_fp(suite, cutoff, pfix, ppt_psb); 629 ptu_run_fp(suite, cutoff_ip, pfix, ppt_tip); 630 ptu_run_fp(suite, cutoff_ip, pfix, ppt_tip_pge); 631 ptu_run_fp(suite, cutoff_ip, pfix, ppt_tip_pgd); 632 ptu_run_fp(suite, cutoff_ip, pfix, ppt_fup); 633 ptu_run_fp(suite, cutoff, pfix, ppt_ovf); 634 ptu_run_fp(suite, cutoff, pfix, ppt_psbend); 635 ptu_run_fp(suite, cutoff, pfix, ppt_tnt_64); 636 ptu_run_fp(suite, cutoff, pfix, ppt_tsc); 637 ptu_run_fp(suite, cutoff, pfix, ppt_cbr); 638 ptu_run_fp(suite, cutoff, pfix, ppt_tma); 639 ptu_run_fp(suite, cutoff, pfix, ppt_mtc); 640 ptu_run_f(suite, cutoff_cyc, pfix); 641 ptu_run_fp(suite, cutoff_mode, pfix, pt_mol_exec); 642 ptu_run_fp(suite, cutoff_mode, pfix, pt_mol_tsx); 643 ptu_run_fp(suite, cutoff, pfix, ppt_vmcs); 644 ptu_run_fp(suite, cutoff, pfix, ppt_mnt); 645 ptu_run_fp(suite, cutoff, pfix, ppt_exstop); 646 ptu_run_fp(suite, cutoff, pfix, ppt_mwait); 647 ptu_run_fp(suite, cutoff, pfix, ppt_pwre); 648 ptu_run_fp(suite, cutoff, pfix, ppt_pwrx); 649 ptu_run_fp(suite, cutoff, pfix, ppt_ptw); 650 651 return ptunit_report(&suite); 652} 653 654 655/* Dummy decode functions to satisfy link dependencies. 656 * 657 * As a nice side-effect, we will know if we need to add more tests when 658 * adding new decoder functions. 659 */ 660struct pt_query_decoder; 661 662int pt_qry_decode_unknown(struct pt_query_decoder *d) 663{ 664 (void) d; 665 666 return -pte_internal; 667} 668int pt_qry_decode_pad(struct pt_query_decoder *d) 669{ 670 (void) d; 671 672 return -pte_internal; 673} 674int pt_qry_decode_psb(struct pt_query_decoder *d) 675{ 676 (void) d; 677 678 return -pte_internal; 679} 680int pt_qry_decode_tip(struct pt_query_decoder *d) 681{ 682 (void) d; 683 684 return -pte_internal; 685} 686int pt_qry_decode_tnt_8(struct pt_query_decoder *d) 687{ 688 (void) d; 689 690 return -pte_internal; 691} 692int pt_qry_decode_tnt_64(struct pt_query_decoder *d) 693{ 694 (void) d; 695 696 return -pte_internal; 697} 698int pt_qry_decode_tip_pge(struct pt_query_decoder *d) 699{ 700 (void) d; 701 702 return -pte_internal; 703} 704int pt_qry_decode_tip_pgd(struct pt_query_decoder *d) 705{ 706 (void) d; 707 708 return -pte_internal; 709} 710int pt_qry_decode_fup(struct pt_query_decoder *d) 711{ 712 (void) d; 713 714 return -pte_internal; 715} 716int pt_qry_header_fup(struct pt_query_decoder *d) 717{ 718 (void) d; 719 720 return -pte_internal; 721} 722int pt_qry_decode_pip(struct pt_query_decoder *d) 723{ 724 (void) d; 725 726 return -pte_internal; 727} 728int pt_qry_header_pip(struct pt_query_decoder *d) 729{ 730 (void) d; 731 732 return -pte_internal; 733} 734int pt_qry_decode_ovf(struct pt_query_decoder *d) 735{ 736 (void) d; 737 738 return -pte_internal; 739} 740int pt_qry_decode_mode(struct pt_query_decoder *d) 741{ 742 (void) d; 743 744 return -pte_internal; 745} 746int pt_qry_header_mode(struct pt_query_decoder *d) 747{ 748 (void) d; 749 750 return -pte_internal; 751} 752int pt_qry_decode_psbend(struct pt_query_decoder *d) 753{ 754 (void) d; 755 756 return -pte_internal; 757} 758int pt_qry_decode_tsc(struct pt_query_decoder *d) 759{ 760 (void) d; 761 762 return -pte_internal; 763} 764int pt_qry_header_tsc(struct pt_query_decoder *d) 765{ 766 (void) d; 767 768 return -pte_internal; 769} 770int pt_qry_decode_cbr(struct pt_query_decoder *d) 771{ 772 (void) d; 773 774 return -pte_internal; 775} 776int pt_qry_header_cbr(struct pt_query_decoder *d) 777{ 778 (void) d; 779 780 return -pte_internal; 781} 782int pt_qry_decode_tma(struct pt_query_decoder *d) 783{ 784 (void) d; 785 786 return -pte_internal; 787} 788int pt_qry_decode_mtc(struct pt_query_decoder *d) 789{ 790 (void) d; 791 792 return -pte_internal; 793} 794int pt_qry_decode_cyc(struct pt_query_decoder *d) 795{ 796 (void) d; 797 798 return -pte_internal; 799} 800int pt_qry_decode_stop(struct pt_query_decoder *d) 801{ 802 (void) d; 803 804 return -pte_internal; 805} 806int pt_qry_decode_vmcs(struct pt_query_decoder *d) 807{ 808 (void) d; 809 810 return -pte_internal; 811} 812int pt_qry_header_vmcs(struct pt_query_decoder *d) 813{ 814 (void) d; 815 816 return -pte_internal; 817} 818int pt_qry_decode_mnt(struct pt_query_decoder *d) 819{ 820 (void) d; 821 822 return -pte_internal; 823} 824int pt_qry_header_mnt(struct pt_query_decoder *d) 825{ 826 (void) d; 827 828 return -pte_internal; 829} 830int pt_qry_decode_exstop(struct pt_query_decoder *d) 831{ 832 (void) d; 833 834 return -pte_internal; 835} 836int pt_qry_decode_mwait(struct pt_query_decoder *d) 837{ 838 (void) d; 839 840 return -pte_internal; 841} 842int pt_qry_decode_pwre(struct pt_query_decoder *d) 843{ 844 (void) d; 845 846 return -pte_internal; 847} 848int pt_qry_decode_pwrx(struct pt_query_decoder *d) 849{ 850 (void) d; 851 852 return -pte_internal; 853} 854int pt_qry_decode_ptw(struct pt_query_decoder *d) 855{ 856 (void) d; 857 858 return -pte_internal; 859} 860