From d2f08383e821102765b98d24df37eccfe8cdd2bd Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 16 Nov 2026 11:46:27 -0500 Subject: vgsp: eng89c - fix the live GS map, draw anchor, prelude budget, RT persistence Four fixes from a code audit of eng89/eng89b, each of which could have made the maps=6 experiment unobservable or harmful: - Draw-move anchor: use the FIRST 0x3810 run only. The 247-word window also carries its own 0x3810 later; the old code moved the draw to the last one, i.e. behind the setup calls it must precede. Removed the post-scan promotion. - Prelude/stage budget: the raster-enable words (8) pushed the prelude toward the 96-word cap and could skip the whole stage-bind block (SPH-BIND-STAGE-SKIP reason=budget), hiding the GS bind. Array and gates grown to 128. - RT persistence: require B/W/H only (A optional, matching the existing first-valid check), store the channel and require it for admission, require a real draw marker (0x1618/0xd78/0x3910) in the window, and clear the state in svc_session_flush so a recycled channel cannot inherit a dead session's target. - GS live map: moved out of the SPH-AUTHOR copy branch and derived from the family page's actual VTG image at +0x900 (not the source record), so an overlap skip no longer makes maps=6 inert. New gs_addr=0 parameter set (GS at 0x780) keeps the GS header clear of the VTG copy. Test matrix: params-r1624-maps6-780.txt (maps=6, gs_addr=0). --- kernel/gsp_sema_service.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'kernel/gsp_sema_service.c') 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; -- cgit v1.2.3