diff options
| -rw-r--r-- | kernel/gsp_phys_booter.c | 194 | ||||
| -rw-r--r-- | kernel/gsp_sema_service.c | 45 | ||||
| -rw-r--r-- | tools/guest-diag/params-r1624-maps6-780.txt | 13 |
3 files changed, 172 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; diff --git a/tools/guest-diag/params-r1624-maps6-780.txt b/tools/guest-diag/params-r1624-maps6-780.txt new file mode 100644 index 0000000..5c82983 --- /dev/null +++ b/tools/guest-diag/params-r1624-maps6-780.txt @@ -0,0 +1,13 @@ +gsp_phys_gpu=1 gsp_phys_hazard_ack=1 gsp_phys_boot=1 gsp_phys_nocat=1 gsp_phys_fw=nvidia/tu102/gsp/gsp-570.144.bin gsp_phys_guest_mem=1 gsp_phys_gr_forward=1 cuda_bridge=0 gsp_phys_rmcall_engine=1 gsp_phys_rmcall_golden=1 gsp_phys_rmcall_gr_promote=25 gsp_phys_rmcall_fwclient_mask=0x601 gsp_phys_rmcall_vas_shared=1 gsp_phys_gpu=1 gsp_phys_hazard_ack=1 gsp_phys_boot=1 gsp_phys_nocat=1 gsp_phys_fw=nvidia/tu102/gsp/gsp-570.144.bin gsp_phys_guest_mem=1 gsp_phys_gr_forward=1 cuda_bridge=0 gsp_phys_rmcall_engine=1 gsp_phys_rmcall_golden=1 gsp_phys_rmcall_gr_promote=35 gsp_phys_rmcall_fwclient_mask=0xE3F gsp_phys_rmcall_vas_shared=1 gsp_phys_gr_nowrite_retries=0 gsp_phys_gr_retry_fast=1 gsp_phys_gr_first_poll_ms=2500 gsp_sema_winfill=1 gsp_sema_gr_swrel_gate=1 gsp_phys_rmcall_srv_ctxcommit=0 gsp_phys_rmcall_gr_qmdwin=1 gsp_phys_rmcall_gr_shadow_win0=1 gsp_phys_rmcall_gr_lmem_en=1 gsp_phys_rmcall_gr_skedrec=1 gsp_phys_rmcall_gr_inst_sys=1 gsp_phys_rmcall_gr_r1_first=1 gsp_phys_gr_strict_reloc=0 gsp_phys_fault_relay=1 sema_bigcopy_log=512 sema_gl_xlate=1 gsp_phys_gr_min_data=0 gsp_phys_rmcall_gr_ptr_guest=0 sema_gr_xlate=1 sema_dbg=Y gsp_phys_gr_dec_log=32 gsp_phys_rmcall_gr_rel_mod=1 sema_vas_cand_ms=1000 sema_push_raw=64 binapi07_rep=0x0101 sema_push_raw_small=2000 sema_gr_copy_run_max=2 sema_kick_notify=Y sema_gl_idx_reloc=1 sema_gl_mme_reloc=1 sema_mme_census=1 sema_gr_setup_hold_ms=0 sema_attr_prelude_cap=1 sema_gl_attr_prelude=1 sema_gr_prelude_gate_ms=0 sema_gl_win_drop= sema_gl_attr_zero_fix=1 sema_gl_sdm_drop=1 sema_gl_miss_abort=1 sema_mme_fast_ms=2800 sema_gl_mme_sa_stub_all=N sema_gl_mme_keep_mask=0xffffffffffffffff sema_gl_mme_nop_drop=0x0 sema_gl_mme_hold_calls=1 sema_gl_mme_prelude=1 sema_gl_win_patch=124:0 sema_map_add_max=4096 sema_gl_mme_sa_rearm=0 sema_gl_sph_version=1 sema_gl_sph_bind=1 sema_gr_wedge_recover=1 sema_mme_prelude_cap=1 sema_gl_mme_track=0 sema_gl_mme_version=1 sema_gl_sph_canary=0 sema_gl_shader_exc=1 gsp_phys_rmcall_gr_pte_kind=0 gsp_phys_rmcall_ce_lane=1 sema_gl_mme_prelude_live_skip=1 sema_gl_mme_nop_pair=0 sema_mme_post_ms=20000 sema_gl_mme_seed=Y sema_gl_mme_seed_val=0x1207000 sema_gl_mme_state_seed=Y sema_mme_state_d26=0 sema_mme_state_d27=0 sema_mme_state_d28=0xffffffff sema_mme_state_d29=0 sema_mme_state_d2a=0x80000000 sema_gl_mme_prelude_pack=1 sema_gl_mme_pack_split=1 sema_gl_mme_iram_gate=1 sema_gl_mme_hold_fe_idle=0 sema_gl_mme_iram_gate_break=0 sema_gl_mme_iram_gate_build=0 sema_gl_wit_shown=1024 sema_gl_mme_keep_clamp=1 sema_gl_mme_golden=1 sema_gl_mme_golden_force=1 sema_sph_region_base=0x01500000 sema_gl_sph_8k=1 sema_mme_state_d19=0x1207000 sema_gl_mme_seed_xlat=1 sema_gl_mme_hold_strict=0 sema_gl_mme_hold_window=1 sema_gl_ps_hex=82140a0000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026730400ff0000001f000e0000020e0426730000ff000000a080000000620e0026730100ff000000a180020000a20e0026730200ff000000a280040000e20e0026730300ff000000a380060000220f0008730400040000000010000000641e00208200000400000000c0410000e42f08209201010400000000c0410000e44f0820a202020400000000c0410000c48f0020b203030400000000c0410000e20f014d790000000000000000800300ee0f0047790000f0ffffffffff830300c00f0018790000000000000000000000c00f0018790000000000000000000000c00f0018790000000000000000000000c00f0018790000000000000000000000c00f00 sema_gl_cb_copy_to=0x120700000 sema_gl_cb_src_va=0x0cd70000 sema_gl_sph_gs_img=1 sema_gl_sph_gs_maps=6 sema_gl_sph_gs_mode=1 sema_gl_sph_gs_addr=0 sema_gl_raster_prelude=1 sema_gl_sph_gs_ctx=3 sema_pub_adv=1 bus_gart_mb=4096 disp_caps_seed=1 disp_dbg=1 sema_gr_fb_push=1 sema_gl_mme_pack_carry_client=1 sema_gl_draw_synth=1 +sema_gr_grace_ms=500 sema_gl_mme_keep_done_across_recycle=1 sema_mme_prelude_cap_any=1 +sema_gl_rt0_bind=1 +sema_gl_mme_partial_keep_window=1 sema_gl_mme_pack_keep_gen=1 sema_gl_mme_cb_alias=1 + sema_gl_win_rt0_admit=1 + sema_ddx_tracker_auth=1 +sema_gl_mme_pack_carry=1 sema_gl_mme_pack_carry_ms=100 sema_gl_mme_pack_release=1 sema_gl_mme_pack_release_ms=100 + sema_gl_sph_bind_pair_safe=1 sema_gl_mme_sa_golden_fill=1 sema_gl_mme_release_sa_arm=1 + sema_gl_sph_stage_disable=0x04 + sema_gl_viewport=1 + sema_gl_vs_autobind=2 + sema_gl_wit_shown=40 + sema_gl_surf_alias_pref=1 |
