summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhu Lingshan <lingshan.zhu@amd.com>2025-10-13 15:58:31 +0800
committerAlex Deucher <alexander.deucher@amd.com>2025-12-08 14:19:30 -0500
commite3491fa3f3c94d47e7b82604ca7b9925987f1683 (patch)
tree1d8d89e37facd0cca03b51757c5433c40dd6334a
parent3ec1a42f5f4ba877374a22a8da45d219772ac968 (diff)
amdkfd: process debug trap ioctl only on a primary context
Set_debug_trap ioctl should work on a specific kfd_process even when multiple contexts feature is implemented. For consistency, this commit allow set_debug_trap ioctl only work on the primary kfd process of a user space program Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 14bee49f0bf9..092a2b8aaea1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2931,6 +2931,12 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
struct kfd_process_device *pdd = NULL;
int r = 0;
+ if (p->context_id != KFD_CONTEXT_ID_PRIMARY) {
+ pr_debug("Set debug trap ioctl can not be invoked on non-primary kfd process\n");
+
+ return -EOPNOTSUPP;
+ }
+
if (sched_policy == KFD_SCHED_POLICY_NO_HWS) {
pr_err("Debugging does not support sched_policy %i", sched_policy);
return -EINVAL;
@@ -2975,6 +2981,12 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
goto out;
}
+ if (target->context_id != KFD_CONTEXT_ID_PRIMARY) {
+ pr_debug("Set debug trap ioctl not supported on non-primary kfd process\n");
+ r = -EOPNOTSUPP;
+ goto out;
+ }
+
/* Check if target is still PTRACED. */
rcu_read_lock();
if (target != p && args->op != KFD_IOC_DBG_TRAP_DISABLE