drm/amdkfd: fix vmfault signalling with additional data.

Exception handling for vmfaults should be raised with additional data.

Reported-by: Mukul Joshi <mukul.joshi@amd.com>
Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Mukul Joshi <mukul.joshi@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Jonathan Kim 2023-06-07 03:56:27 -04:00 committed by Alex Deucher
parent 0bc3137b21
commit 7386f88ab1
1 changed files with 20 additions and 14 deletions

View File

@ -1240,19 +1240,24 @@ void kfd_signal_vm_fault_event(struct kfd_node *dev, u32 pasid,
return; return;
} }
memset(&memory_exception_data, 0, sizeof(memory_exception_data)); /* SoC15 chips and onwards will pass in data from now on. */
memory_exception_data.gpu_id = user_gpu_id; if (!data) {
memory_exception_data.failure.imprecise = true; memset(&memory_exception_data, 0, sizeof(memory_exception_data));
/* Set failure reason */ memory_exception_data.gpu_id = user_gpu_id;
if (info) { memory_exception_data.failure.imprecise = true;
memory_exception_data.va = (info->page_addr) << PAGE_SHIFT;
memory_exception_data.failure.NotPresent = /* Set failure reason */
info->prot_valid ? 1 : 0; if (info) {
memory_exception_data.failure.NoExecute = memory_exception_data.va = (info->page_addr) <<
info->prot_exec ? 1 : 0; PAGE_SHIFT;
memory_exception_data.failure.ReadOnly = memory_exception_data.failure.NotPresent =
info->prot_write ? 1 : 0; info->prot_valid ? 1 : 0;
memory_exception_data.failure.imprecise = 0; memory_exception_data.failure.NoExecute =
info->prot_exec ? 1 : 0;
memory_exception_data.failure.ReadOnly =
info->prot_write ? 1 : 0;
memory_exception_data.failure.imprecise = 0;
}
} }
rcu_read_lock(); rcu_read_lock();
@ -1261,7 +1266,8 @@ void kfd_signal_vm_fault_event(struct kfd_node *dev, u32 pasid,
idr_for_each_entry_continue(&p->event_idr, ev, id) idr_for_each_entry_continue(&p->event_idr, ev, id)
if (ev->type == KFD_EVENT_TYPE_MEMORY) { if (ev->type == KFD_EVENT_TYPE_MEMORY) {
spin_lock(&ev->lock); spin_lock(&ev->lock);
ev->memory_exception_data = memory_exception_data; ev->memory_exception_data = data ? *data :
memory_exception_data;
set_event(ev); set_event(ev);
spin_unlock(&ev->lock); spin_unlock(&ev->lock);
} }