[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/17] intel_iommu: fix missing BQL in pt fast path
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 10/17] intel_iommu: fix missing BQL in pt fast path |
Date: |
Fri, 8 Sep 2017 17:19:19 +0300 |
From: Peter Xu <address@hidden>
In vtd_switch_address_space() we did the memory region switch, however
it's possible that the caller of it has not taken the BQL at all. Make
sure we have it.
CC: Paolo Bonzini <address@hidden>
CC: Jason Wang <address@hidden>
CC: Michael S. Tsirkin <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/intel_iommu.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index a7bf87a..3a5bb0b 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -957,6 +957,8 @@ static bool vtd_dev_pt_enabled(VTDAddressSpace *as)
static bool vtd_switch_address_space(VTDAddressSpace *as)
{
bool use_iommu;
+ /* Whether we need to take the BQL on our own */
+ bool take_bql = !qemu_mutex_iothread_locked();
assert(as);
@@ -967,6 +969,15 @@ static bool vtd_switch_address_space(VTDAddressSpace *as)
VTD_PCI_FUNC(as->devfn),
use_iommu);
+ /*
+ * It's possible that we reach here without BQL, e.g., when called
+ * 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) {
+ qemu_mutex_lock_iothread();
+ }
+
/* Turn off first then on the other */
if (use_iommu) {
memory_region_set_enabled(&as->sys_alias, false);
@@ -976,6 +987,10 @@ static bool vtd_switch_address_space(VTDAddressSpace *as)
memory_region_set_enabled(&as->sys_alias, true);
}
+ if (take_bql) {
+ qemu_mutex_unlock_iothread();
+ }
+
return use_iommu;
}
--
MST
- [Qemu-devel] [PULL 03/17] hw/acpi: Limit hotplug to root bus on legacy mode, (continued)
- [Qemu-devel] [PULL 03/17] hw/acpi: Limit hotplug to root bus on legacy mode, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 04/17] hw/acpi: Move acpi_set_pci_info to pcihp, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 06/17] hw/pci: introduce pcie-pci-bridge device, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 05/17] Revert "ACPI: don't call acpi_pcihp_device_plug_cb on xen", Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 02/17] pc: add 2.11 machine types, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 08/17] hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 07/17] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 09/17] docs: update documentation considering PCIE-PCI bridge, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 11/17] acpi/vmgenid: change device category to misc, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 12/17] libvhost-user: support resuming vq->last_avail_idx based on used_idx, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 10/17] intel_iommu: fix missing BQL in pt fast path,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 13/17] vhost-user-bridge: fix resume regression (since 2.9), Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 14/17] vmgenid: replace x-write-pointer-available hack, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 15/17] pci: move check for existing devfn into new pci_bus_devfn_available() helper, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 16/17] pci: add reserved slot check to do_pci_register_device(), Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 17/17] fw_cfg: rename read callback, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 01/17] vhost: Release memory references on cleanup, Michael S. Tsirkin, 2017/09/08
- Re: [Qemu-devel] [PULL 00/17] pc, pci, virtio: patches queued before 2.10, Peter Maydell, 2017/09/08