From: n.nikolaev@virtualopensystems.com (Nikolay Nikolaev)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/5] KVM: ARM: on IO mem abort - route the call to KVM MMIO bus
Date: Sun, 07 Dec 2014 11:37:49 +0200 [thread overview]
Message-ID: <20141207093749.17563.12497.stgit@i3820> (raw)
In-Reply-To: <20141207093641.17563.84226.stgit@i3820>
On IO memory abort, try to handle the MMIO access thorugh the KVM
registered read/write callbacks. This is done by invoking the relevant
kvm_io_bus_* API.
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
---
arch/arm/kvm/mmio.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
index 4cb5a93..e42469f 100644
--- a/arch/arm/kvm/mmio.c
+++ b/arch/arm/kvm/mmio.c
@@ -162,6 +162,36 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
return 0;
}
+/**
+ * handle_kernel_mmio - handle an in-kernel MMIO access
+ * @vcpu: pointer to the vcpu performing the access
+ * @run: pointer to the kvm_run structure
+ * @mmio: pointer to the data describing the access
+ *
+ * returns true if the MMIO access has been performed in kernel space,
+ * and false if it needs to be emulated in user space.
+ */
+static bool handle_kernel_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
+ struct kvm_exit_mmio *mmio)
+{
+ int ret;
+
+ if (mmio->is_write) {
+ ret = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, mmio->phys_addr,
+ mmio->len, &mmio->data);
+
+ } else {
+ ret = kvm_io_bus_read(vcpu, KVM_MMIO_BUS, mmio->phys_addr,
+ mmio->len, &mmio->data);
+ }
+ if (!ret) {
+ kvm_prepare_mmio(run, mmio);
+ kvm_handle_mmio_return(vcpu, run);
+ }
+
+ return !ret;
+}
+
int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
phys_addr_t fault_ipa)
{
@@ -200,6 +230,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
if (vgic_handle_mmio(vcpu, run, &mmio))
return 1;
+ if (handle_kernel_mmio(vcpu, run, &mmio))
+ return 1;
+
kvm_prepare_mmio(run, &mmio);
return 0;
}
WARNING: multiple messages have this Message-ID (diff)
From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
To: kvm@vger.kernel.org, eric.auger@linaro.org, marc.zyngier@arm.com,
andre.przywara@arm.com, kvmarm@lists.cs.columbia.edu,
christoffer.dall@linaro.org
Cc: tech@virtualopensystems.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/5] KVM: ARM: on IO mem abort - route the call to KVM MMIO bus
Date: Sun, 07 Dec 2014 11:37:49 +0200 [thread overview]
Message-ID: <20141207093749.17563.12497.stgit@i3820> (raw)
In-Reply-To: <20141207093641.17563.84226.stgit@i3820>
On IO memory abort, try to handle the MMIO access thorugh the KVM
registered read/write callbacks. This is done by invoking the relevant
kvm_io_bus_* API.
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
---
arch/arm/kvm/mmio.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
index 4cb5a93..e42469f 100644
--- a/arch/arm/kvm/mmio.c
+++ b/arch/arm/kvm/mmio.c
@@ -162,6 +162,36 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
return 0;
}
+/**
+ * handle_kernel_mmio - handle an in-kernel MMIO access
+ * @vcpu: pointer to the vcpu performing the access
+ * @run: pointer to the kvm_run structure
+ * @mmio: pointer to the data describing the access
+ *
+ * returns true if the MMIO access has been performed in kernel space,
+ * and false if it needs to be emulated in user space.
+ */
+static bool handle_kernel_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
+ struct kvm_exit_mmio *mmio)
+{
+ int ret;
+
+ if (mmio->is_write) {
+ ret = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, mmio->phys_addr,
+ mmio->len, &mmio->data);
+
+ } else {
+ ret = kvm_io_bus_read(vcpu, KVM_MMIO_BUS, mmio->phys_addr,
+ mmio->len, &mmio->data);
+ }
+ if (!ret) {
+ kvm_prepare_mmio(run, mmio);
+ kvm_handle_mmio_return(vcpu, run);
+ }
+
+ return !ret;
+}
+
int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
phys_addr_t fault_ipa)
{
@@ -200,6 +230,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
if (vgic_handle_mmio(vcpu, run, &mmio))
return 1;
+ if (handle_kernel_mmio(vcpu, run, &mmio))
+ return 1;
+
kvm_prepare_mmio(run, &mmio);
return 0;
}
next prev parent reply other threads:[~2014-12-07 9:37 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-07 9:37 [PATCH v2 0/5] ARM: KVM: Enable the ioeventfd capability of KVM on ARM Nikolay Nikolaev
2014-12-07 9:37 ` Nikolay Nikolaev
2014-12-07 9:37 ` [PATCH v2 1/5] KVM: Redesign kvm_io_bus_ API to pass VCPU structure to the callbacks Nikolay Nikolaev
2014-12-07 9:37 ` Nikolay Nikolaev
2015-01-12 17:10 ` Eric Auger
2015-01-12 17:10 ` Eric Auger
2014-12-07 9:37 ` Nikolay Nikolaev [this message]
2014-12-07 9:37 ` [PATCH v2 2/5] KVM: ARM: on IO mem abort - route the call to KVM MMIO bus Nikolay Nikolaev
2015-01-12 17:09 ` Eric Auger
2015-01-12 17:09 ` Eric Auger
2015-01-12 17:48 ` Eric Auger
2015-01-12 17:48 ` Eric Auger
2015-01-24 1:02 ` Nikolay Nikolaev
2015-01-24 1:02 ` Nikolay Nikolaev
2015-01-27 21:38 ` Christoffer Dall
2015-01-27 21:38 ` Christoffer Dall
2015-01-28 11:08 ` Eric Auger
2015-01-28 11:08 ` Eric Auger
2014-12-07 9:37 ` [PATCH v2 3/5] KVM: ARM VGIC add kvm_io_bus_ frontend Nikolay Nikolaev
2014-12-07 9:37 ` Nikolay Nikolaev
2015-01-12 21:41 ` Eric Auger
2015-01-12 21:41 ` Eric Auger
2015-01-24 0:57 ` Nikolay Nikolaev
2015-01-24 0:57 ` Nikolay Nikolaev
2014-12-07 9:38 ` [PATCH v2 4/5] ARM/ARM64: enable linking against eventfd Nikolay Nikolaev
2014-12-07 9:38 ` Nikolay Nikolaev
2014-12-07 9:38 ` [PATCH v2 5/5] ARM: enable KVM_CAP_IOEVENTFD Nikolay Nikolaev
2014-12-07 9:38 ` Nikolay Nikolaev
2015-01-12 21:46 ` [PATCH v2 0/5] ARM: KVM: Enable the ioeventfd capability of KVM on ARM Eric Auger
2015-01-12 21:46 ` Eric Auger
[not found] ` <CADDJ2=M2UjsV0U9cFiRoKghWSckWje+h6M-XQ-0dqPrH3BXp1A@mail.gmail.com>
2015-01-15 15:31 ` Eric Auger
2015-01-15 15:31 ` Eric Auger
2015-01-15 19:47 ` Christoffer Dall
2015-01-15 19:47 ` Christoffer Dall
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=20141207093749.17563.12497.stgit@i3820 \
--to=n.nikolaev@virtualopensystems.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.