diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-07-03 12:44:32 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-07-03 12:44:32 -0400 |
| commit | 073e8978334a07e0053ee08310743ddf3046d7d2 (patch) | |
| tree | f73583c3ea3fd3c9416313736a697254bc866fed | |
| parent | a3fe3788535dd099d15e0ddca455be58e1d63156 (diff) | |
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
| -rw-r--r-- | device_info_procfs.c | 1 | ||||
| -rw-r--r-- | nvdebug.h | 2 | ||||
| -rw-r--r-- | nvdebug_entry.c | 2 | ||||
| -rw-r--r-- | 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, | |||
| 24 | } | 24 | } |
| 25 | struct file_operations nvdebug_read_reg32_file_ops = { | 25 | struct file_operations nvdebug_read_reg32_file_ops = { |
| 26 | .read = nvdebug_reg32_read, | 26 | .read = nvdebug_reg32_read, |
| 27 | .llseek = default_llseek, | ||
| 27 | }; | 28 | }; |
| 28 | 29 | ||
| 29 | //// ==v== PTOP_DEVICE_INFO ==v== //// | 30 | //// ==v== PTOP_DEVICE_INFO ==v== //// |
| @@ -951,7 +951,7 @@ static inline int file2parentgpuidx(const struct file *f) { | |||
| 951 | // was upgraded from Linux 4.9 to 5.10 (r32 -> r34+) | 951 | // was upgraded from Linux 4.9 to 5.10 (r32 -> r34+) |
| 952 | // Note that this is wrong if nvgpu was built without CONFIG_NVGPU_NON_FUSA | 952 | // Note that this is wrong if nvgpu was built without CONFIG_NVGPU_NON_FUSA |
| 953 | // i.e. if FUSA was enabled, this is wrong. | 953 | // i.e. if FUSA was enabled, this is wrong. |
| 954 | #define gk20a_regs(gk20a) ((void*)gk20a + sizeof(void(*)(void))) | 954 | #define gk20a_regs(gk20a) (*(void**)((void*)gk20a + sizeof(void(*)(void)))) |
| 955 | #else | 955 | #else |
| 956 | #include <os/linux/os_linux.h> // For struct nvgpu_os_linux, which holds regs | 956 | #include <os/linux/os_linux.h> // For struct nvgpu_os_linux, which holds regs |
| 957 | #define gk20a_regs(gk20a) (container_of(gk20a, struct nvgpu_os_linux, g)->regs) | 957 | #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; | |||
| 35 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) | 35 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) |
| 36 | // This rewrites the struct to the proc_ops layout on newer kernels | 36 | // This rewrites the struct to the proc_ops layout on newer kernels |
| 37 | const struct proc_ops* compat_ops(const struct file_operations* ops) { | 37 | const struct proc_ops* compat_ops(const struct file_operations* ops) { |
| 38 | struct proc_ops new_ops; | 38 | struct proc_ops new_ops = {}; |
| 39 | new_ops.proc_open = ops->open; | 39 | new_ops.proc_open = ops->open; |
| 40 | new_ops.proc_read = ops->read; | 40 | new_ops.proc_read = ops->read; |
| 41 | new_ops.proc_write = ops->write; | 41 | 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, | |||
| 201 | 201 | ||
| 202 | struct file_operations preempt_tsg_file_ops = { | 202 | struct file_operations preempt_tsg_file_ops = { |
| 203 | .write = preempt_tsg_file_write, | 203 | .write = preempt_tsg_file_write, |
| 204 | .llseek = default_llseek, | ||
| 204 | }; | 205 | }; |
| 205 | 206 | ||
| 206 | ssize_t disable_channel_file_write(struct file *f, const char __user *buffer, | 207 | 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, | |||
| 238 | 239 | ||
| 239 | struct file_operations disable_channel_file_ops = { | 240 | struct file_operations disable_channel_file_ops = { |
| 240 | .write = disable_channel_file_write, | 241 | .write = disable_channel_file_write, |
| 242 | .llseek = default_llseek, | ||
| 241 | }; | 243 | }; |
| 242 | 244 | ||
| 243 | ssize_t enable_channel_file_write(struct file *f, const char __user *buffer, | 245 | 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, | |||
| 264 | 266 | ||
| 265 | struct file_operations enable_channel_file_ops = { | 267 | struct file_operations enable_channel_file_ops = { |
| 266 | .write = enable_channel_file_write, | 268 | .write = enable_channel_file_write, |
| 269 | .llseek = default_llseek, | ||
| 267 | }; | 270 | }; |
| 268 | 271 | ||
| 269 | ssize_t switch_to_tsg_file_write(struct file *f, const char __user *buffer, | 272 | 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, | |||
| 319 | 322 | ||
| 320 | struct file_operations switch_to_tsg_file_ops = { | 323 | struct file_operations switch_to_tsg_file_ops = { |
| 321 | .write = switch_to_tsg_file_write, | 324 | .write = switch_to_tsg_file_write, |
| 325 | .llseek = default_llseek, | ||
| 322 | }; | 326 | }; |
