From 073e8978334a07e0053ee08310743ddf3046d7d2 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Mon, 3 Jul 2023 12:44:32 -0400 Subject: Fix addressing, zero-init, and compatibility bugs in a3fe378 - Including missing dereference to finish getting the address of the control register range - Add zero-initialization to the proc_ops structure in copat_ops to insure that all intentionally unset fields remain unset - Set .llseek in all the file_operations structures, as recent kernels require this to be explictly set --- device_info_procfs.c | 1 + nvdebug.h | 2 +- nvdebug_entry.c | 2 +- runlist_procfs.c | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/device_info_procfs.c b/device_info_procfs.c index c96007a..1fc0586 100644 --- a/device_info_procfs.c +++ b/device_info_procfs.c @@ -24,6 +24,7 @@ static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, } struct file_operations nvdebug_read_reg32_file_ops = { .read = nvdebug_reg32_read, + .llseek = default_llseek, }; //// ==v== PTOP_DEVICE_INFO ==v== //// diff --git a/nvdebug.h b/nvdebug.h index 968a60b..8009b84 100644 --- a/nvdebug.h +++ b/nvdebug.h @@ -951,7 +951,7 @@ static inline int file2parentgpuidx(const struct file *f) { // was upgraded from Linux 4.9 to 5.10 (r32 -> r34+) // Note that this is wrong if nvgpu was built without CONFIG_NVGPU_NON_FUSA // i.e. if FUSA was enabled, this is wrong. -#define gk20a_regs(gk20a) ((void*)gk20a + sizeof(void(*)(void))) +#define gk20a_regs(gk20a) (*(void**)((void*)gk20a + sizeof(void(*)(void)))) #else #include // For struct nvgpu_os_linux, which holds regs #define gk20a_regs(gk20a) (container_of(gk20a, struct nvgpu_os_linux, g)->regs) diff --git a/nvdebug_entry.c b/nvdebug_entry.c index 60fb7af..8e8266c 100644 --- a/nvdebug_entry.c +++ b/nvdebug_entry.c @@ -35,7 +35,7 @@ unsigned int g_nvdebug_devices = 0; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) // This rewrites the struct to the proc_ops layout on newer kernels const struct proc_ops* compat_ops(const struct file_operations* ops) { - struct proc_ops new_ops; + struct proc_ops new_ops = {}; new_ops.proc_open = ops->open; new_ops.proc_read = ops->read; new_ops.proc_write = ops->write; diff --git a/runlist_procfs.c b/runlist_procfs.c index a0e71b0..d9ec6eb 100644 --- a/runlist_procfs.c +++ b/runlist_procfs.c @@ -201,6 +201,7 @@ ssize_t preempt_tsg_file_write(struct file *f, const char __user *buffer, struct file_operations preempt_tsg_file_ops = { .write = preempt_tsg_file_write, + .llseek = default_llseek, }; ssize_t disable_channel_file_write(struct file *f, const char __user *buffer, @@ -238,6 +239,7 @@ ssize_t disable_channel_file_write(struct file *f, const char __user *buffer, struct file_operations disable_channel_file_ops = { .write = disable_channel_file_write, + .llseek = default_llseek, }; ssize_t enable_channel_file_write(struct file *f, const char __user *buffer, @@ -264,6 +266,7 @@ ssize_t enable_channel_file_write(struct file *f, const char __user *buffer, struct file_operations enable_channel_file_ops = { .write = enable_channel_file_write, + .llseek = default_llseek, }; ssize_t switch_to_tsg_file_write(struct file *f, const char __user *buffer, @@ -319,4 +322,5 @@ ssize_t switch_to_tsg_file_write(struct file *f, const char __user *buffer, struct file_operations switch_to_tsg_file_ops = { .write = switch_to_tsg_file_write, + .llseek = default_llseek, }; -- cgit v1.2.2