Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-24 Thread Luck, Tony
On Fri, Sep 24, 2021 at 04:03:53PM -0700, Andy Lutomirski wrote: > 1. The context switch code needs to resync PASID. Unfortunately, this adds > some overhead to every context switch, although a static_branch could > minimize it for non-PASID users. Any solution that adds to context switch time

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-24 Thread Andy Lutomirski
On Fri, Sep 24, 2021, at 9:12 AM, Luck, Tony wrote: > On Fri, Sep 24, 2021 at 03:18:12PM +0200, Thomas Gleixner wrote: >> On Thu, Sep 23 2021 at 19:48, Thomas Gleixner wrote: >> > On Thu, Sep 23 2021 at 09:40, Tony Luck wrote: >> > >> > fpu_write_task_pasid() can just grab the pasid from

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-24 Thread Fenghua Yu
Hi, Thomas, On Fri, Sep 24, 2021 at 03:18:12PM +0200, Thomas Gleixner wrote: > On Thu, Sep 23 2021 at 19:48, Thomas Gleixner wrote: > > On Thu, Sep 23 2021 at 09:40, Tony Luck wrote: > > > > fpu_write_task_pasid() can just grab the pasid from current->mm->pasid > > and be done with it. > > > >

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-24 Thread Luck, Tony
On Fri, Sep 24, 2021 at 03:18:12PM +0200, Thomas Gleixner wrote: > On Thu, Sep 23 2021 at 19:48, Thomas Gleixner wrote: > > On Thu, Sep 23 2021 at 09:40, Tony Luck wrote: > > > > fpu_write_task_pasid() can just grab the pasid from current->mm->pasid > > and be done with it. > > > > The task exit

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-24 Thread Luck, Tony
On Fri, Sep 24, 2021 at 03:37:22PM +0200, Peter Zijlstra wrote: > On Thu, Sep 23, 2021 at 10:14:42AM -0700, Luck, Tony wrote: > > On Wed, Sep 22, 2021 at 11:07:22PM +0200, Peter Zijlstra wrote: > > > On Mon, Sep 20, 2021 at 07:23:45PM +, Fenghua Yu wrote: > > > > @@ -538,6 +547,9 @@

Re: [PATCH] iommu/dart: Clear sid2group entry when a group is freed

2021-09-24 Thread Marc Zyngier
On Fri, 24 Sep 2021 14:45:02 +0100, Sven Peter wrote: > > sid2groups keeps track of which stream id combinations belong to a > iommu_group to assign those correctly to devices. > When a iommu_group is freed a stale pointer will however remain in > sid2groups. This prevents devices with the same

[PATCH] iommu/dart: Clear sid2group entry when a group is freed

2021-09-24 Thread Sven Peter via iommu
sid2groups keeps track of which stream id combinations belong to a iommu_group to assign those correctly to devices. When a iommu_group is freed a stale pointer will however remain in sid2groups. This prevents devices with the same stream id combination to ever be attached again (see below). Fix

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-24 Thread Peter Zijlstra
On Thu, Sep 23, 2021 at 10:14:42AM -0700, Luck, Tony wrote: > On Wed, Sep 22, 2021 at 11:07:22PM +0200, Peter Zijlstra wrote: > > On Mon, Sep 20, 2021 at 07:23:45PM +, Fenghua Yu wrote: > > > @@ -538,6 +547,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) > > > > > >

Re: [PATCH v3 5/8] x86/sme: Replace occurrences of sme_active() with cc_platform_has()

2021-09-24 Thread Tom Lendacky via iommu
On 9/24/21 4:51 AM, Borislav Petkov wrote: On Fri, Sep 24, 2021 at 12:41:32PM +0300, Kirill A. Shutemov wrote: On Thu, Sep 23, 2021 at 08:21:03PM +0200, Borislav Petkov wrote: On Thu, Sep 23, 2021 at 12:05:58AM +0300, Kirill A. Shutemov wrote: Unless we find other way to guarantee

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-24 Thread Thomas Gleixner
On Thu, Sep 23 2021 at 19:48, Thomas Gleixner wrote: > On Thu, Sep 23 2021 at 09:40, Tony Luck wrote: > > fpu_write_task_pasid() can just grab the pasid from current->mm->pasid > and be done with it. > > The task exit code can just call iommu_pasid_put_task_ref() from the > generic code and not

