From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm/arm64: KVM: vgic: Handle out-of-bound MMIO access
Date: Wed, 17 Feb 2016 15:34:41 +0000 [thread overview]
Message-ID: <1455723281-23846-1-git-send-email-marc.zyngier@arm.com> (raw)
When performing a MMIO access via a KVM IO bus, it is possible
that the access will actually be out-of-bounds (the redistributor
handlers do not cover the whole device, for example). In this case,
we return an error code, which leads to escaping to userspace
to handle it. Not that good.
Instead, let's just treat it like any other OOB access, by either
ignoring the write, or by returning a bunch of zeroes.
And let's keep the code quiet while we're at it, as nobody likes
it when a guest can generate zillions on messages on the host's
console...
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
virt/kvm/arm/vgic.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 043032c..2358272 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -830,8 +830,11 @@ static int vgic_handle_mmio_access(struct kvm_vcpu *vcpu,
offset = addr - iodev->addr;
range = vgic_find_range(iodev->reg_ranges, len, offset);
if (unlikely(!range || !range->handle_mmio)) {
- pr_warn("Unhandled access %d %08llx %d\n", is_write, addr, len);
- return -ENXIO;
+ /* Treat an OOR access as RAZ/WI. */
+ if (!is_write)
+ memset(val, 0, len);
+ pr_debug("Unhandled access %d %08llx %d\n", is_write, addr, len);
+ return 0;
}
mmio.phys_addr = addr;
--
2.1.4
next reply other threads:[~2016-02-17 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 15:34 Marc Zyngier [this message]
2016-02-24 11:51 ` [PATCH] arm/arm64: KVM: vgic: Handle out-of-bound MMIO access 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=1455723281-23846-1-git-send-email-marc.zyngier@arm.com \
--to=marc.zyngier@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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).