Patch "iommu/vt-d: Allow to use flush-queue when first level is default" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iommu/vt-d: Allow to use flush-queue when first level is default

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iommu-vt-d-allow-to-use-flush-queue-when-first-level.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d86253a5f4475541f2e7665c3e6e0a7c41dd6d22
Author: Tina Zhang <tina.zhang@xxxxxxxxx>
Date:   Thu Feb 16 21:08:16 2023 +0800

    iommu/vt-d: Allow to use flush-queue when first level is default
    
    [ Upstream commit 257ec290741924f8df678927d0dfecb1deebb9c5 ]
    
    Commit 29b32839725f ("iommu/vt-d: Do not use flush-queue when caching-mode
    is on") forced default domains to be strict mode as long as IOMMU
    caching-mode is flagged. The reason for doing this is that when vIOMMU
    uses VT-d caching mode to synchronize shadowing page tables, the strict
    mode shows better performance.
    
    However, this optimization is orthogonal to the first-level page table
    because the Intel VT-d architecture does not define the caching mode of
    the first-level page table. Refer to VT-d spec, section 6.1, "When the
    CM field is reported as Set, any software updates to remapping
    structures other than first-stage mapping (including updates to not-
    present entries or present entries whose programming resulted in
    translation faults) requires explicit invalidation of the caches."
    Exclude the first-level page table from this optimization.
    
    Generally using first-stage translation in vIOMMU implies nested
    translation enabled in the physical IOMMU. In this case the first-stage
    page table is wholly captured by the guest. The vIOMMU only needs to
    transfer the cache invalidations on vIOMMU to the physical IOMMU.
    Forcing the default domain to strict mode will cause more frequent
    cache invalidations, resulting in performance degradation. In a real
    performance benchmark test measured by iperf receive, the performance
    result on Sapphire Rapids 100Gb NIC shows:
    w/ this fix ~51 Gbits/s, w/o this fix ~39.3 Gbits/s.
    
    Theoretically a first-stage IOMMU page table can still be shadowed
    in absence of the caching mode, e.g. with host write-protecting guest
    IOMMU page table to synchronize changed PTEs with the physical
    IOMMU page table. In this case the shadowing overhead is decoupled
    from emulating IOTLB invalidation then the overhead of the latter part
    is solely decided by the frequency of IOTLB invalidations. Hence
    allowing guest default dma domain to be lazy can also benefit the
    overall performance by reducing the total VM-exit numbers.
    
    Fixes: 29b32839725f ("iommu/vt-d: Do not use flush-queue when caching-mode is on")
    Reported-by: Sanjay Kumar <sanjay.k.kumar@xxxxxxxxx>
    Suggested-by: Sanjay Kumar <sanjay.k.kumar@xxxxxxxxx>
    Signed-off-by: Tina Zhang <tina.zhang@xxxxxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230214025618.2292889-1-tina.zhang@xxxxxxxxx
    Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
    Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 494a872cbf9bd..82d18eb02266c 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4051,7 +4051,8 @@ int __init intel_iommu_init(void)
 		 * is likely to be much lower than the overhead of synchronizing
 		 * the virtual and physical IOMMU page-tables.
 		 */
-		if (cap_caching_mode(iommu->cap)) {
+		if (cap_caching_mode(iommu->cap) &&
+		    !first_level_by_default(IOMMU_DOMAIN_DMA)) {
 			pr_info_once("IOMMU batching disallowed due to virtualization\n");
 			iommu_set_dma_strict();
 		}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux