Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-22 Thread Xu Yilun
On Wed, Jan 22, 2025 at 08:55:12AM -0400, Jason Gunthorpe wrote: > On Wed, Jan 22, 2025 at 12:32:56PM +0800, Xu Yilun wrote: > > On Tue, Jan 21, 2025 at 01:43:03PM -0400, Jason Gunthorpe wrote: > > > On Tue, Jun 25, 2024 at 05:12:10AM +0800, Xu Yilun wrote: > > > >

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-21 Thread Xu Yilun
On Tue, Jan 21, 2025 at 01:43:03PM -0400, Jason Gunthorpe wrote: > On Tue, Jun 25, 2024 at 05:12:10AM +0800, Xu Yilun wrote: > > > When VFIO works as a TEE user in VM, it means an attester (e.g. PCI > > subsystem) has already moved the device to RUN state. So VFIO & DPDK >

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-21 Thread Xu Yilun
On Mon, Jan 20, 2025 at 02:44:13PM +0100, Christian König wrote: > Am 21.06.24 um 00:02 schrieb Xu Yilun: > > On Thu, Jan 16, 2025 at 04:13:13PM +0100, Christian König wrote: > > > Am 15.01.25 um 18:09 schrieb Jason Gunthorpe: > > > > > > On Wed, Jan 15,

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-20 Thread Xu Yilun
On Mon, Jan 20, 2025 at 09:25:25AM -0400, Jason Gunthorpe wrote: > On Mon, Jun 24, 2024 at 03:59:53AM +0800, Xu Yilun wrote: > > > But it also seems to me that VFIO should be able to support putting > > > the device into the RUN state > > > > Firstly I think V

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-19 Thread Xu Yilun
5 00:35, Jason Gunthorpe wrote: > > > > > On Tue, Jun 18, 2024 at 07:28:43AM +0800, Xu Yilun wrote: > > > > > > > > > > > > is needed so the secure world can prepare anything it needs prior > > > > > > > to > &

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-16 Thread Xu Yilun
On Thu, Jan 16, 2025 at 04:13:13PM +0100, Christian König wrote: >Am 15.01.25 um 18:09 schrieb Jason Gunthorpe: > > On Wed, Jan 15, 2025 at 05:34:23PM +0100, Christian König wrote: > > Granted, let me try to improve this. > Here is a real world example of one of the issues we ran int

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-16 Thread Xu Yilun
On Thu, Jan 16, 2025 at 06:33:48AM +0100, Christoph Hellwig wrote: > On Wed, Jan 15, 2025 at 09:34:19AM -0400, Jason Gunthorpe wrote: > > > Or do you mean some that don't have pages associated with them, and > > > thus have pfn_valid fail on them? They still have a PFN, just not > > > one that is

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-14 Thread Xu Yilun
On Mon, Jan 13, 2025 at 12:49:35PM -0400, Jason Gunthorpe wrote: > On Sat, Jan 11, 2025 at 11:48:06AM +0800, Xu Yilun wrote: > > > > > > can be sure what is the correct UAPI. In other words, make the > > > > > VFIO device into a CC device shou

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-13 Thread Xu Yilun
On Fri, Jan 10, 2025 at 04:38:38PM -0400, Jason Gunthorpe wrote: > On Fri, Jan 10, 2025 at 08:34:55PM +0100, Simona Vetter wrote: > > > So if I'm getting this right, what you need from a functional pov is a > > dma_buf_tdx_mmap? Because due to tdx restrictions, the normal dma_buf_mmap I'm not sur

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-11 Thread Xu Yilun
On Fri, Jan 10, 2025 at 09:31:16AM -0400, Jason Gunthorpe wrote: > On Fri, Jan 10, 2025 at 12:40:28AM +0800, Xu Yilun wrote: > > > So then we face with the shared <-> private device conversion in CoCo VM, > > and in turn shared <-> private MMIO conversion. MMIO re

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-09 Thread Xu Yilun
On Thu, Jan 09, 2025 at 10:40:51AM -0400, Jason Gunthorpe wrote: > On Thu, Jan 09, 2025 at 12:57:58AM +0800, Xu Yilun wrote: > > On Wed, Jan 08, 2025 at 09:30:26AM -0400, Jason Gunthorpe wrote: > > > On Tue, Jan 07, 2025 at 10:27:15PM +0800, Xu Yilun wrote: > >

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-09 Thread Xu Yilun
> So I guess my first question is, which locking rules do you want here for > pfn importers? > > follow_pfn() is unwanted for private MMIO, so dma_resv_lock. > >As Sima explained you either have follow_pfn() and mmu_notifier or you >have DMA addresses and dma_resv lock / dma_fence. >

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-08 Thread Xu Yilun
On Wed, Jan 08, 2025 at 07:44:54PM +0100, Simona Vetter wrote: > On Wed, Jan 08, 2025 at 12:22:27PM -0400, Jason Gunthorpe wrote: > > On Wed, Jan 08, 2025 at 04:25:54PM +0100, Christian König wrote: > > > Am 08.01.25 um 15:58 schrieb Jason Gunthorpe: > > > > I have imagined a staged approach were D

Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-08 Thread Xu Yilun
> > > 5) iommufd and kvm are both using CPU addresses without DMA. No > > > exporter mapping is possible > > > > We have customers using both KVM and XEN with DMA-buf, so I can clearly > > confirm that this isn't true. > > Today they are mmaping the dma-buf into a VMA and then using KVM's > follo

