summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_phys_booter.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 11:46:27 -0500
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-16 11:46:27 -0500
commitd2f08383e821102765b98d24df37eccfe8cdd2bd (patch)
tree7d1d5965adca29a540d9ef6f9ba714e364c9cd75 /kernel/gsp_phys_booter.c
parent9c36fba49f1ed5af0f40fc7a3d1fbb9ffadd4d97 (diff)
downloadopen-iov-d2f08383e821102765b98d24df37eccfe8cdd2bd.tar.gz
open-iov-d2f08383e821102765b98d24df37eccfe8cdd2bd.zip
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).
Diffstat (limited to 'kernel/gsp_phys_booter.c')
-rw-r--r--kernel/gsp_phys_booter.c194
1 files changed, 119 insertions, 75 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