From: Gwan-gyeong Mun <gwan-gyeong.mun@xxxxxxxxx> The XE2 (and PVC) HW has a limitation that the pagefault due to invalid access will halt the corresponding EUs. So, in order to activate the debugger, kmd needs to install the temporal page to unhalt the EUs. Plan to be used for pagefault handling when the EU debugger is running. The idea is to install a null page vma if the pagefault is from an invalid access. After installing null page pte, the user debugger can continue to run/inspect without causing a fatal failure or reset and stop. Based on Bruce's implementation [1]. [1] https://lore.kernel.org/intel-xe/20230829231648.4438-1-yu.bruce.chang@xxxxxxxxx/ Cc: Oak Zeng <oak.zeng@xxxxxxxxx> Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@xxxxxxxxx> Cc: Stuart Summers <stuart.summers@xxxxxxxxx> Cc: Matthew Brost <matthew.brost@xxxxxxxxx> Co-developed-by: Bruce Chang <yu.bruce.chang@xxxxxxxxx> Signed-off-by: Bruce Chang <yu.bruce.chang@xxxxxxxxx> Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@xxxxxxxxx> Signed-off-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/xe/xe_vm.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_vm.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index 474521d0fea9..ff45e5264aed 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -3552,3 +3552,26 @@ int xe_vm_userptr_access(struct xe_userptr_vma *uvma, u64 offset, up_read(&vm->userptr.notifier_lock); return ret; } + +struct xe_vma *xe_vm_create_null_vma(struct xe_vm *vm, u64 addr) +{ + struct xe_vma *vma; + u32 page_size; + int err; + + if (xe_vm_is_closed_or_banned(vm)) + return ERR_PTR(-ENOENT); + + page_size = vm->flags & XE_VM_FLAG_64K ? SZ_64K : SZ_4K; + vma = xe_vma_create(vm, NULL, 0, addr, addr + page_size - 1, 0, VMA_CREATE_FLAG_IS_NULL); + if (IS_ERR_OR_NULL(vma)) + return vma; + + err = xe_vm_insert_vma(vm, vma); + if (err) { + xe_vma_destroy_late(vma); + return ERR_PTR(err); + } + + return vma; +} diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h index 372ad40ad67f..2ae3749cfd82 100644 --- a/drivers/gpu/drm/xe/xe_vm.h +++ b/drivers/gpu/drm/xe/xe_vm.h @@ -283,3 +283,5 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap); int xe_vm_userptr_access(struct xe_userptr_vma *uvma, u64 offset, void *buf, u64 len, bool write); + +struct xe_vma *xe_vm_create_null_vma(struct xe_vm *vm, u64 addr); -- 2.43.0