#!/bin/sh
# DF-3945 source-presence check for the CVE-2019-14615 fix
# (upstream bc8a76a152c5 / stable dd4f3b3508f6) in the local sys tree.
SRC=${1:-/usr/src/sys/dev/drm/i915/intel_lrc.c}
echo "-- gen9_init_indirectctx_bb (needs unconditional WaClearSlmSpace pipe control):"
sed -n "/^static u32 \*gen9_init_indirectctx_bb/,/^}/p" "$SRC" | grep -n "WaClearSlm\|emit_lri\|flush_coherentl3"
echo "-- gen8_init_indirectctx_bb (has the cleardown; fix borrows it verbatim):"
sed -n "/^static u32 \*gen8_init_indirectctx_bb/,/^}/p" "$SRC" | grep -n "WaClearSlm\|emit_pipe_control\|FLUSH_L3"
echo "-- all FLUSH_L3 uses in intel_lrc.c (1512=gen8 BB, 1589=KBL-A0-only gen9):"
grep -n "PIPE_CONTROL_FLUSH_L3" "$SRC"
