#include #include "debug.h" #include "tests/tests.h" #include "arch-tests.h" #include "intel-pt-decoder/insn.h" #include "intel-pt-decoder/intel-pt-insn-decoder.h" struct test_data { u8 data[MAX_INSN_SIZE]; int expected_length; int expected_rel; const char *expected_op_str; const char *expected_branch_str; const char *asm_rep; }; struct test_data test_data_32[] = { #include "insn-x86-dat-32.c" {{0x0f, 0x01, 0xee}, 3, 0, NULL, NULL, "0f 01 ee \trdpkru"}, {{0x0f, 0x01, 0xef}, 3, 0, NULL, NULL, "0f 01 ef \twrpkru"}, {{0}, 0, 0, NULL, NULL, NULL}, }; struct test_data test_data_64[] = { #include "insn-x86-dat-64.c" {{0x0f, 0x01, 0xee}, 3, 0, NULL, NULL, "0f 01 ee \trdpkru"}, {{0x0f, 0x01, 0xef}, 3, 0, NULL, NULL, "0f 01 ef \twrpkru"}, {{0}, 0, 0, NULL, NULL, NULL}, }; static int get_op(const char *op_str) { struct val_data { const char *name; int val; } vals[] = { {"other", INTEL_PT_OP_OTHER}, {"call", INTEL_PT_OP_CALL}, {"ret", INTEL_PT_OP_RET}, {"jcc", INTEL_PT_OP_JCC}, {"jmp", INTEL_PT_OP_JMP}, {"loop", INTEL_PT_OP_LOOP}, {"iret", INTEL_PT_OP_IRET}, {"int", INTEL_PT_OP_INT}, {"syscall", INTEL_PT_OP_SYSCALL}, {"sysret", INTEL_PT_OP_SYSRET}, {NULL, 0}, }; struct val_data *val; if (!op_str || !strlen(op_str)) return 0; for (val = vals; val->name; val++) { if (!strcmp(val->name, op_str)) return val->val; } pr_debug("Failed to get op\n"); return -1; } static int get_branch(const char *branch_str) { struct val_data { const char *name; int val; } vals[] = { {"no_branch", INTEL_PT_BR_NO_BRANCH}, {"indirect", INTEL_PT_BR_INDIRECT}, {"conditional", INTEL_PT_BR_CONDITIONAL}, {"unconditional", INTEL_PT_BR_UNCONDITIONAL}, {NULL, 0}, }; struct val_data *val; if (!branch_str || !strlen(branch_str)) return 0; for (val = vals; val->name; val++) { if (!strcmp(val->name, branch_str)) return val->val; } pr_debug("Failed to get branch\n"); return -1; } static int test_data_item(struct test_data *dat, int x86_64) { struct intel_pt_insn intel_pt_insn; struct insn insn; int op, branch; insn_init(&insn, dat->data, MAX_INSN_SIZE, x86_64); insn_get_length(&insn); if (!insn_complete(&insn)) { pr_debug("Failed to decode: %s\n", dat->asm_rep); return -1; } if (insn.length != dat->expected_length) { pr_debug("Failed to decode length (%d vs expected %d): %s\n", insn.length, dat->expected_length, dat->asm_rep); return -1; } op = get_op(dat->expected_op_str); branch = get_branch(dat->expected_branch_str); if (intel_pt_get_insn(dat->data, MAX_INSN_SIZE, x86_64, &intel_pt_insn)) { pr_debug("Intel PT failed to decode: %s\n", dat->asm_rep); return -1; } if ((int)intel_pt_insn.op != op) { pr_debug("Failed to decode 'op' value (%d vs expected %d): %s\n", intel_pt_insn.op, op, dat->asm_rep); return -1; } if ((int)intel_pt_insn.branch != branch) { pr_debug("Failed to decode 'branch' value (%d vs expected %d): %s\n", intel_pt_insn.branch, branch, dat->asm_rep); return -1; } if (intel_pt_insn.rel != dat->expected_rel) { pr_debug("Failed to decode 'rel' value (%#x vs expected %#x): %s\n", intel_pt_insn.rel, dat->expected_rel, dat->asm_rep); return -1; } pr_debug("Decoded ok: %s\n", dat->asm_rep); return 0; } static int test_data_set(struct test_data *dat_set, int x86_64) { struct test_data *dat; int ret = 0; for (dat = dat_set; dat->expected_length; dat++) { if (test_data_item(dat, x86_64)) ret = -1; } return ret; } /** * test__insn_x86 - test x86 instruction decoder - new instructions. * * This function implements a test that decodes a selection of instructions and * checks the results. The Intel PT function that further categorizes * instructions (i.e. intel_pt_get_insn()) is also checked. * * The instructions are originally in insn-x86-dat-src.c which has been * processed by scripts gen-insn-x86-dat.sh and gen-insn-x86-dat.awk to produce * insn-x86-dat-32.c and insn-x86-dat-64.c which are included into this program. * i.e. to add new instructions to the test, edit insn-x86-dat-src.c, run the * gen-insn-x86-dat.sh script, make perf, and then run the test. * * If the test passes %0 is returned, otherwise %-1 is returned. Use the * verbose (-v) option to see all the instructions and whether or not they * decoded successfuly. */ int test__insn_x86(int subtest __maybe_unused) { int ret = 0; if (test_data_set(test_data_32, 0)) ret = -1; if (test_data_set(test_data_64, 1)) ret = -1; return ret; } on>space:mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-29 13:50:06 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-29 13:50:06 -0800
commit39cb2c9a316e77f6dfba96c543e55b6672d5a37e (patch)
tree98fe974ee4e20121253de7f61fc8d01bdb3821c1 /tools/perf/pmu-events/arch/x86/silvermont/frontend.json
parent2c5d9555d6d937966d79d4c6529a5f7b9206e405 (diff)
drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj()
I've seen this trigger twice now, where the i915_gem_object_to_ggtt() call in intel_unpin_fb_obj() returns NULL, resulting in an oops immediately afterwards as the (inlined) call to i915_vma_unpin_fence() tries to dereference it. It seems to be some race condition where the object is going away at shutdown time, since both times happened when shutting down the X server. The call chains were different: - VT ioctl(KDSETMODE, KD_TEXT): intel_cleanup_plane_fb+0x5b/0xa0 [i915] drm_atomic_helper_cleanup_planes+0x6f/0x90 [drm_kms_helper] intel_atomic_commit_tail+0x749/0xfe0 [i915] intel_atomic_commit+0x3cb/0x4f0 [i915] drm_atomic_commit+0x4b/0x50 [drm] restore_fbdev_mode+0x14c/0x2a0 [drm_kms_helper] drm_fb_helper_restore_fbdev_mode_unlocked+0x34/0x80 [drm_kms_helper] drm_fb_helper_set_par+0x2d/0x60 [drm_kms_helper] intel_fbdev_set_par+0x18/0x70 [i915] fb_set_var+0x236/0x460 fbcon_blank+0x30f/0x350 do_unblank_screen+0xd2/0x1a0 vt_ioctl+0x507/0x12a0 tty_ioctl+0x355/0xc30 do_vfs_ioctl+0xa3/0x5e0 SyS_ioctl+0x79/0x90 entry_SYSCALL_64_fastpath+0x13/0x94 - i915 unpin_work workqueue: intel_unpin_work_fn+0x58/0x140 [i915] process_one_work+0x1f1/0x480 worker_thread+0x48/0x4d0 kthread+0x101/0x140 and this patch purely papers over the issue by adding a NULL pointer check and a WARN_ON_ONCE() to avoid the oops that would then generally make the machine unresponsive. Other callers of i915_gem_object_to_ggtt() seem to also check for the returned pointer being NULL and warn about it, so this clearly has happened before in other places. [ Reported it originally to the i915 developers on Jan 8, applying the ugly workaround on my own now after triggering the problem for the second time with no feedback. This is likely to be the same bug reported as https://bugs.freedesktop.org/show_bug.cgi?id=98829 https://bugs.freedesktop.org/show_bug.cgi?id=99134 which has a patch for the underlying problem, but it hasn't gotten to me, so I'm applying the workaround. ] Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Imre Deak <imre.deak@intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/perf/pmu-events/arch/x86/silvermont/frontend.json')