From e5d1b3d6ab61b85b945400fcbd3637052feb2ace Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Wed, 30 Sep 2026 05:23:28 -0400 Subject: sema-svc: sema_copy_watch (size-keyed src/dst byte audit for the CE data path) --- kernel/gsp_sema_service.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'kernel/gsp_sema_service.c') diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c index 56285bf..4d3f6ef 100644 --- a/kernel/gsp_sema_service.c +++ b/kernel/gsp_sema_service.c @@ -343,6 +343,7 @@ struct sema_svc { u64 memsets_fail; u64 ring_ops; /* op runs from ring-decoded pushes */ u64 lda_log; /* LAUNCH_DMA inventory budget */ + u64 copy_watch_log; /* sema_copy_watch log budget */ u64 entry_log; /* per-push summary budget */ u64 ops_denied; /* work refused: implausible stream */ u64 false_trans; /* resolvable VA mapped to non-push */ @@ -2019,6 +2020,41 @@ static int svc_copy(struct nv_vgpu_device *vgpu, u64 dst, u64 src, size_t total, src_aperture = aper; } + /* + * Data-path watch: for copies of exactly sema_copy_watch bytes, log + * the first 8 source and destination bytes so a broken link in the + * chain (wrong source page, wrong destination, silent wipe) is + * visible directly in the log. + */ + if (gsp_sema_copy_watch && total == gsp_sema_copy_watch) { + u8 sb[8] = {0}, db[8] = {0}; + + if (src_aperture == CE_APERTURE_VID) { + u8 *base = vgpu->bars[1].vaddr; + + if (base && src + 8 <= vgpu->bars[1].size) + memcpy(sb, base + src, 8); + } else { + svc_read(vgpu, src, sb, 8); + } + if (dst_aperture == CE_APERTURE_VID) { + u8 *base = vgpu->bars[1].vaddr; + + if (base && dst + 8 <= vgpu->bars[1].size) + memcpy(db, base + dst, 8); + } else { + svc_read(vgpu, dst, db, 8); + } + if (svc.copy_watch_log < 64) { + svc.copy_watch_log++; + pr_info("sema-copy-watch: total=%zu dst=0x%llx dap=%u src=0x%llx sap=%u src8=%02x %02x %02x %02x %02x %02x %02x %02x dst8_before=%02x %02x %02x %02x %02x %02x %02x %02x\n", + total, dst, dst_aperture, src, src_aperture, + sb[0], sb[1], sb[2], sb[3], sb[4], sb[5], + sb[6], sb[7], db[0], db[1], db[2], db[3], + db[4], db[5], db[6], db[7]); + } + } + for (o = 0; o < total; ) { size_t chunk = total - o; u32 i; @@ -3685,6 +3721,9 @@ bool gsp_sema_skip_ops; /* Executed-op log cap (see header). */ unsigned gsp_sema_ops_log = 8; +/* Data-path watch: copy size whose first bytes are logged (0 = off). */ +unsigned gsp_sema_copy_watch; + static unsigned long svc_gr_ring_tried; /* ranks that got a diagnostic line */ static void svc_gr_ring_autopin(struct nv_vgpu_device *vgpu, -- cgit v1.2.3