diff options
author | CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com> | 2025-04-30 12:48:06 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2025-05-14 05:39:15 -0400 |
commit | b1c84782bfddeaa0070f5ae57ac2e4e3992f9f19 (patch) | |
tree | c364bc81a98bc2eddab523c8edbfb415e626521e | |
parent | 77a9408fc774ad99dcd16ea08f31b96b590fbf99 (diff) | |
download | qemu-b1c84782bfddeaa0070f5ae57ac2e4e3992f9f19.zip qemu-b1c84782bfddeaa0070f5ae57ac2e4e3992f9f19.tar.gz qemu-b1c84782bfddeaa0070f5ae57ac2e4e3992f9f19.tar.bz2 |
intel_iommu: Use BQL_LOCK_GUARD to manage cleanup automatically
vtd_switch_address_space needs to take the BQL if not already held.
Use BQL_LOCK_GUARD to make the iommu implementation more consistent.
Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
Message-Id: <20250430124750.240412-2-clement.mathieu--drif@eviden.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | hw/i386/intel_iommu.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 5f8ed12..b925e65 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1728,8 +1728,6 @@ static bool vtd_as_pt_enabled(VTDAddressSpace *as) static bool vtd_switch_address_space(VTDAddressSpace *as) { bool use_iommu, pt; - /* Whether we need to take the BQL on our own */ - bool take_bql = !bql_locked(); assert(as); @@ -1746,9 +1744,7 @@ static bool vtd_switch_address_space(VTDAddressSpace *as) * from vtd_pt_enable_fast_path(). However the memory APIs need * it. We'd better make sure we have had it already, or, take it. */ - if (take_bql) { - bql_lock(); - } + BQL_LOCK_GUARD(); /* Turn off first then on the other */ if (use_iommu) { @@ -1801,10 +1797,6 @@ static bool vtd_switch_address_space(VTDAddressSpace *as) memory_region_set_enabled(&as->iommu_ir_fault, false); } - if (take_bql) { - bql_unlock(); - } - return use_iommu; } |