From 3b9432714a0515b89309ff2e6c1983690fb67761 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Thu, 24 Sep 2026 01:58:15 -0400 Subject: kernel: validate learned semaphore maps and post guest GPU events - admit {GPU VA -> PA} pairs only when the preceding bytes form a valid client memory descriptor header (type 0/1, CPU+GPU mapped bits), prefer validated pairs over headerless candidates under first-wins dedup, and invalidate the translation cache on every rebuild; fixes stale identity entries shadowing live pool pages and lets the guest UVM channel bring-up complete on its own - capture OS event allocations (class 0x79) and post event records (function 0x1003) into the guest status queue when a channel's busy notification is consumed, with a broadcast fallback, serialized with replies via a queue lock - add BAR0 shadow introspection (dump_bar0/scan_bar0) and guest-side diagnostic scripts for the VM cycle --- kernel/gsp_rm_emulation.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'kernel/gsp_rm_emulation.h') diff --git a/kernel/gsp_rm_emulation.h b/kernel/gsp_rm_emulation.h index a82656f..1ab0a83 100644 --- a/kernel/gsp_rm_emulation.h +++ b/kernel/gsp_rm_emulation.h @@ -40,9 +40,13 @@ struct gsp_emu_context; #define GSPRM_RPC_FUNC_GSP_SET_SYSTEM_INFO 72 #define GSPRM_RPC_FUNC_SET_REGISTRY 73 #define GSPRM_RPC_FUNC_CONTINUATION_RECORD 71 +#define GSPRM_RPC_FUNC_SET_PAGE_DIRECTORY 54 +#define GSPRM_RPC_FUNC_UNSET_PAGE_DIRECTORY 79 #define GSPRM_RPC_FUNC_GSP_RM_CONTROL 76 #define GSPRM_RPC_FUNC_GSP_RM_ALLOC 103 #define GSPRM_RPC_FUNC_FREE 10 +#define GSPRM_RPC_EVENT_POST_EVENT 0x1003 +#define GSPRM_MAX_EVENTS 128 #define GSPRM_RPC_EVENT_GSP_INIT_DONE 0x1001 /* rpc_set_guest_system_info_v03_00: version fields the driver reads back @@ -168,10 +172,29 @@ struct gsp_rm_emu { u32 alloc_dumps; /* raw GSP_RM_ALLOC dumps emitted */ u32 alloc_param_dumps; /* alloc param dumps emitted */ u32 ctrl_param_dumps; /* control param dumps emitted */ + + /* + * NV01_EVENT objects (class 0x5, allocated via class 0x79 in the + * guest ABI). Each carries {hSrcResource, notifyIndex, data}; the + * driver allocates one per channel and waits for the GPU to post the + * event before it considers submitted work complete. + */ + struct mutex stat_lock; /* serializes status-queue writers */ + struct { + u32 h_src; /* source object (channel handle) */ + u32 h_event; /* event handle */ + u32 h_client; /* owning client */ + u32 notify_index; + u32 data; + bool valid; + } events[GSPRM_MAX_EVENTS]; + u32 events_n; + u64 events_posted; }; int gsp_rm_emu_init(struct nv_vgpu_device *vgpu, struct gsp_emu_context *ctx); void gsp_rm_emu_fini(struct gsp_emu_context *ctx); +int gsp_rm_post_channel_event(struct nv_vgpu_device *vgpu, u32 h_src); int gsp_rm_scan_guest_ram(struct nv_vgpu_device *vgpu, u64 needle, u64 start, u64 end, u32 max_hits); int gsp_rm_scan_guest_ram_seq(struct nv_vgpu_device *vgpu, const u32 *pat, -- cgit v1.2.3