From 5c47eacbe01f9353f2c21d96e1a3eb15a63fd991 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Wed, 23 Sep 2026 11:46:33 -0400 Subject: kernel: coherent GSP-RM replies for engine-context creation - GSP_RM_ALLOC: echo the request payload back with status forced to NV_OK. The kernel driver copies the reply params over the caller's params buffer using the class-expected size, so a zeroed reply smashed libcuda's stack (SIGSEGV at the engine-registration continuation); echoing makes the copy-back idempotent. - CE_GET_PHYSICAL_CAPS / CE_GET_ALL(_PHYSICAL)_CAPS: report sysmem, P2P and BL copy caps and mark the GR-synchronous CE (GRCE, COPY0). Without a GRCE the client's context walk ends with an empty secondary-engine record and the engine RM alloc is issued with class 0 (rejected -> cuCtxCreate fails). - TU104 engine table: CE0 shares the GR PBDMA ids (the driver's GR/GRCE runqueue validation requires it), plus an entry for the async copy engine (COPY14) advertised in the GSP static info engine caps. - tools/guest-diag/ioctl_trace: decode the RM status fields of alloc, control and free so the first failing driver call is visible in traces. gitignore: keep the CUDA analysis scratch tree (incl. WORKING-HERE.md) local. --- tools/guest-diag/ioctl_trace.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/guest-diag/ioctl_trace.c b/tools/guest-diag/ioctl_trace.c index fd1802a..04fea05 100644 --- a/tools/guest-diag/ioctl_trace.c +++ b/tools/guest-diag/ioctl_trace.c @@ -38,17 +38,29 @@ static int read_child(pid_t pid, unsigned long addr, void *buf, size_t len) return 0; } -static void dump_alloc(pid_t pid, unsigned long arg) +static void dump_alloc(pid_t pid, unsigned long arg, unsigned int size) { unsigned int v[12]; + unsigned int st; if (read_child(pid, arg, v, sizeof(v))) return; - /* NVOS21_PARAMETERS: hRoot, hObjectParent, hObjectNew, hClass, - * pAllocParms, pRightsRequested, paramsSize, flags, status */ + /* NVOS21_PARAMETERS (0x20): ... paramsSize@0x14, status@0x10 + * NVOS64_PARAMETERS (0x30): ... status@0x28 */ + st = (size == 0x30) ? v[10] : v[4]; fprintf(stderr, - "[iot] alloc root=0x%x parent=0x%x new=0x%x class=0x%x params=%u flags=0x%x\n", - v[0], v[1], v[2], v[3], v[6], v[7]); + "[iot] alloc root=0x%x parent=0x%x new=0x%x class=0x%x st=0x%x\n", + v[0], v[1], v[2], v[3], st); +} + +static void dump_free(pid_t pid, unsigned long arg) +{ + unsigned int v[4]; + + if (read_child(pid, arg, v, sizeof(v))) + return; + /* NVOS00_PARAMETERS: hRoot, hObjectParent, hObjectOld, status */ + fprintf(stderr, "[iot] free old=0x%x st=0x%x\n", v[2], v[3]); } static void dump_control(pid_t pid, unsigned long arg) @@ -59,12 +71,13 @@ static void dump_control(pid_t pid, unsigned long arg) if (read_child(pid, arg, v, sizeof(v))) return; - /* NVOS54_PARAMETERS: hClient, hObject, cmd, flags, params, paramsSize, ... */ + /* NVOS54_PARAMETERS: hClient, hObject, cmd, flags, params, paramsSize, + * status@0x1c */ cmd = v[2]; memcpy(&pParams, &v[4], sizeof(pParams)); fprintf(stderr, - "[iot] control client=0x%x object=0x%x cmd=0x%x params=0x%llx size=%u\n", - v[0], v[1], cmd, pParams, v[5]); + "[iot] control client=0x%x object=0x%x cmd=0x%x params=0x%llx size=%u st=0x%x\n", + v[0], v[1], cmd, pParams, v[5], v[7]); } int main(int argc, char **argv) @@ -148,8 +161,10 @@ int main(int argc, char **argv) fprintf(stderr, "[iot] req=0x%llx arg=0x%llx ret=0x%llx\n", req, a2, ret); - if (req == 0xc030462bULL) - dump_alloc(pid, a2); + if ((req & 0xff) == 0x2b) + dump_alloc(pid, a2, (req >> 16) & 0x3fff); + else if ((req & 0xff) == 0x29) + dump_free(pid, a2); else if ((req & 0xff) == 0x2a) dump_control(pid, a2); } -- cgit v1.2.3