public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform
@ 2014-07-24 19:27 Will Deacon
  2014-07-24 19:47 ` Peter Maydell
  0 siblings, 1 reply; 15+ messages in thread
From: Will Deacon @ 2014-07-24 19:27 UTC (permalink / raw)
  To: pbonzini, gleb
  Cc: kvmarm, kvm, Will Deacon, Christoffer Dall, Marc Zyngier,
	Joel Schopp, Don Dutile, Peter Maydell, stable

If the physical address of GICV isn't page-aligned, then we end up
creating a stage-2 mapping of the page containing it, which causes us to
map neighbouring memory locations directly into the guest.

As an example, consider a platform with GICV at physical 0x2c02f000
running a 64k-page host kernel. If qemu maps this into the guest at
0x80010000, then guest physical addresses 0x80010000 - 0x8001efff will
map host physical region 0x2c020000 - 0x2c02efff. Accesses to these
physical regions may cause UNPREDICTABLE behaviour, for example, on the
Juno platform this will cause an SError exception to EL3, which brings
down the entire physical CPU resulting in RCU stalls / HYP panics / host
crashing / wasted weeks of debugging.

SBSA recommends that systems alias the 4k GICV across the bounding 64k
region, in which case GICV physical could be described as 0x2c020000 in
the above scenario.

This patch fixes the problem by failing the vgic probe if the physical
address of GICV isn't page-aligned. Note that this generated a warning
in dmesg about freeing enabled IRQs, so I had to move the IRQ enabling
later in the probe.

Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Joel Schopp <joel.schopp@amd.com>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---

Paulo, Gleb,

This fixes a *really* nasty bug with 64k-page hosts and KVM. I believe
Marc and Christoffer are both on holiday at the moment (not together),
so could you please take this as an urgent fix? Without it, I can trivially
bring down machines using kvm. I've checked that it applies cleanly against
-next, so you shouldn't see any conflicts during the merge window.

Thanks,

Will

 virt/kvm/arm/vgic.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 56ff9bebb577..fa9a95b3ed19 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1526,17 +1526,25 @@ int kvm_vgic_hyp_init(void)
 		goto out_unmap;
 	}
 
-	kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
-		 vctrl_res.start, vgic_maint_irq);
-	on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1);
-
 	if (of_address_to_resource(vgic_node, 3, &vcpu_res)) {
 		kvm_err("Cannot obtain VCPU resource\n");
 		ret = -ENXIO;
 		goto out_unmap;
 	}
+
+	if (!PAGE_ALIGNED(vcpu_res.start)) {
+		kvm_err("GICV physical address 0x%llx not page aligned\n",
+			(unsigned long long)vcpu_res.start);
+		ret = -ENXIO;
+		goto out_unmap;
+	}
+
 	vgic_vcpu_base = vcpu_res.start;
 
+	kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
+		 vctrl_res.start, vgic_maint_irq);
+	on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1);
+
 	goto out;
 
 out_unmap:
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [GIT PULL] KVM/ARM Urgent fix for 3.16
@ 2014-07-30 12:55 Christoffer Dall
  2014-07-30 12:55 ` [PATCH] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Christoffer Dall
  0 siblings, 1 reply; 15+ messages in thread
From: Christoffer Dall @ 2014-07-30 12:55 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Linus Torvalds, Will Deacon, Marc Zyngier, kvmarm,
	linux-arm-kernel, kvm, Christoffer Dall

Hi Paolo and Gleb,

Is there any chance you can get this urgent fix (which allows KVM guest
to bring down the entire system on some 64K enabled ARM64 hosts) merged
for 3.16?

The following changes since commit bb18b526a9d8d4a3fe56f234d5013b9f6036978d:

  Merge tag 'signed-for-3.16' of git://github.com/agraf/linux-2.6 into kvm-master (2014-07-08 12:08:58 +0200)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-for-3.16-rc7

for you to fetch changes up to 63afbe7a0ac184ef8485dac4914e87b211b5bfaa:

  kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform (2014-07-30 14:35:42 +0200)

---
Will Deacon (1):
  kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform

 virt/kvm/arm/vgic.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-07-30 12:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24 19:27 [PATCH] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Will Deacon
2014-07-24 19:47 ` Peter Maydell
2014-07-24 19:55   ` Will Deacon
2014-07-24 20:01     ` Joel Schopp
2014-07-24 20:05     ` Peter Maydell
2014-07-25  9:31       ` Will Deacon
2014-07-25 10:06         ` Peter Maydell
2014-07-25 14:02         ` Joel Schopp
2014-07-25 14:08           ` Will Deacon
2014-07-25 14:16             ` Joel Schopp
2014-07-25 14:23               ` Will Deacon
2014-07-25 14:59                 ` Joel Schopp
2014-07-25 14:08           ` Peter Maydell
2014-07-24 19:59   ` Joel Schopp
  -- strict thread matches above, loose matches on Subject: below --
2014-07-30 12:55 [GIT PULL] KVM/ARM Urgent fix for 3.16 Christoffer Dall
2014-07-30 12:55 ` [PATCH] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Christoffer Dall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox