summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/gsp_phys_booter.c188
-rw-r--r--kernel/gsp_sema_service.c11
2 files changed, 187 insertions, 12 deletions
diff --git a/kernel/gsp_phys_booter.c b/kernel/gsp_phys_booter.c
index 55082e6..e61f3ea 100644
--- a/kernel/gsp_phys_booter.c
+++ b/kernel/gsp_phys_booter.c
@@ -18811,11 +18811,15 @@ static void gsp_phys_gr_mme_carry_arm(bool split, u32 poff, u32 maxa,
/*
* CONT 549: reject absurd pack totals. c890 decoded the packed
* program's length word to 0x3D2F5F73-like garbage (expected 2799)
- * and armed a continuation on it. A real golden IR is a few thousand
- * words; anything past 64K cannot be a valid continuation total.
+ * and armed a continuation on it. eng89 tightens the bound to the
+ * IR pack array itself (GSP_PHYS_GR_RAW_WORDS = 4096): a total past
+ * the array can never complete and would make the builder's
+ * memcpy(&gsp_phys_gr_mme_ir_pack[poff], ..., chunk*4) overrun.
*/
- if (maxa == 0u || maxa > 0x10000u)
+ if (maxa == 0u || maxa > 4096u) {
+ pr_info("vgsp-gr: MME-PACK-REJECT reason=bound maxa=%u\n", maxa);
return;
+ }
if (!READ_ONCE(gsp_phys_rmcall_gr_mme_pack_carry) || !split ||
poff >= maxa ||
((h_object & 0xfffff000u) != 0xbeef0000u &&
@@ -20483,7 +20487,7 @@ static u32 gsp_phys_rmcall_gr_sph_gs_maps;
module_param_named(sema_gl_sph_gs_maps, gsp_phys_rmcall_gr_sph_gs_maps,
uint, 0644);
MODULE_PARM_DESC(sema_gl_sph_gs_maps,
- "Synth GS SPH attribute-map variant: 0=pass-through(POS+COLOR both), 1=zero maps, 2=PS-exact(POS.W/POS.XYZW), 3=IMAP POS+COLOR / OMAP POS.XYZW (default 0)");
+ "Synth GS SPH attribute-map variant: 0=pass-through(POS+COLOR both), 1=zero maps, 2=PS-exact(POS.W/POS.XYZW), 3=IMAP POS+COLOR / OMAP POS.XYZW, 4=IMAP=prior OMAP/OMAP=PS exact, 5=mesh-dummy, 6=live-derived from the bound VTG+PS images (default 0)");
u32 gsp_phys_rmcall_gr_sph_gs_maps_value(void)
{
@@ -20535,6 +20539,24 @@ MODULE_PARM_DESC(sema_gl_raster_prelude,
"Emit CT_WRITE(0..7)=0x1111 + depth/stencil/scissor disable ahead of replayed 3D windows (default 0; A/B)");
/*
+ * eng89 store gate: the raster/global render enables are client channel-init
+ * state that a fresh replay context may not carry. If SET_RASTER_ENABLE is
+ * 0, every primitive is discarded in the backend regardless of a clean DS
+ * and a bound VB; if SET_GLOBAL_RENDER_ENABLE's MODE is FALSE the launch
+ * renders nothing. Emit the canonical enabled values ahead of the window:
+ * 0x037c SET_RASTER_ENABLE <- 1
+ * 0x0130 SET_GLOBAL_RENDER_ENABLE_A <- 0 (offset upper)
+ * 0x0134 SET_GLOBAL_RENDER_ENABLE_B <- 0 (offset lower)
+ * 0x0138 SET_GLOBAL_RENDER_ENABLE_C <- 1 (MODE_TRUE)
+ * Harmless when the state is already enabled. Default 1; A/B with 0.
+ */
+static bool gsp_phys_rmcall_gr_raster_en = 1;
+module_param_named(sema_gl_raster_enable, gsp_phys_rmcall_gr_raster_en,
+ bool, 0644);
+MODULE_PARM_DESC(sema_gl_raster_enable,
+ "Emit SET_RASTER_ENABLE=1 and SET_GLOBAL_RENDER_ENABLE MODE_TRUE ahead of replayed 3D windows (default 1)");
+
+/*
* eng67 DRAW-STATE finding (c797): the release launch has RT0/RT1 bound
* (alias 0xa000000, 1920x1080, fmt 0xe6), vertex stream 0 bound at
* 0x1e305dc and the DRAW_IAB emitted its 8x3-vertex draws (0xd74=0x15),
@@ -25481,6 +25503,7 @@ if (gsp_phys_gr_slot_kept(j, sa_mask,
u32 rr = 0, first = 0;
u32 s34 = 0, s34span = 0, leadsp = 0;
u32 prev = 0, prevsp = 0, prevm = 0;
+ u32 vs_end = 0;
while (rr < win3d_n) {
u32 h = win3d[rr];
@@ -25508,8 +25531,36 @@ if (gsp_phys_gr_slot_kept(j, sa_mask,
if ((m - 0x3800u) / 8u == 34u)
slot34 = true;
}
- if (call && !first)
- first = rr;
+ /*
+ * eng89: never move the DRAW ahead of
+ * the prepended VERTEX_STREAM bind
+ * (CALL slot 2, macro 0x3810). The
+ * release_fill prepends that run so a
+ * multi-page VB is bound before the
+ * draw; c848 moved CALL(34) to 0x204,
+ * i.e. *before* the 0x3810 run, so the
+ * 8x3 vertex fetch used the previous
+ * (stale/zero) stream state. Anchor
+ * the move at the first run after the
+ * 0x3810 span instead.
+ */
+ if (call) {
+ bool vs2 = false;
+
+ for (k = 0; k < nk; k++) {
+ u32 m = m0 + 4u * k;
+
+ if (m >= 0x3800u &&
+ m < 0x3a00u &&
+ ((m - 0x3800u) / 8u) == 2u)
+ vs2 = true;
+ }
+ if (vs2)
+ vs_end = rr + span;
+ if (!first)
+ first = vs2 ? rr + span :
+ rr;
+ }
if (slot34 && !s34) {
s34 = rr;
s34span = span;
@@ -25522,6 +25573,8 @@ 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;
@@ -29001,10 +29054,36 @@ static u32 gsp_phys_gr_pair_n;
* Diagnostic only; the pair arrays are written under gsp_phys_rm_lock, so
* READ_ONCE keeps the census from tearing a line during a live submit.
*/
+/*
+ * eng89: bit accessors for the SPH V4T1 attribute-map blocks. Word N bit B
+ * of the little-endian image is byte (N*4 + B/8), bit (B%8). IMAP occupies
+ * absolute bits 184..399 and OMAP 424..639 (OMAP = IMAP + 240), so mapping
+ * the whole 216-bit block between stages needs an unaligned bit copy (the
+ * blocks are 8 bits off a halfword). x86-only driver: LE byte order.
+ */
+static inline u32 gsp_sph_bit_get(const u8 *p, u32 bit)
+{
+ return (p[bit >> 3] >> (bit & 7u)) & 1u;
+}
+
+static inline void gsp_sph_bit_put(u8 *p, u32 bit, u32 v)
+{
+ if (v)
+ p[bit >> 3] |= (u8)(1u << (bit & 7u));
+ else
+ p[bit >> 3] &= (u8)~(1u << (bit & 7u));
+}
+
+/* Attribute-map block geometry (SPH V4T1): IMAP at bit 184, OMAP at 424. */
+#define GSP_SPH_IMAP_BIT 184u
+#define GSP_SPH_OMAP_BIT 424u
+#define GSP_SPH_MAP_BITS 216u
+
static void gsp_phys_ds_image_census(const char *tag, u32 h_object,
const u32 s[6], const u32 u[6])
{
u32 w0[6] = { 0 }, code[6] = { 0 };
+ u32 w5[6] = { 0 }, w10[6] = { 0 }, w13[6] = { 0 }, w17[6] = { 0 };
u32 si, pi, n = READ_ONCE(gsp_phys_gr_pair_n);
for (si = 0; si < 6u; si++) {
@@ -29022,10 +29101,14 @@ static void gsp_phys_ds_image_census(const char *tag, u32 h_object,
continue;
ph = READ_ONCE(gsp_phys_gr_pair_hpa[pi]) + (va - pv);
if (pfn_valid((unsigned long)(ph >> PAGE_SHIFT))) {
- w0[si] = get_unaligned_le32(
- (const u8 *)__va(ph));
- code[si] = get_unaligned_le32(
- (const u8 *)__va(ph) + 0x80u);
+ const u8 *ip = (const u8 *)__va(ph);
+
+ w0[si] = get_unaligned_le32(ip);
+ code[si] = get_unaligned_le32(ip + 0x80u);
+ w5[si] = get_unaligned_le32(ip + 20u);
+ w10[si] = get_unaligned_le32(ip + 40u);
+ w13[si] = get_unaligned_le32(ip + 52u);
+ w17[si] = get_unaligned_le32(ip + 68u);
}
break;
}
@@ -29034,6 +29117,9 @@ static void gsp_phys_ds_image_census(const char *tag, u32 h_object,
tag, h_object,
w0[0], code[0], w0[1], code[1], w0[2], code[2],
w0[3], code[3], w0[4], code[4], w0[5], code[5]);
+ pr_info_ratelimited("vgsp-gr: DS-MAP %s h=0x%x st4 w5=%08x w10=%08x w13=%08x w17=%08x st5 w5=%08x w10=%08x w13=%08x\n",
+ tag, h_object, w5[4], w10[4], w13[4], w17[4],
+ w5[5], w10[5], w13[5]);
}
/*
@@ -33075,6 +33161,72 @@ gr_page_unmapped:
gsp_phys_gr_sph_alias_receipt(
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");
+ }
+ }
}
}
}
@@ -33386,6 +33538,22 @@ gr_page_unmapped:
in[nfin++] = 0x20000000u | (1u << 16) |
(0x0e00u >> 2);
in[nfin++] = 0u;
+ if (READ_ONCE(gsp_phys_rmcall_gr_raster_en)) {
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x037cu >> 2);
+ in[nfin++] = 1u; /* RASTER_ENABLE TRUE */
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0130u >> 2);
+ in[nfin++] = 0u;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0134u >> 2);
+ in[nfin++] = 0u;
+ in[nfin++] = 0x20000000u | (1u << 16) |
+ (0x0138u >> 2);
+ in[nfin++] = 1u; /* MODE_TRUE */
+ pr_info_ratelimited("vgsp-gr: RASTER-ENABLE emitted raster=1 gre=1 h=0x%x push=0x%llx\n",
+ req->h_object, req->push_va);
+ }
}
/*
* eng67: full-RT viewport for the replay context (see
diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c
index 455adff..69b7341 100644
--- a/kernel/gsp_sema_service.c
+++ b/kernel/gsp_sema_service.c
@@ -13127,9 +13127,16 @@ static void svc_gl_flush(struct nv_vgpu_device *vgpu,
gs_words[17] = 0u;
} else if (gs_maps == 3u) {
gs_words[17] = 0u;
- } else if (gs_maps == 4u) {
+ } else if (gs_maps == 4u || gs_maps == 6u) {
/* IMAP = previous OMAP; OMAP =
- * PS IMAP exactly (POSITION.W). */
+ * PS IMAP exactly (POSITION.W).
+ * maps=6 is the live-derived
+ * variant: the booter rewrites
+ * the whole 216-bit blocks from
+ * the bound VTG/PS images at
+ * authoring time; these words
+ * are the safe fallback when the
+ * booter cannot derive. */
gs_words[5] = 0xf0000000u;
gs_words[10] = 0x0000000fu;
gs_words[13] = 0x00008000u;