All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	Andre Przywara <andre.przywara@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 30/55] KVM: kvm_io_bus: Add kvm_io_bus_get_dev() call
Date: Fri, 22 Jul 2016 18:28:47 +0100	[thread overview]
Message-ID: <1469208552-4155-31-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1469208552-4155-1-git-send-email-marc.zyngier@arm.com>

From: Andre Przywara <andre.przywara@arm.com>

The kvm_io_bus framework is a nice place of holding information about
various MMIO regions for kernel emulated devices.
Add a call to retrieve the kvm_io_device structure which is associated
with a certain MMIO address. This avoids to duplicate kvm_io_bus'
knowledge of MMIO regions without having to fake MMIO calls if a user
needs the device a certain MMIO address belongs to.
This will be used by the ITS emulation to get the associated ITS device
when someone triggers an MSI via an ioctl from userspace.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 include/linux/kvm_host.h |  2 ++
 virt/kvm/kvm_main.c      | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0640ee9..614a981 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -164,6 +164,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 			    int len, struct kvm_io_device *dev);
 int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 			      struct kvm_io_device *dev);
+struct kvm_io_device *kvm_io_bus_get_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+					 gpa_t addr);
 
 #ifdef CONFIG_KVM_ASYNC_PF
 struct kvm_async_pf {
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ef54b4c..bd2eb92 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3496,6 +3496,30 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 	return r;
 }
 
+struct kvm_io_device *kvm_io_bus_get_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+					 gpa_t addr)
+{
+	struct kvm_io_bus *bus;
+	int dev_idx, srcu_idx;
+	struct kvm_io_device *iodev = NULL;
+
+	srcu_idx = srcu_read_lock(&kvm->srcu);
+
+	bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
+
+	dev_idx = kvm_io_bus_get_first_dev(bus, addr, 1);
+	if (dev_idx < 0)
+		goto out_unlock;
+
+	iodev = bus->range[dev_idx].dev;
+
+out_unlock:
+	srcu_read_unlock(&kvm->srcu, srcu_idx);
+
+	return iodev;
+}
+EXPORT_SYMBOL_GPL(kvm_io_bus_get_dev);
+
 static struct notifier_block kvm_cpu_notifier = {
 	.notifier_call = kvm_cpu_hotplug,
 };
-- 
2.8.1

WARNING: multiple messages have this Message-ID (diff)
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 30/55] KVM: kvm_io_bus: Add kvm_io_bus_get_dev() call
Date: Fri, 22 Jul 2016 18:28:47 +0100	[thread overview]
Message-ID: <1469208552-4155-31-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1469208552-4155-1-git-send-email-marc.zyngier@arm.com>

From: Andre Przywara <andre.przywara@arm.com>

The kvm_io_bus framework is a nice place of holding information about
various MMIO regions for kernel emulated devices.
Add a call to retrieve the kvm_io_device structure which is associated
with a certain MMIO address. This avoids to duplicate kvm_io_bus'
knowledge of MMIO regions without having to fake MMIO calls if a user
needs the device a certain MMIO address belongs to.
This will be used by the ITS emulation to get the associated ITS device
when someone triggers an MSI via an ioctl from userspace.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 include/linux/kvm_host.h |  2 ++
 virt/kvm/kvm_main.c      | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0640ee9..614a981 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -164,6 +164,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 			    int len, struct kvm_io_device *dev);
 int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 			      struct kvm_io_device *dev);
+struct kvm_io_device *kvm_io_bus_get_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+					 gpa_t addr);
 
 #ifdef CONFIG_KVM_ASYNC_PF
 struct kvm_async_pf {
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ef54b4c..bd2eb92 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3496,6 +3496,30 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 	return r;
 }
 
+struct kvm_io_device *kvm_io_bus_get_dev(struct kvm *kvm, enum kvm_bus bus_idx,
+					 gpa_t addr)
+{
+	struct kvm_io_bus *bus;
+	int dev_idx, srcu_idx;
+	struct kvm_io_device *iodev = NULL;
+
+	srcu_idx = srcu_read_lock(&kvm->srcu);
+
+	bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
+
+	dev_idx = kvm_io_bus_get_first_dev(bus, addr, 1);
+	if (dev_idx < 0)
+		goto out_unlock;
+
+	iodev = bus->range[dev_idx].dev;
+
+out_unlock:
+	srcu_read_unlock(&kvm->srcu, srcu_idx);
+
+	return iodev;
+}
+EXPORT_SYMBOL_GPL(kvm_io_bus_get_dev);
+
 static struct notifier_block kvm_cpu_notifier = {
 	.notifier_call = kvm_cpu_hotplug,
 };
