mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Max Zhen <max.zhen@amd.com>
To: Lizhi Hou <lizhi.hou@amd.com>, <ogabbay@kernel.org>,
	<quic_jhugo@quicinc.com>, <mario.limonciello@amd.com>,
	<karol.wachowski@linux.intel.com>,
	<dri-devel@lists.freedesktop.org>
Cc: <linux-kernel@vger.kernel.org>, <sonal.santan@amd.com>
Subject: Re: [PATCH V3] accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults
Date: Thu, 17 Sep 2026 10:47:32 -0700	[thread overview]
Message-ID: <df2d1b7a-5dc6-4139-9fc8-43b92e78bd75@amd.com> (raw)
In-Reply-To: <20260917171952.1883974-1-lizhi.hou@amd.com>



On 9/17/2026 Thu 10:19, Lizhi Hou wrote:
> When aie2_populate_range() faults in pages, it only sets
> HMM_PFN_REQ_FAULT. Without HMM_PFN_REQ_WRITE, handle_mm_fault() does not
> request write permissions and may populate the CPU page tables with
> read-only PTEs.
> 
> Check the VMA flags and set HMM_PFN_REQ_WRITE when the VMA has VM_WRITE.
> 
> Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
> V3:
>    Revert the V2 change. Instead, add comment to describe why it is not
> an issue.
> V2:
>    Fix sashiko comment.
> 
>   drivers/accel/amdxdna/amdxdna_gem.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index e861db6f9369..a5e30855c8a1 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -418,7 +418,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
>   	mapp->range.notifier = &mapp->notifier;
>   	mapp->range.start = vma->vm_start;
>   	mapp->range.end = vma->vm_end;
> +	/*
> +	 * Access permissions are fixed at mmap() time. Changing them later
> +	 * with mprotect() is not supported: the range keeps requesting the
> +	 * original permissions, so the application may see a fault failure
> +	 * or an IOMMU fault.
> +	 */
>   	mapp->range.default_flags = HMM_PFN_REQ_FAULT;
> +	if (vma->vm_flags & VM_WRITE)
> +		mapp->range.default_flags |= HMM_PFN_REQ_WRITE;
>   	mapp->abo = abo;
>   	kref_init(&mapp->refcnt);
>   


      reply	other threads:[~2026-09-17 17:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 17:19 Lizhi Hou
2026-09-17 17:47 ` Max Zhen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df2d1b7a-5dc6-4139-9fc8-43b92e78bd75@amd.com \
    --to=max.zhen@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karol.wachowski@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhi.hou@amd.com \
    --cc=mario.limonciello@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=quic_jhugo@quicinc.com \
    --cc=sonal.santan@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®