summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/gsp_phys_booter.c194
-rw-r--r--kernel/gsp_sema_service.c45
2 files changed, 159 insertions, 80 deletions
diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c
index e61f3ea..424aa2c 100644
--- a/kernel/gsp_phys_booter.c
+++ b/kernel/gsp_phys_booter.c
@@ -25555,11 +25555,14 @@ if (gsp_phys_gr_slot_kept(j, sa_mask,
((m - 0x3800u) / 8u) == 2u)
vs2 = true;
}
- if (vs2)
- vs_end = rr + span;
- if (!first)
- first = vs2 ? rr + span :
- rr;
+ if (vs2) {
+ if (!vs_end)
+ vs_end = rr + span;
+ if (!first)
+ first = rr + span;
+ } else if (!first) {
+ first = rr;
+ }
}
if (slot34 && !s34) {
s34 = rr;
@@ -25573,8 +25576,6 @@ if (gsp_phys_gr_slot_kept(j, sa_mask,
prevm = m0;
rr += span;
}
- if (vs_end && first < vs_end)
- first = vs_end;
if (s34 && first && s34 > first + leadsp) {
mme_draw_dst = first;
mme_draw_src = s34 - leadsp;
@@ -32990,13 +32991,13 @@ gr_page_unmapped:
if ((sph_bind_all || sph_bind_mask) &&
(req->h_object & 0xfffff000u) == 0xbeef0000u &&
req->prog_va &&
- win3d_n + 96u <= GSP_PHYS_RMCALL_GR_METHOD_WORDS) {
+ win3d_n + 128u <= GSP_PHYS_RMCALL_GR_METHOD_WORDS) {
static u32 sph_bind_log;
u64 fam = req->prog_va &
~(u64)(GSP_PHYS_PAGE_SIZE - 1);
u64 vtg_va;
bool vtg_auth = false;
- u32 in[96], out[96];
+ u32 in[128], out[128];
u32 nfin = 0, nrun = 0, on = 0, odrop = 0, orel;
u32 bi;
/*
@@ -33162,71 +33163,114 @@ gr_page_unmapped:
fam, fam + 0x900u, 0,
vpg->hpa, "auth");
- /*
- * eng89: live-derived GS
- * attribute map (maps=6).
- * The DS stage-4 check2
- * compares the GS IMAP with
- * the previous stage's OMAP
- * and the GS OMAP with the PS
- * IMAP. Hardcoded maps=4 is
- * exact only for one family
- * pair; derive the whole
- * 216-bit blocks from THIS
- * family's VTG image (vsrc)
- * and PS image (fam+0x0) so
- * the map is exact for any
- * pair. The GS header is
- * header-only (the stage is
- * bound with ENABLE=0); only
- * the map words change.
- */
- if (gsp_phys_rmcall_gr_sph_gs_maps_value() == 6u &&
- gsp_phys_rmcall_gr_sph_gs_img_value()) {
- u32 gs_off = gsp_phys_rmcall_gr_sph_gs_addr_value() ? 0xe80u : 0x780u;
- u8 *page = (u8 *)__va(vpg->hpa);
- u8 *gs = page + gs_off;
- u32 gw0 = get_unaligned_le32(gs);
- u32 pw0 = get_unaligned_le32(page);
- u32 bi;
- bool pok = ((pw0 >> 10) & 0xfu) == 5u;
- bool gok = ((gw0 >> 10) & 0xfu) == 4u;
- bool ovl = (vlen > 0x580u) && (gs_off == 0xe80u);
-
- if (!pok || !gok || ovl ||
- vlen < 80u || gs_off + 128u > GSP_PHYS_PAGE_SIZE) {
- if (sph_auth_log < 64u) {
- sph_auth_log++;
- pr_info("vgsp-gr: SPH-GS-SKIP off=0x%x reason=%s vlen=%u pw0=%08x gw0=%08x\n",
- gs_off,
- !pok ? "ps-invalid" :
- !gok ? "gs-invalid" :
- ovl ? "vtg-overlap" :
- vlen < 80u ? "vtg-short" : "bounds",
- vlen, pw0, gw0);
- }
- } else {
- for (bi = 0; bi < GSP_SPH_MAP_BITS; bi++) {
- gsp_sph_bit_put(gs, GSP_SPH_IMAP_BIT + bi,
- gsp_sph_bit_get(vsrc, GSP_SPH_OMAP_BIT + bi));
- gsp_sph_bit_put(gs, GSP_SPH_OMAP_BIT + bi,
- gsp_sph_bit_get(page, GSP_SPH_IMAP_BIT + bi));
- }
- dma_wmb();
- if (sph_auth_log < 64u) {
- sph_auth_log++;
- pr_info("vgsp-gr: SPH-GS-MAP src=live off=0x%x w5=%08x w10=%08x w13=%08x w17=%08x\n",
- gs_off,
- get_unaligned_le32(gs + 20u),
- get_unaligned_le32(gs + 40u),
- get_unaligned_le32(gs + 52u),
- get_unaligned_le32(gs + 68u));
- }
- gsp_phys_gr_sph_alias_receipt(
- fam, fam + (u64)gs_off, 0,
- vpg->hpa + gs_off, "gsmap");
- }
+ }
+ }
+ }
+ /*
+ * eng89c: live-derived GS attribute map (maps=6).
+ * The DS stage-4 check2 compares the GS IMAP with the
+ * previous stage's OMAP and the GS OMAP with the PS IMAP.
+ * Hardcoded maps=4 is exact only for one family pair;
+ * derive the whole 216-bit blocks from the VTG image that
+ * is ACTUALLY on the family page at +0x900 (the client's
+ * inline or this launch's copy) and the PS image at +0x0.
+ * Self-contained (the authoring block's locals are out of
+ * scope here) and deliberately independent of the copy so
+ * an overlap skip cannot make the map inert.
+ */
+ if (gsp_phys_rmcall_gr_sph_gs_maps_value() == 6u &&
+ gsp_phys_rmcall_gr_sph_gs_img_value()) {
+ const struct gsp_phys_gr_page *gpg = NULL;
+ u32 gs_off = gsp_phys_rmcall_gr_sph_gs_addr_value() ?
+ 0xe80u : 0x780u;
+ u32 gvlen = 0, gvi;
+ static u32 gsmap_log;
+
+ for (gvi = 0; gvi < req->n_pages; gvi++) {
+ if ((req->pages[gvi].guest_va &
+ ~(u64)(GSP_PHYS_PAGE_SIZE - 1)) !=
+ fam || !req->pages[gvi].hpa)
+ continue;
+ gpg = &req->pages[gvi];
+ break;
+ }
+ if (gpg) {
+ for (gvi = 0; gvi < req->n_inl; gvi++) {
+ const struct gsp_phys_gr_inline *gi =
+ &req->inl[gvi];
+
+ if ((gi->dst_va &
+ ~(u64)(GSP_PHYS_PAGE_SIZE - 1)) !=
+ fam)
+ continue;
+ if ((gi->dst_va &
+ (GSP_PHYS_PAGE_SIZE - 1)) ==
+ 0x900u)
+ gvlen = gi->len;
+ }
+ if (!gvlen) {
+ u32 bl = 0;
+
+ (void)gsp_sema_gl_vs_img(&bl);
+ gvlen = bl;
+ }
+ }
+ if (gpg) {
+ u8 *page = (u8 *)__va(gpg->hpa);
+ u8 *gs = page + gs_off;
+ const u8 *vtg = page + 0x900u;
+ u32 gw0 = get_unaligned_le32(gs);
+ u32 vw0 = get_unaligned_le32(vtg);
+ u32 pw0 = get_unaligned_le32(page);
+ u32 bi;
+ bool pok = ((pw0 >> 10) & 0xfu) == 5u;
+ bool gok = ((gw0 >> 10) & 0xfu) == 4u;
+ bool vok = ((vw0 >> 10) & 0xfu) == 1u;
+ bool ovl = (gs_off == 0xe80u) &&
+ (gvlen > 0x580u);
+
+ if (!pok || !gok || !vok || ovl ||
+ gs_off + 128u >
+ GSP_PHYS_PAGE_SIZE) {
+ if (gsmap_log < 64u) {
+ gsmap_log++;
+ pr_info("vgsp-gr: SPH-GS-SKIP off=0x%x reason=%s vw0=%08x pw0=%08x gw0=%08x len=%u\n",
+ gs_off,
+ !pok ? "ps-invalid" :
+ !gok ? "gs-invalid" :
+ !vok ? "vtg-invalid" :
+ ovl ? "vtg-overlap" :
+ "bounds",
+ vw0, pw0, gw0,
+ gvlen);
+ }
+ } else {
+ for (bi = 0;
+ bi < GSP_SPH_MAP_BITS;
+ bi++) {
+ gsp_sph_bit_put(gs,
+ GSP_SPH_IMAP_BIT + bi,
+ gsp_sph_bit_get(vtg,
+ GSP_SPH_OMAP_BIT + bi));
+ gsp_sph_bit_put(gs,
+ GSP_SPH_OMAP_BIT + bi,
+ gsp_sph_bit_get(page,
+ GSP_SPH_IMAP_BIT + bi));
}
+ dma_wmb();
+ if (gsmap_log < 64u) {
+ gsmap_log++;
+ pr_info("vgsp-gr: SPH-GS-MAP src=live off=0x%x w5=%08x w10=%08x w13=%08x w17=%08x\n",
+ gs_off,
+ get_unaligned_le32(gs + 20u),
+ get_unaligned_le32(gs + 40u),
+ get_unaligned_le32(gs + 52u),
+ get_unaligned_le32(gs + 68u));
+ }
+ gsp_phys_gr_sph_alias_receipt(
+ fam, fam + (u64)gs_off, 0,
+ gpg->hpa + gs_off,
+ "gsmap");
}
}
}
@@ -33674,7 +33718,7 @@ gr_page_unmapped:
u64 va = req->prog_bind_va[bi];
u32 sl = req->prog_bind_slot[bi] & 0x1fu;
- if (!va || nfin + 3u > 96u)
+ if (!va || nfin + 3u > 128u)
continue;
/*
* eng51: the window's own slot-1 bind can be
@@ -33712,7 +33756,7 @@ gr_page_unmapped:
(emit_gsimg ? (9u + ((gs_mode & 1u) ? 11u : 0u) +
((gs_ctx & 1u) ? 2u : 0u) +
((gs_ctx & 2u) ? 2u : 0u)) : 0u)
- <= 96u) {
+ <= 128u) {
/*
* SESSION 155 CONT 9: pair_safe emits each
* synthesized stage's SET_PIPELINE_SHADER
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;