diff options
Diffstat (limited to 'kernel/gsp_sema_service.c')
| -rw-r--r-- | kernel/gsp_sema_service.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c index f0f6632..9a6fde9 100644 --- a/kernel/gsp_sema_service.c +++ b/kernel/gsp_sema_service.c @@ -12207,6 +12207,7 @@ static bool svc_gl_window_rt_first_valid(const u8 *buf, u32 len, u32 start_off, static u32 svc_gl_rtp_a[4], svc_gl_rtp_b[4], svc_gl_rtp_w[4], svc_gl_rtp_h[4]; static u32 svc_gl_rtp_mask; static u64 svc_gl_rtp_push; +static u64 svc_gl_rtp_chan; static bool svc_gl_rtp = true; module_param_named(sema_gl_win_rt_persist, svc_gl_rtp, bool, 0644); MODULE_PARM_DESC(sema_gl_win_rt_persist, @@ -12217,6 +12218,31 @@ static bool svc_gl_rtp_valid(void) return READ_ONCE(svc_gl_rtp_mask) != 0u; } +/* + * Cheap draw marker for the persisted-admission path: the real beef draw + * windows carry BEGIN (0x1618), DRAW_VERTEX_ARRAY (0xd78) or a CALL(34) + * (0x3910). A data blob that happens to inherit a persisted bind is then + * not admitted as a 3D section. + */ +static bool svc_gl_win_has_draw(const u8 *buf, u32 len) +{ + u32 i; + + if (!buf) + return false; + for (i = 0; i + 4u <= len; i += 4u) { + u32 w, m; + + memcpy(&w, buf + i, 4); + if ((w & 0xe0001fffu) != 0x20000000u) + continue; + m = (w & 0x1fffu) << 2; + if (m == 0x1618u || m == 0x0d78u || m == 0x3910u) + return true; + } + return false; +} + static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push) { u32 A[4] = { 0 }, B[4] = { 0 }, W[4] = { 0 }, H[4] = { 0 }; @@ -12259,7 +12285,7 @@ static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push) o += span * 4u; } for (j = 0; j < 4u; j++) { - if (sa[j] && sb[j] && sw[j] && sh[j] && + if (sb[j] && sw[j] && sh[j] && (A[j] & ~0xffu) == 0 && (A[j] & 0xffu) <= 1u && B[j] >= 0x08000000u && B[j] < 0x40000000u && (B[j] & 3u) == 0 && W[j] > 0 && W[j] <= 0x4000u && @@ -12273,6 +12299,7 @@ static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push) } if (nval) { WRITE_ONCE(svc_gl_rtp_push, push); + WRITE_ONCE(svc_gl_rtp_chan, h); smp_wmb(); WRITE_ONCE(svc_gl_rtp_mask, READ_ONCE(svc_gl_rtp_mask) | 1u); if (gsp_sema_dbg) { @@ -12293,7 +12320,7 @@ static void svc_gl_rt_note(const u8 *buf, u32 len, u64 h, u64 push) } static bool svc_gl_window_drawwin_ok(const u8 *buf, u32 len, u32 start_off, - u32 at_off) + u32 at_off, u64 h) { if (svc_gl_window_state_push(buf, len, start_off)) return true; @@ -12317,7 +12344,8 @@ static bool svc_gl_window_drawwin_ok(const u8 *buf, u32 len, u32 start_off, * persisted bind when one is known; the replay context's RT state * comes from the channel shadow, not from this window. */ - if (READ_ONCE(svc_gl_rtp) && svc_gl_rtp_valid()) { + if (READ_ONCE(svc_gl_rtp) && svc_gl_rtp_valid() && + READ_ONCE(svc_gl_rtp_chan) == h && svc_gl_win_has_draw(buf, len)) { static u32 rtp_adm_log; if (rtp_adm_log < 16u) { @@ -13423,7 +13451,7 @@ static void svc_gl_flush(struct nv_vgpu_device *vgpu, (op_src[0] == 'd' && (ch->h_object & 0xfffff000u) == 0xbeef0000u && svc_gl_window_drawwin_ok(buf, len, svc_gl.start_off, - at_off))) && + at_off, ch->h_object))) && svc_gr_cand.valid && len == svc_gr_cand.push_n * 4 && svc_gl.start_off + 8u <= at_off && @@ -13451,7 +13479,7 @@ static void svc_gl_flush(struct nv_vgpu_device *vgpu, */ if (op_src[0] == 'd' && !svc_gl_window_drawwin_ok(buf, len, svc_gl.start_off, - at_off)) { + at_off, ch->h_object)) { /* eng25: bounded witness when a beef draw-synth * window is refused - its last colour-target bind * is not a usable C597 RT (see the clause above). */ @@ -26064,6 +26092,13 @@ static void svc_session_flush(void) tr_fail_next = 0; svc_fwd_hold_clear(); memset(&svc_gr_cand, 0, sizeof(svc_gr_cand)); + /* + * eng89c: the persisted colour-target bind belongs to a channel of the + * dead session; admitting a recycled beef channel on it would replay + * the wrong RT. Cleared with the rest of the per-session carryover. + */ + WRITE_ONCE(svc_gl_rtp_mask, 0u); + WRITE_ONCE(svc_gl_rtp_chan, 0u); /* m176: re-arm the opdef diagnostic budget (it was never per-session, * so a late client's strand could be silent). */ svc_opdef_log = 0; |
