summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-30 07:25:45 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-30 07:25:45 -0400
commit0ffc3bf8effd69af2910ad38294cb99894c6b44b (patch)
tree8ddf0108163afdfef67b2f1dada6d2e26c86ae3e
parent06a6e25d6bce4a24018df97ee7c72fcb9734d950 (diff)
downloadopen-iov-0ffc3bf8effd69af2910ad38294cb99894c6b44b.tar.gz
open-iov-0ffc3bf8effd69af2910ad38294cb99894c6b44b.zip
guest-diag: cdt2 scans its own mappings for the payload after HtoD (DtoH mechanism probe)
-rw-r--r--tools/test/cuda_drv_test2.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/test/cuda_drv_test2.c b/tools/test/cuda_drv_test2.c
index a146bc2..cfe21d8 100644
--- a/tools/test/cuda_drv_test2.c
+++ b/tools/test/cuda_drv_test2.c
@@ -58,6 +58,52 @@ static void pause_env(const char *name)
}
}
+/*
+ * Scan this process's readable mappings for the payload pattern and print
+ * every mapping that looks like a device/BAR window. This answers whether the
+ * HtoD bytes are visible to the client CPU at all: the DtoH path can only be a
+ * CPU read if some mapping of this process contains them.
+ */
+static void scan_self_for_payload(const char *tag)
+{
+ const unsigned long long pat = 0x0000000400000001ULL;
+ FILE *f = fopen("/proc/self/maps", "r");
+ char line[512];
+ int hits = 0;
+
+ printf("SCAN %s:\n", tag);
+ if (!f) { printf("SCAN %s: no maps\n", tag); return; }
+ while (fgets(line, sizeof(line), f)) {
+ unsigned long long a = 0, b = 0, off = 0;
+ char perms[8] = {0};
+ char path[256] = {0};
+
+ if (sscanf(line, "%llx-%llx %7s %llx %*s %*s %255[^\n]",
+ &a, &b, &perms, &off, path) < 4)
+ continue;
+ if (strstr(path, "vfio") || strstr(path, "nvidia") ||
+ strstr(path, "/dev/"))
+ printf("MAP %s: %llx-%llx %s off=%llx %s\n", tag, a, b,
+ perms, off, path);
+ if (perms[0] != 'r' || b <= a || b - a > (512ULL << 20))
+ continue;
+ {
+ volatile unsigned long long *p;
+ for (p = (volatile unsigned long long *)a;
+ (unsigned long long)p + 8 <= b; p++) {
+ if (*p == pat && hits < 16) {
+ hits++;
+ printf("SCAN %s: payload at %p (map %llx-%llx %s %s)\n",
+ tag, (void *)p, a, b, perms, path);
+ }
+ }
+ }
+ }
+ if (!hits)
+ printf("SCAN %s: payload not visible in any mapping\n", tag);
+ fclose(f);
+}
+
int main(void)
{
setvbuf(stdout, NULL, _IONBF, 0);
@@ -121,9 +167,11 @@ int main(void)
MARK("cuMemcpyHtoD");
CHECK(cuMemcpyHtoD(dptr, buf, sizeof(buf)));
pause_env("CDT_HP_PAUSE");
+ scan_self_for_payload("after-HtoD");
memset(back, 0, sizeof(back));
MARK("cuMemcpyDtoH");
CHECK(cuMemcpyDtoH(back, dptr, sizeof(buf)));
+ scan_self_for_payload("after-DtoH");
{
size_t matched = 0;
for (i = 0; i < 64; i++)