All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: marc.zyngier@arm.com, christoffer.dall@linaro.org, pbonzini@redhat.com
Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	kvmarm@lists.cs.columbia.edu
Subject: [PATCH] KVM: arm/arm64: fix MMIO handling on userland induced accesses
Date: Tue, 24 Mar 2015 16:03:16 +0000	[thread overview]
Message-ID: <1427212996-16844-1-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <1427126309-11223-12-git-send-email-andre.przywara@arm.com>

The guest is not the only user of the MMIO handling routines, userland
can also read and write to those handlers. Since we don't use the
KVM iobus framework in this case, we have to set the data pointer to
some actual memory before executing the handler routines.
This allows to use QEMU as the userland control tool.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

just embarrassingly realised that I haven't tested the latest version of this
series with QEMU, so this bug slipped me. Sorry for that! I will merge this
patch in the next revision of this series (or just send a new version of
11/12).

Cheers,
Andre.

 virt/kvm/arm/vgic-v2-emul.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/arm/vgic-v2-emul.c b/virt/kvm/arm/vgic-v2-emul.c
index 12cb1361..a715054 100644
--- a/virt/kvm/arm/vgic-v2-emul.c
+++ b/virt/kvm/arm/vgic-v2-emul.c
@@ -666,6 +666,7 @@ static int vgic_attr_regs_access(struct kvm_device *dev,
 	struct kvm_vcpu *vcpu, *tmp_vcpu;
 	struct vgic_dist *vgic;
 	struct kvm_exit_mmio mmio;
+	u32 data;
 
 	offset = attr->attr & KVM_DEV_ARM_VGIC_OFFSET_MASK;
 	cpuid = (attr->attr & KVM_DEV_ARM_VGIC_CPUID_MASK) >>
@@ -687,6 +688,7 @@ static int vgic_attr_regs_access(struct kvm_device *dev,
 
 	mmio.len = 4;
 	mmio.is_write = is_write;
+	mmio.data = &data;
 	if (is_write)
 		mmio_data_write(&mmio, ~0, *reg);
 	switch (attr->group) {
-- 
1.7.9.5

WARNING: multiple messages have this Message-ID (diff)
From: andre.przywara@arm.com (Andre Przywara)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] KVM: arm/arm64: fix MMIO handling on userland induced accesses
Date: Tue, 24 Mar 2015 16:03:16 +0000	[thread overview]
Message-ID: <1427212996-16844-1-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <1427126309-11223-12-git-send-email-andre.przywara@arm.com>

The guest is not the only user of the MMIO handling routines, userland
can also read and write to those handlers. Since we don't use the
KVM iobus framework in this case, we have to set the data pointer to
some actual memory before executing the handler routines.
This allows to use QEMU as the userland control tool.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

just embarrassingly realised that I haven't tested the latest version of this
series with QEMU, so this bug slipped me. Sorry for that! I will merge this
patch in the next revision of this series (or just send a new version of
11/12).

Cheers,
Andre.

 virt/kvm/arm/vgic-v2-emul.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/arm/vgic-v2-emul.c b/virt/kvm/arm/vgic-v2-emul.c
index 12cb1361..a715054 100644
--- a/virt/kvm/arm/vgic-v2-emul.c
+++ b/virt/kvm/arm/vgic-v2-emul.c
@@ -666,6 +666,7 @@ static int vgic_attr_regs_access(struct kvm_device *dev,
 	struct kvm_vcpu *vcpu, *tmp_vcpu;
 	struct vgic_dist *vgic;
 	struct kvm_exit_mmio mmio;
+	u32 data;
 
 	offset = attr->attr & KVM_DEV_ARM_VGIC_OFFSET_MASK;
 	cpuid = (attr->attr & KVM_DEV_ARM_VGIC_CPUID_MASK) >>
@@ -687,6 +688,7 @@ static int vgic_attr_regs_access(struct kvm_device *dev,
 
 	mmio.len = 4;
 	mmio.is_write = is_write;
+	mmio.data = &data;
 	if (is_write)
 		mmio_data_write(&mmio, ~0, *reg);
 	switch (attr->group) {
-- 
1.7.9.5

  parent reply	other threads:[~2015-03-24 16:03 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 15:58 [PATCH v2 00/12] KVM: arm/arm64: move VGIC MMIO to kvm_io_bus Andre Przywara
2015-03-23 15:58 ` Andre Przywara
2015-03-23 15:58 ` [PATCH v2 01/12] KVM: Redesign kvm_io_bus_ API to pass VCPU structure to the callbacks Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 16:56   ` Marc Zyngier
2015-03-25 16:56     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 02/12] KVM: move iodev.h from virt/kvm/ to include/kvm Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:00   ` Marc Zyngier
2015-03-25 17:00     ` Marc Zyngier
2015-03-25 21:41     ` Marcelo Tosatti
2015-03-25 21:41       ` Marcelo Tosatti
2015-03-23 15:58 ` [PATCH v2 03/12] KVM: arm/arm64: remove now unneeded include directory from Makefile Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:00   ` Marc Zyngier
2015-03-25 17:00     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 04/12] KVM: x86: " Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:01   ` Marc Zyngier
2015-03-25 17:01     ` Marc Zyngier
2015-03-25 21:41     ` Marcelo Tosatti
2015-03-25 21:41       ` Marcelo Tosatti
2015-03-23 15:58 ` [PATCH v2 05/12] KVM: arm/arm64: rename struct kvm_mmio_range to vgic_io_range Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:02   ` Marc Zyngier
2015-03-25 17:02     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 06/12] KVM: mark kvm->buses as empty once they were destroyed Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:09   ` Marc Zyngier
2015-03-25 17:09     ` Marc Zyngier
2015-03-25 21:59     ` Marcelo Tosatti
2015-03-25 21:59       ` Marcelo Tosatti
2015-03-26 12:41       ` Andre Przywara
2015-03-26 12:41         ` Andre Przywara
2015-03-27  1:31     ` Marcelo Tosatti
2015-03-27  1:31       ` Marcelo Tosatti
2015-03-27  2:10       ` Chen, Tiejun
2015-03-27  2:10         ` Chen, Tiejun
2015-03-23 15:58 ` [PATCH v2 07/12] KVM: arm/arm64: simplify vgic_find_range() and callers Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:13   ` Marc Zyngier
2015-03-25 17:13     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 08/12] KVM: arm/arm64: implement kvm_io_bus MMIO handling for the VGIC Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:18   ` Marc Zyngier
2015-03-25 17:18     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 09/12] KVM: arm/arm64: prepare GICv2 emulation to be handled by kvm_io_bus Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:21   ` Marc Zyngier
2015-03-25 17:21     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 10/12] KVM: arm/arm64: prepare GICv3 emulation to use kvm_io_bus MMIO handling Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:36   ` Marc Zyngier
2015-03-25 17:36     ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 11/12] KVM: arm/arm64: rework MMIO abort handling to use KVM MMIO bus Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-23 21:43   ` Nikolay Nikolaev
2015-03-23 21:43     ` Nikolay Nikolaev
2015-03-24 16:03   ` Andre Przywara [this message]
2015-03-24 16:03     ` [PATCH] KVM: arm/arm64: fix MMIO handling on userland induced accesses Andre Przywara
2015-03-25 17:37     ` Marc Zyngier
2015-03-25 17:37       ` Marc Zyngier
2015-03-23 15:58 ` [PATCH v2 12/12] KVM: arm/arm64: remove now obsolete VGIC specific MMIO handling code Andre Przywara
2015-03-23 15:58   ` Andre Przywara
2015-03-25 17:36   ` Marc Zyngier
2015-03-25 17:36     ` Marc Zyngier
2015-03-27  9:33   ` Marc Zyngier
2015-03-27  9:33     ` Marc Zyngier
2015-03-23 21:50 ` [PATCH v2 00/12] KVM: arm/arm64: move VGIC MMIO to kvm_io_bus Nikolay Nikolaev
2015-03-23 21:50   ` Nikolay Nikolaev
2015-03-24 10:10   ` Marc Zyngier

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=1427212996-16844-1-git-send-email-andre.przywara@arm.com \
    --to=andre.przywara@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@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.