From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64F2BEA4FC3 for ; Mon, 23 Feb 2026 14:04:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 203E910E440; Mon, 23 Feb 2026 14:04:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QDtG9GLu"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F0FF10E43F for ; Mon, 23 Feb 2026 14:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771855466; x=1803391466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H6F13ZC1bfzT9/sZXWrKuRHc1LhJ6abtxwXK2Ow4Okw=; b=QDtG9GLuIHsAJvXrQX8e52BMxicDCbmlgCuO4oXvCWmDDtTuIdjsn7sK Fx93Fv5h/U9vq4eSgtiDPX2eSS78ZJzw9bHT22eOBQ5xBM5Ysxi1N6AEq qFmzFH5redoi+xP+leIfkxQwdvvfwTocKhQKEyDKRHPtfT7VJbiiVPd1t 9BJ7IarMg5ZHIcEJZmmgRaLfDFyDAFwH+8oPPNWqL9mdPM9lt7+FrntIF 5Gr0kE8r35IKNCcVsN2Aaw4/5mtSLAsOK50apYKuZk4lPQiHvNWDcZ12s kz2bCeE06EQQbOW1kawhA2+lO5BEAYNKtbD5DQ3g3scCaJeCbHd8xV4yx w==; X-CSE-ConnectionGUID: jiNQ3VJ3RLKlotluFzQrpw== X-CSE-MsgGUID: pUNZkCCNSfqlO2rFuLQpQg== X-IronPort-AV: E=McAfee;i="6800,10657,11709"; a="76460913" X-IronPort-AV: E=Sophos;i="6.21,306,1763452800"; d="scan'208";a="76460913" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2026 06:04:26 -0800 X-CSE-ConnectionGUID: Uxr+wLVmSt+X+gPLYUAEwQ== X-CSE-MsgGUID: aD1hTTDnS+OLmIPLx8N8SQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,306,1763452800"; d="scan'208";a="214656386" Received: from ettammin-mobl3.ger.corp.intel.com (HELO mkuoppal-desk.intel.com) ([10.245.246.3]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2026 06:04:21 -0800 From: Mika Kuoppala To: intel-xe@lists.freedesktop.org Cc: simona.vetter@ffwll.ch, matthew.brost@intel.com, christian.koenig@amd.com, thomas.hellstrom@linux.intel.com, joonas.lahtinen@linux.intel.com, christoph.manszewski@intel.com, rodrigo.vivi@intel.com, andrzej.hajda@intel.com, matthew.auld@intel.com, maciej.patelczyk@intel.com, gwan-gyeong.mun@intel.com, Mika Kuoppala , Simona Vetter , Dominik Grzegorzek Subject: [PATCH 12/22] drm/xe/eudebug: userptr vm pread/pwrite Date: Mon, 23 Feb 2026 16:03:07 +0200 Message-ID: <20260223140318.1822138-13-mika.kuoppala@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223140318.1822138-1-mika.kuoppala@linux.intel.com> References: <20260223140318.1822138-1-mika.kuoppala@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Implement debugger vm access for userptrs. When bind is done, take ref to current task so that we know from which vm the address was bound. Then during debugger pread/pwrite we use this target task as parameter to access the debuggee vm with access_process_vm(). This is based on suggestions from Simona, Thomas and Joonas. v2: need to add offset into vma (Dominik) v3: move code into xe_userptr.c (Mika) Cc: Simona Vetter Cc: Matthew Brost Cc: Andrzej Hajda Cc: Thomas Hellström Cc: Dominik Grzegorzek Cc: Christian König Cc: Joonas Lahtinen Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/xe/xe_eudebug_vm.c | 16 +++++++++++++++ drivers/gpu/drm/xe/xe_userptr.c | 4 ++++ drivers/gpu/drm/xe/xe_userptr.h | 32 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_eudebug_vm.c b/drivers/gpu/drm/xe/xe_eudebug_vm.c index 4cf6d2e79658..074443a792be 100644 --- a/drivers/gpu/drm/xe/xe_eudebug_vm.c +++ b/drivers/gpu/drm/xe/xe_eudebug_vm.c @@ -51,6 +51,22 @@ static int xe_eudebug_vma_access(struct xe_vma *vma, xe_bo_put(bo); return ret; + } else if (xe_vma_is_userptr(vma)) { + struct xe_userptr *userptr = &to_userptr_vma(vma)->userptr; + + if (XE_WARN_ON(!userptr->eudebug.task)) + return -EINVAL; + + /* + * access_remote_vm() would fit as userptr notifier has + * mm ref so we would not need to carry task ref at all. + * But access_remote_vm is not exported. access_process_vm() + * is exported so use it instead. + */ + return access_process_vm(userptr->eudebug.task, + xe_vma_userptr(vma) + offset_in_vma, + buf, bytes, + write ? FOLL_WRITE : 0); } return -EINVAL; diff --git a/drivers/gpu/drm/xe/xe_userptr.c b/drivers/gpu/drm/xe/xe_userptr.c index e120323c43bc..5932f9f0cce3 100644 --- a/drivers/gpu/drm/xe/xe_userptr.c +++ b/drivers/gpu/drm/xe/xe_userptr.c @@ -292,6 +292,8 @@ int xe_userptr_setup(struct xe_userptr_vma *uvma, unsigned long start, userptr->pages.notifier_seq = LONG_MAX; + xe_eudebug_track_userptr_task(userptr); + return 0; } @@ -300,6 +302,8 @@ void xe_userptr_remove(struct xe_userptr_vma *uvma) struct xe_vm *vm = xe_vma_vm(&uvma->vma); struct xe_userptr *userptr = &uvma->userptr; + xe_eudebug_untrack_userptr_task(userptr); + drm_gpusvm_free_pages(&vm->svm.gpusvm, &uvma->userptr.pages, xe_vma_size(&uvma->vma) >> PAGE_SHIFT); diff --git a/drivers/gpu/drm/xe/xe_userptr.h b/drivers/gpu/drm/xe/xe_userptr.h index ef801234991e..4af2569f1fa1 100644 --- a/drivers/gpu/drm/xe/xe_userptr.h +++ b/drivers/gpu/drm/xe/xe_userptr.h @@ -66,6 +66,12 @@ struct xe_userptr { #if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT) u32 divisor; #endif + +#if IS_ENABLED(CONFIG_DRM_XE_EUDEBUG) + struct { + struct task_struct *task; + } eudebug; +#endif }; #if IS_ENABLED(CONFIG_DRM_GPUSVM) @@ -104,4 +110,30 @@ static inline void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma) { } #endif + +#if IS_ENABLED(CONFIG_DRM_XE_EUDEBUG) +static inline void xe_eudebug_track_userptr_task(struct xe_userptr *userptr) +{ + /* + * We could use the mm which is on notifier. But + * the access_remote_vm() is not exported. Thus + * we get reference to task for access_process_vm() + */ + userptr->eudebug.task = get_task_struct(current); +} + +static inline void xe_eudebug_untrack_userptr_task(struct xe_userptr *userptr) +{ + put_task_struct(userptr->eudebug.task); +} +#else +static inline void xe_eudebug_track_userptr_task(struct xe_userptr *userptr) +{ +} + +static inline void xe_eudebug_untrack_userptr_task(struct xe_userptr *userptr) +{ +} +#endif /* CONFIG_DRM_XE_EUDEBUG */ + #endif -- 2.43.0