From patchwork Mon Mar 24 21:57:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cavitt X-Patchwork-Id: 14027904 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 EA961C36002 for ; Mon, 24 Mar 2025 21:58:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE73510E4DD; Mon, 24 Mar 2025 21:57:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XN1hFuYQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7062810E4D8; Mon, 24 Mar 2025 21:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742853475; x=1774389475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hl8+lM11PRLmxBjMwYzmp398zmvgVeUwbwpOM7K9t/8=; b=XN1hFuYQ5USBg8qRCHmU9AiJPNUv0unP13aovBW6Qgzs8HIbOp4Adlfw Dok0059mwIi51Q2Sco64cSzsOUJCFkT3ypOupJZ7ez1GNoI04kO6T8Eh5 sx28RaIFgoBV+n5pklBdh767Bv1HdRwUNl2xcyvkf4vFTmfL8VtrBPfqr /JUesARiSEr/ppHFKsfTtKG6pvr7IVavMKrnPxIYaC/eprqhsTDKpZIay VuDCeCjIY1EJT3ULuPEzAaz1XW9p2pi7qy8mMhYu2/JSkLEYVBebhl3AH 3eHHGQniJivVO25L+lif11OunMy/8Gk7beYjFvfUwk3WKzZzO4tTr5j1Y Q==; X-CSE-ConnectionGUID: c+HWSMa5SFylgLJPKuKxJw== X-CSE-MsgGUID: PLfbSzSKSlCk8XAB6V/OjA== X-IronPort-AV: E=McAfee;i="6700,10204,11383"; a="54723279" X-IronPort-AV: E=Sophos;i="6.14,272,1736841600"; d="scan'208";a="54723279" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 14:57:55 -0700 X-CSE-ConnectionGUID: HqGzkaTLQfuLDiFQS7idkA== X-CSE-MsgGUID: r7YhSdBrSmu5Njc37PZwqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,272,1736841600"; d="scan'208";a="129236843" Received: from dut4419lnl.fm.intel.com ([10.105.10.61]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2025 14:57:54 -0700 From: Jonathan Cavitt To: intel-xe@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com, matthew.brost@intel.com, jianxun.zhang@intel.com, shuicheng.lin@intel.com, dri-devel@lists.freedesktop.org, Michal.Wajdeczko@intel.com, michal.mrozek@intel.com, raag.jadav@intel.com Subject: [PATCH v11 1/5] drm/xe/xe_gt_pagefault: Disallow writes to read-only VMAs Date: Mon, 24 Mar 2025 21:57:48 +0000 Message-ID: <20250324215753.70768-2-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250324215753.70768-1-jonathan.cavitt@intel.com> References: <20250324215753.70768-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The page fault handler should reject write/atomic access to read only VMAs. Add code to handle this in handle_pagefault after the VMA lookup. Fixes: 3d420e9fa848 ("drm/xe: Rework GPU page fault handling") Signed-off-by: Jonathan Cavitt Suggested-by: Matthew Brost --- drivers/gpu/drm/xe/xe_gt_pagefault.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c index 9fa11e837dd1..3240890aac07 100644 --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c @@ -237,6 +237,11 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf) goto unlock_vm; } + if (xe_vma_read_only(vma) && pf->access_type != ACCESS_TYPE_READ) { + err = -EPERM; + goto unlock_vm; + } + atomic = access_is_atomic(pf->access_type); if (xe_vma_is_cpu_addr_mirror(vma))