Re: [RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-08 Thread Xu Yilun
On Wed, Jan 08, 2025 at 09:30:26AM -0400, Jason Gunthorpe wrote: > On Tue, Jan 07, 2025 at 10:27:15PM +0800, Xu Yilun wrote: > > Add a flag for ioctl(VFIO_DEVICE_BIND_IOMMUFD) to mark a device as > > for private assignment. For these private assigned devices, disallow > > host

[RFC PATCH 12/12] KVM: TDX: Implement TDX specific private MMIO map/unmap for SEPT

2025-01-07 Thread Xu Yilun
Implement TDX specific private MMIO map/unmap in existing TDP MMU hooks. Signed-off-by: Yan Zhao Signed-off-by: Xu Yilun --- TODO: This patch is still based on the earlier kvm-coco-queue version (v6.13-rc2). Will follow up the latest SEAMCALL wrapper change. [1] [1] https://lore.kernel.org

[RFC PATCH 11/12] KVM: x86/mmu: Export kvm_is_mmio_pfn()

2025-01-07 Thread Xu Yilun
From: Xu Yilun Export kvm_is_mmio_pfn() for KVM TDX to decide which seamcall should be used to setup SEPT leaf entry. TDX Module requires tdh_mem_page_aug() for memory page setup, and tdh_mmio_map() for MMIO setup. Signed-off-by: Yan Zhao Signed-off-by: Xu Yilun --- arch/x86/kvm/mmu.h

[RFC PATCH 10/12] KVM: vfio_dmabuf: Fetch VFIO specific dma-buf data for sanity check

2025-01-07 Thread Xu Yilun
device of the MMIO region is already assigned to the same CoCo VM. Signed-off-by: Xu Yilun --- virt/kvm/vfio_dmabuf.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/virt/kvm/vfio_dmabuf.c b/virt/kvm/vfio_dmabuf.c index c427ab39c68a..26e01b815ebf 100644 --- a/virt

[RFC PATCH 09/12] vfio/pci: Export vfio dma-buf specific info for importers

2025-01-07 Thread Xu Yilun
export struct kvm * handler attached to the vfio device. This allows KVM to do another sanity check. MMIO should only be assigned to a CoCo VM if its owner device is already assigned to the same VM. Signed-off-by: Xu Yilun --- drivers/vfio/pci/dma_buf.c | 24 include

[RFC PATCH 08/12] vfio/pci: Create host unaccessible dma-buf for private device

2025-01-07 Thread Xu Yilun
for these regions, instead add a new VFIO_REGION_INFO_FLAG_PRIVATE flag to indicate users should create dma-buf for MMIO mapping in KVM MMU. Signed-off-by: Xu Yilun --- drivers/vfio/device_cdev.c | 9 - drivers/vfio/pci/vfio_pci_core.c | 14 ++ drivers/vfio/pci

[RFC PATCH 06/12] KVM: Support vfio_dmabuf backed MMIO region

2025-01-07 Thread Xu Yilun
//lore.kernel.org/all/ywywgcih6biwz...@nvidia.com/ [2] https://lore.kernel.org/kvm/14-v4-0de2f6c78ed0+9d1-iommufd_...@nvidia.com/ Signed-off-by: Xu Yilun --- Documentation/virt/kvm/api.rst | 7 ++ include/linux/kvm_host.h | 18 + include/uapi/linux/kvm.h | 1 + virt/kvm/Kconf

[RFC PATCH 07/12] KVM: x86/mmu: Handle page fault for vfio_dmabuf backed MMIO

2025-01-07 Thread Xu Yilun
and toggles KVM_MEMORY_EXIT_FLAG_PRIVATE. Unlike gmem slot, vfio_dmabuf slot has only one backend MMIO resource, the switching of GFN's attribute won't change the way of getting PFN, the vfio_dmabuf specific way, kvm_vfio_dmabuf_get_pfn(). Signed-off-by: Xu Yilun --- arch/x86

[RFC PATCH 05/12] vfio/pci: Support get_pfn() callback for dma-buf

2025-01-07 Thread Xu Yilun
Implement get_pfn() callback for exported MMIO resources. Signed-off-by: Xu Yilun --- drivers/vfio/pci/dma_buf.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/dma_buf.c b/drivers/vfio/pci/dma_buf.c index 1d5f46744922

[RFC PATCH 04/12] vfio/pci: Allow MMIO regions to be exported through dma-buf

2025-01-07 Thread Xu Yilun
[1] https://lore.kernel.org/kvm/20240624065552.1572580-4-vivek.kasire...@intel.com/ [2] https://lore.kernel.org/all/ia0pr11mb7185fdd56cfdd0a2b8d21468f8...@ia0pr11mb7185.namprd11.prod.outlook.com/ Original-patch-by: Jason Gunthorpe Signed-off-by: Vivek Kasireddy Signed-off-by: Xu Yilun --- drivers

[RFC PATCH 03/12] vfio/pci: Share the core device pointer while invoking feature functions

2025-01-07 Thread Xu Yilun
From: Vivek Kasireddy There is no need to share the main device pointer (struct vfio_device *) with all the feature functions as they only need the core device pointer. Therefore, extract the core device pointer once in the caller (vfio_pci_core_ioctl_feature) and share it instead. Signed-off-by

[RFC PATCH 02/12] vfio: Export vfio device get and put registration helpers

2025-01-07 Thread Xu Yilun
From: Vivek Kasireddy These helpers are useful for managing additional references taken on the device from other associated VFIO modules. Original-patch-by: Jason Gunthorpe Signed-off-by: Vivek Kasireddy --- drivers/vfio/vfio_main.c | 2 ++ include/linux/vfio.h | 2 ++ 2 files changed, 4

[RFC PATCH 00/12] Private MMIO support for private assigned dev

2025-01-07 Thread Xu Yilun
evolving of basic TDX patches. Vivek Kasireddy (3): vfio: Export vfio device get and put registration helpers vfio/pci: Share the core device pointer while invoking feature functions vfio/pci: Allow MMIO regions to be exported through dma-buf Xu Yilun (9): dma-buf: Introduce dma_buf_get_

[RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI

2025-01-07 Thread Xu Yilun
e importer choose to do dynamic attach, it also should handle the dma-buf move notification. Only the unlocked version of dma_buf_get_pfn is implemented for now, just because no locked version is used for now. Signed-off-by: Xu Yilun --- IIUC, Only get_pfn() is needed but no put_pfn(). The whole

Re: [PATCH v2 2/4] eventfd: simplify eventfd_signal()

2023-11-22 Thread Xu Yilun
2,7 @@ static irqreturn_t dfl_irq_handler(int irq, void *arg) > { > struct eventfd_ctx *trigger = arg; > > - eventfd_signal(trigger, 1); > + eventfd_signal(trigger); For FPGA part, Acked-by: Xu Yilun > return IRQ_HANDLED; > }