-- 
2.8.1

  parent reply	other threads:[~2016-07-22 17:28 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 17:28 [PULL] KVM/ARM updates for Linux 4.8, take #1 Marc Zyngier
2016-07-22 17:28 ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 01/55] arm/arm64: KVM: Add a protection parameter to create_hyp_mappings Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 02/55] arm64: Add PTE_HYP_XN page table flag Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 03/55] arm/arm64: KVM: Enforce HYP read-only mapping of the kernel's rodata section Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 04/55] arm/arm64: KVM: Map the HYP text as read-only Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 05/55] arm/arm64: KVM: Make default HYP mappings non-excutable Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 06/55] KVM: arm/arm64: The GIC is dead, long live the GIC Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 07/55] arm64: KVM: Merged page tables documentation Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 08/55] arm64: KVM: Always reference __hyp_panic_string via its kernel VA Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 09/55] arm/arm64: KVM: Remove hyp_kern_va helper Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 10/55] arm64: KVM: Kill HYP_PAGE_OFFSET Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 11/55] arm64: Add ARM64_HYP_OFFSET_LOW capability Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 12/55] arm64: KVM: Define HYP offset masks Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 13/55] arm64: KVM: Refactor kern_hyp_va to deal with multiple offsets Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 14/55] arm/arm64: KVM: Export __hyp_text_start/end symbols Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 15/55] arm64: KVM: Runtime detection of lower HYP offset Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 16/55] arm/arm64: KVM: Always have merged page tables Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 17/55] arm64: KVM: Simplify HYP init/teardown Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 18/55] arm/arm64: KVM: Drop boot_pgd Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 19/55] arm/arm64: KVM: Kill free_boot_hyp_pgd Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 20/55] arm: KVM: Simplify HYP init Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 21/55] arm: KVM: Allow hyp teardown Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 22/55] arm/arm64: KVM: Prune unused #defines Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 23/55] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 24/55] arm/arm64: Get rid of KERN_TO_HYP Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 25/55] arm64: KVM: Clean up a condition Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 26/55] KVM: arm/arm64: vgic: Move redistributor kvm_io_devices Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 27/55] KVM: arm/arm64: vgic: Check return value for kvm_register_vgic_device Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 28/55] KVM: Extend struct kvm_msi to hold a 32-bit device ID Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 29/55] KVM: arm/arm64: Extend arch CAP checks to allow per-VM capabilities Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` Marc Zyngier [this message]
2016-07-22 17:28   ` [PATCH 30/55] KVM: kvm_io_bus: Add kvm_io_bus_get_dev() call Marc Zyngier
2016-07-22 17:28 ` [PATCH 31/55] KVM: arm/arm64: vgic: Add refcounting for IRQs Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 32/55] irqchip/gic-v3: Refactor and add GICv3 definitions Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 33/55] KVM: arm64: vgic: Handle ITS related GICv3 redistributor registers Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-08-01 18:20   ` Christoffer Dall
2016-08-01 18:20     ` Christoffer Dall
2016-08-02  9:40     ` Andre Przywara
2016-08-02  9:40       ` Andre Przywara
2016-08-02 10:12       ` Marc Zyngier
2016-08-02 10:12         ` Marc Zyngier
2016-08-02 14:33         ` Christoffer Dall
2016-08-02 14:33           ` Christoffer Dall
2016-08-02 14:46           ` Marc Zyngier
2016-08-02 14:46             ` Marc Zyngier
2016-08-02 14:55             ` Christoffer Dall
2016-08-02 14:55               ` Christoffer Dall
2016-08-02 15:01               ` Marc Zyngier
2016-08-02 15:01                 ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 34/55] KVM: arm64: vgic-its: Introduce ITS emulation file with MMIO framework Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 35/55] KVM: arm64: vgic-its: Introduce new KVM ITS device Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 36/55] KVM: arm64: vgic-its: Implement basic ITS register handlers Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 37/55] KVM: arm64: vgic-its: Connect LPIs to the VGIC emulation Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 38/55] KVM: arm64: vgic-its: Read initial LPI pending table Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 39/55] KVM: arm64: vgic-its: Allow updates of LPI configuration table Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 40/55] KVM: arm64: vgic-its: Implement ITS command queue command handlers Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:28 ` [PATCH 41/55] KVM: arm64: vgic-its: Implement MSI injection in ITS emulation Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-08-01 18:20   ` Christoffer Dall
2016-08-01 18:20     ` Christoffer Dall
2016-08-02 10:18     ` Marc Zyngier
2016-08-02 10:18       ` Marc Zyngier
2016-08-04 10:47   ` Christoffer Dall
2016-08-04 10:47     ` Christoffer Dall
2016-07-22 17:28 ` [PATCH 42/55] KVM: arm64: vgic-its: Enable ITS emulation as a virtual MSI controller Marc Zyngier
2016-07-22 17:28   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 43/55] KVM: arm/arm64: Fix vGICv2 KVM_DEV_ARM_VGIC_GRP_CPU/DIST_REGS Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 44/55] irqchip/gicv3-its: Restore all cacheability attributes Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 45/55] KVM: arm64: vgic-its: Generalize use of vgic_get_irq_kref Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 46/55] KVM: arm64: vgic-its: Fix handling of indirect tables Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 47/55] KVM: arm64: vgic-its: Fix vgic_its_check_device_id BE handling Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 48/55] KVM: arm64: vgic-its: Fix misleading nr_entries in vgic_its_check_device_id Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 49/55] KVM: arm64: vgic-its: Validate the device table L1 entry Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 50/55] KVM: arm64: vgic-its: Fix L2 entry validation for indirect tables Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 51/55] KVM: arm64: vgic-its: Add collection allocator/destructor Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 52/55] KVM: arm64: vgic-its: Add pointer to corresponding kvm_device Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 53/55] KVM: arm64: vgic-its: Turn device_id validation into generic ID validation Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 54/55] KVM: arm64: vgic-its: Make vgic_its_cmd_handle_mapi similar to other handlers Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 17:29 ` [PATCH 55/55] KVM: arm64: vgic-its: Simplify MAPI error handling Marc Zyngier
2016-07-22 17:29   ` Marc Zyngier
2016-07-22 19:50 ` [PULL] KVM/ARM updates for Linux 4.8, take #1 Radim Krčmář
2016-07-22 19:50   ` Radim Krčmář

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469208552-4155-31-git-send-email-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.