[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<SI2PR01MB4393F42495CB73A47FD3744BDCAAA@SI2PR01MB4393.apcprd01.prod.exchangelabs.com>
Date: Tue, 16 Dec 2025 13:40:37 +0800
From: Wei Wang <wei.w.wang@...mail.com>
To: "Tian, Kevin" <kevin.tian@...el.com>, Jason Gunthorpe <jgg@...dia.com>
Cc: "alex@...zbot.org" <alex@...zbot.org>,
"thomas.lendacky@....com" <thomas.lendacky@....com>,
"vasant.hegde@....com" <vasant.hegde@....com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"joro@...tes.org" <joro@...tes.org>, "aik@....com" <aik@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>
Subject: Re: [PATCH v3 2/2] vfio/type1: Set IOMMU_MMIO in dma->prot for
MMIO-backed addresses
On 12/12/25 3:26 PM, Tian, Kevin wrote:
>> From: Jason Gunthorpe <jgg@...dia.com>
>> Sent: Friday, December 12, 2025 3:00 PM
>>
>> On Fri, Dec 12, 2025 at 02:36:46AM +0000, Tian, Kevin wrote:
>>>> From: Wei Wang <wei.w.wang@...mail.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.
Yeah, that looks better, thanks.
>>>
>>> Reviewed-by: Kevin Tian <kevin.tian@...el.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.
>
> ah that's a good point!
>
>>
>> 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
>
Powered by blists - more mailing lists