[PATCH 5/5] iommu/iova: Avoid double-negatives in magazine helpers

2021-09-24 Thread John Garry
A similar crash to the following could be observed if initial CPU rcache magazine allocations fail in init_iova_rcaches(): Unable to handle kernel NULL pointer dereference at virtual address Mem abort info: free_iova_fast+0xfc/0x280 iommu_dma_free_iova+0x64/0x70

[PATCH 3/5] iommu: Move IOVA flush queue code to dma-iommu

2021-09-24 Thread John Garry
Only dma-iommu.c uses the FQ code, so relocate it there. There is nothing really IOVA specific in the FQ code anyway. Signed-off-by: John Garry --- drivers/iommu/dma-iommu.c | 258 +- drivers/iommu/iova.c | 198 -

[PATCH 4/5] iommu: Separate IOVA rcache memories from iova_domain structure

2021-09-24 Thread John Garry
Only dma-iommu.c and vdpa actually use the "fast" mode of IOVA alloc and free. As such, it's wasteful that all other IOVA domains hold the rcache memories. In addition, the current IOVA domain init implementation is poor (init_iova_domain()), in that errors are ignored and not passed to the

[PATCH 2/5] iommu: Separate flush queue memories from IOVA domain structure

2021-09-24 Thread John Garry
Only dma-iommu.c uses the FQ, so it is wasteful and slightly disorganised to hold all the FQ memories in the iova_domain structure. So create a new structure, fq_domain, which is a new separate member in iommu_dma_cookie for DMA IOVA type. Signed-off-by: John Garry ---

[PATCH 1/5] iova: Move fast alloc size roundup into alloc_iova_fast()

2021-09-24 Thread John Garry
It really is a property of the IOVA rcache code that we need to alloc a power-of-2 size, so relocate the functionality to resize into alloc_iova_fast(), rather than the callsites. Signed-off-by: John Garry --- drivers/iommu/dma-iommu.c| 8 drivers/iommu/iova.c

[PATCH 0/5] iommu: Some IOVA code reorganisation

2021-09-24 Thread John Garry
The IOVA domain structure is a bit overloaded, holding: - IOVA tree management - FQ control - IOVA rcache memories Indeed only a couple of IOVA users use the rcache, and only dma-iommu.c uses the FQ feature. This series separates out that structure. In addition, it moves the FQ code into

Re: [PATCH v3 5/8] x86/sme: Replace occurrences of sme_active() with cc_platform_has()

2021-09-24 Thread Borislav Petkov
On Fri, Sep 24, 2021 at 12:41:32PM +0300, Kirill A. Shutemov wrote: > On Thu, Sep 23, 2021 at 08:21:03PM +0200, Borislav Petkov wrote: > > On Thu, Sep 23, 2021 at 12:05:58AM +0300, Kirill A. Shutemov wrote: > > > Unless we find other way to guarantee RIP-relative access, we must use > > >

Re: [PATCH v3 5/8] x86/sme: Replace occurrences of sme_active() with cc_platform_has()

2021-09-24 Thread Kirill A. Shutemov
On Thu, Sep 23, 2021 at 08:21:03PM +0200, Borislav Petkov wrote: > On Thu, Sep 23, 2021 at 12:05:58AM +0300, Kirill A. Shutemov wrote: > > Unless we find other way to guarantee RIP-relative access, we must use > > fixup_pointer() to access any global variables. > > Yah, I've asked compiler folks

Re: [PATCH v2 9/9] iommu/vt-d: Use pci core's DVSEC functionality

2021-09-24 Thread Christoph Hellwig
On Thu, Sep 23, 2021 at 10:26:47AM -0700, Ben Widawsky wrote: > */ > static int siov_find_pci_dvsec(struct pci_dev *pdev) > { > + return pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_INTEL, 5); > } I hink the siov_find_pci_dvsec helper is pretty pointless now and can be folded into its