All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Wei Wang <wei.w.wang@hotmail.com>,
	"alex@shazbot.org" <alex@shazbot.org>,
	"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
	"vasant.hegde@amd.com" <vasant.hegde@amd.com>,
	"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
	"joro@8bytes.org" <joro@8bytes.org>, "aik@amd.com" <aik@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH v3 2/2] vfio/type1: Set IOMMU_MMIO in dma->prot for MMIO-backed addresses
Date: Fri, 12 Dec 2025 03:00:17 -0400	[thread overview]
Message-ID: <aTu9gUxtvWsmG+WD@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB5276D5D7338261F48FB863188CAEA@BN9PR11MB5276.namprd11.prod.outlook.com>

On Fri, Dec 12, 2025 at 02:36:46AM +0000, Tian, Kevin wrote:
> > From: Wei Wang <wei.w.wang@hotmail.com>
> > Sent: Thursday, November 13, 2025 11:54 PM
> > 
> > @@ -629,6 +630,8 @@ static long vaddr_get_pfns(struct mm_struct *mm,
> > unsigned long vaddr,
> >  				ret = -EFAULT;
> >  			}
> >  		}
> > +		if (vma->vm_flags & VM_IO)
> > +			*prot |= IOMMU_MMIO;
> 
> move into "if (is_invalid_reserved_pfn(*pfn)) {}". it's pointless to set
> it in the error path.
> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> 
> btw another alternative is letting userspace set a map flag explicitly
> e.g. introducing a new VFIO_DMA_MAP_FLAG_MMIO flag bit. It's
> not considered because your use case requires existing VMMs to
> work?

I don't think we should do that, userspace shouldn't be able to create
a mapping inconsistent with the rest of the kernel for security
reasons.

I think if we ever need a cachable mmio through to the iommu then it
should be wired through the dmabuf mechanism the same way vfio drivers
wire the cachability when they make the mmap.

The nvgrace is the only driver that creates a cachable mmap already,
and it would be more correct to have a cachable IOPTE, but the only HW
tha driver works with does not care either way so it has been left.

Jason

  reply	other threads:[~2025-12-12  7:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 15:54 [PATCH v3 0/2] iommu: Avoid setting C-bit for MMIO addresses Wei Wang
2025-11-13 15:54 ` [PATCH v3 1/2] iommupt: Do not set C-bit on MMIO backed PTEs Wei Wang
2025-11-17 19:15   ` Jason Gunthorpe
2025-12-12  2:19   ` Tian, Kevin
2025-11-13 15:54 ` [PATCH v3 2/2] vfio/type1: Set IOMMU_MMIO in dma->prot for MMIO-backed addresses Wei Wang
2025-12-03  1:21   ` Wei Wang
2025-12-12  2:36   ` Tian, Kevin
2025-12-12  7:00     ` Jason Gunthorpe [this message]
2025-12-12  7:26       ` Tian, Kevin
2025-12-16  5:40         ` Wei Wang

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=aTu9gUxtvWsmG+WD@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=aik@amd.com \
    --cc=alex@shazbot.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=wei.w.wang@hotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.