[PATCH v3 14/14] iommu/arm-smmu-v3: Report IRQs that belong to devices attached to vIOMMU

2024-12-17 Thread Nicolin Chen
Aside from the IOPF framework, iommufd provides an additional pathway to report a hardware event or IRQ, via the vIRQ of vIOMMU infrastructure. Define an iommu_virq_arm_smmuv3 uAPI structure, and report stage-1 faults in the threaded IRQ handler. Signed-off-by: Nicolin Chen --- drivers/iommu/ar

[PATCH v3 13/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2024-12-17 Thread Nicolin Chen
Use it to store all vSMMU-related data. The vsid (Virtual Stream ID) will be the first use case. Then, add a rw_semaphore to protect it. Also add a pair of arm_smmu_attach_prepare/commit_vmaster helpers to set or unset the master->vmaster point. Put these helpers inside the existing arm_smmu_attac

[PATCH v3 11/14] iommufd/selftest: Add IOMMU_VIRQ_ALLOC test coverage

2024-12-17 Thread Nicolin Chen
Trigger a vIRQ giving an idev ID, to test the loopback whether receiving or not the vdev_id that was set to the idev by the line above. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 63 +++ tools/testing/selftests/iommu/iommufd.c | 22 +

[PATCH v3 12/14] Documentation: userspace-api: iommufd: Update FAULT and VIRQ

2024-12-17 Thread Nicolin Chen
With the introduction of the new objects, update the doc to reflect that. Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 16 1 file changed, 16 insertions(+) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api/iommufd.r

[PATCH v3 10/14] iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VIRQ for vIRQ coverage

2024-12-17 Thread Nicolin Chen
The handler will get vDEVICE object from the given mdev and convert it to its per-vIOMMU virtual ID to mimic a real IOMMU driver. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 10 ++ drivers/iommu/iommufd/selftest.c | 30 2 files

[PATCH v3 09/14] iommufd/selftest: Require vdev_id when attaching to a nested domain

2024-12-17 Thread Nicolin Chen
When attaching a device to a vIOMMU-based nested domain, vdev_id must be present. Add a piece of code hard-requesting it, for vIRQ support in the following patch. Then, update the TEST_F. A HWPT-based nested domain will return a NULL new_viommu, thus no such a vDEVICE requirement. Signed-off-by:

[PATCH v3 08/14] iommufd/viommu: Add iommufd_viommu_report_irq helper

2024-12-17 Thread Nicolin Chen
Similar to iommu_report_device_fault, this allows IOMMU drivers to report, from threaded IRQ handlers to user space hypervisors, IRQs or events that belong to a vIOMMU. Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 9 + drivers/iommu/iommufd/driver.c | 37

[PATCH v3 07/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

2024-12-17 Thread Nicolin Chen
This is a reverse search v.s. iommufd_viommu_find_dev, as drivers may want to convert a struct device pointer (physical) to its virtual device ID for an event injection to the user space VM. Again, this avoids exposing more core structures to the drivers, than the iommufd_viommu alone. Signed-off

[PATCH v3 06/14] iommufd: Add IOMMUFD_OBJ_VIRQ and IOMMUFD_CMD_VIRQ_ALLOC

2024-12-17 Thread Nicolin Chen
Allow a vIOMMU object to allocate vIRQ Event Queues, with a condition that each vIOMMU can only have one single vIRQ event queue per type. Add iommufd_eventq_virq_alloc with an iommufd_eventq_virq_ops for this new ioctl. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h |

[PATCH v3 05/14] iommufd: Rename fault.c to eventq.c

2024-12-17 Thread Nicolin Chen
Rename the file, aligning with the new eventq object. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/{fault.c => eventq.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/iommu/iommufd/{fault.

[PATCH v3 04/14] iommufd: Abstract an iommufd_eventq from iommufd_fault

2024-12-17 Thread Nicolin Chen
The fault object was designed exclusively for hwpt's IO page faults (PRI). But its queue implementation can be reused for other purposes too, such as hardware IRQ and event injections to user space. Meanwhile, a fault object holds a list of faults. So it's more accurate to call it a "fault queue".

[PATCH v3 02/14] iommufd/fault: Add an iommufd_fault_init() helper

2024-12-17 Thread Nicolin Chen
The infrastructure of a fault object will be shared with a new vIRQ object in a following change. Add a helper for a vIRQ allocator to call it too. Reorder the iommufd_ctx_get and refcount_inc to keep them symmetrical with the iommufd_fault_fops_release(). Since the new vIRQ object doesn't need "

[PATCH v3 03/14] iommufd/fault: Move iommufd_fault_iopf_handler() to header

2024-12-17 Thread Nicolin Chen
The new vIRQ object will need a similar function for drivers to report the vIOMMU related interrupts. Split the common part out to a smaller helper, and place it in the header so that CONFIG_IOMMUFD_DRIVER_CORE can include that in the driver.c file for drivers to use. Then keep iommufd_fault_iopf_

[PATCH v3 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vIRQ)

2024-12-17 Thread Nicolin Chen
As the part-3 of the vIOMMU infrastructure, this series introduces a vIRQ object. The existing FAULT object provides a nice notification pathway to the user space already, so let vIRQ reuse the infrastructure. Mimicing the HWPT structure, add a common EVENTQ structure to support its derivatives: I

[PATCH v3 01/14] iommufd: Keep IOCTL list in an alphabetical order

2024-12-17 Thread Nicolin Chen
Move VDEVICE upward to keep the order. Also run clang-format keep the same coding style at line wrappings. No functional change. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/main.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/iommufd/m

Re: [PATCH 2/3] KVM: x86: Add support for VMware guest specific hypercalls

2024-12-17 Thread Sean Christopherson
On Thu, Dec 12, 2024, Doug Covelli wrote: > On Thu, Nov 14, 2024 at 10:45 AM Doug Covelli > wrote: > > > For LINT1, it should be less performance critical; if it's possible > > > to just go through all vCPUs, and do KVM_GET_LAPIC to check who you > > > should send a KVM_NMI to, then I'd do that.

Re: [PATCH v4 18/25] gup: Don't allow FOLL_LONGTERM pinning of FS DAX pages

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:13, Alistair Popple wrote: Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Nit: I'd consi

Re: [PATCH v4 19/25] proc/task_mmu: Ignore ZONE_DEVICE pages

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:13, Alistair Popple wrote: The procfs mmu files such as smaps currently ignore device dax and fs dax pages because these pages are considered special. To maintain existing behaviour once these pages are treated as normal pages and returned from vm_normal_page() add tests to explici

Re: [PATCH v4 20/25] mm/mlock: Skip ZONE_DEVICE PMDs during mlock

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:13, Alistair Popple wrote: At present mlock skips ptes mapping ZONE_DEVICE pages. A future change to remove pmd_devmap will allow pmd_trans_huge_lock() to return ZONE_DEVICE folios so make sure we continue to skip those. Signed-off-by: Alistair Popple --- mm/mlock.c | 2 ++ 1

Re: [PATCH v4 14/25] rmap: Add support for PUD sized mappings to rmap

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:12, Alistair Popple wrote: The rmap doesn't currently support adding a PUD mapping of a folio. This patch adds support for entire PUD mappings of folios, primarily to allow for more standard refcounting of device DAX folios. Currently DAX is the only user of this and it doesn't req

Re: [PATCH v4 10/25] mm/mm_init: Move p2pdma page refcount initialisation to p2pdma

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:12, Alistair Popple wrote: Currently ZONE_DEVICE page reference counts are initialised by core memory management code in __init_zone_device_page() as part of the memremap() call which driver modules make to obtain ZONE_DEVICE pages. This initialises page refcounts to 1 before retur

Re: [PATCH v4 09/25] mm/gup.c: Remove redundant check for PCI P2PDMA page

2024-12-17 Thread David Hildenbrand
On 17.12.24 06:12, Alistair Popple wrote: PCI P2PDMA pages are not mapped with pXX_devmap PTEs therefore the check in __gup_device_huge() is redundant. Remove it Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Wiliams Acked-by: David Hildenbrand --- Nit: patch