From patchwork Mon May 4 01:52:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47953 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A75BC2121F for ; Mon, 4 May 2015 01:54:41 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf42599269lab.1 for ; Sun, 03 May 2015 18:54:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=GaV4yhNGcHnVIVlYWteolGTj7eCii9CnhzcZnhyRIWo=; b=RZDtG4oF/eX+EtRi94gYGWfZKifc5cdDXLEC9aCltHRDe0MKzVv0NhqXqC0qQiuyZm ejxYaAjq61yBpMud+Ui4v+15MYFqzJL0D93GffgCF9y7bNGxww/7H5QGHjl4VHVZLuER tXT7idzZOJIhoupXf0jqfX9bulWMrV+1IlB/caFvx6ubee0MSNRiNaWR9HZnRj2Tyupp iQZS37p4SvPRE2jjtwbn1Vx/6CTEbnoki1PKsidjVrll6WHQHcFcgvNoUhL0MceARzep fyKBGqanItX7e+FU6vbnKG/gGShfY3vC4gyreGPCwj6NnXuBtIx3BMm1yVgIFwM04oBC EAow== X-Gm-Message-State: ALoCoQmkCxX198sqnFEG8toE1h85T4AH7sqnXCJglbA3NEDqPXrrkBc+pQIN6otvmY1wPy2lEpRt X-Received: by 10.112.26.5 with SMTP id h5mr17138026lbg.4.1430704480683; Sun, 03 May 2015 18:54:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.229 with SMTP id jf5ls650115lac.56.gmail; Sun, 03 May 2015 18:54:40 -0700 (PDT) X-Received: by 10.112.157.164 with SMTP id wn4mr17885308lbb.100.1430704480393; Sun, 03 May 2015 18:54:40 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id i4si9105608lbc.22.2015.05.03.18.54.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by laat2 with SMTP id t2so95034669laa.1 for ; Sun, 03 May 2015 18:54:40 -0700 (PDT) X-Received: by 10.112.16.196 with SMTP id i4mr17371048lbd.72.1430704480230; Sun, 03 May 2015 18:54:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1412719lbt; Sun, 3 May 2015 18:54:39 -0700 (PDT) X-Received: by 10.69.25.41 with SMTP id in9mr37905805pbd.80.1430704478384; Sun, 03 May 2015 18:54:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.54.37; Sun, 03 May 2015 18:54:38 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751906AbbEDByh (ORCPT + 2 others); Sun, 3 May 2015 21:54:37 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35339 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbbEDByg (ORCPT ); Sun, 3 May 2015 21:54:36 -0400 Received: by pabtp1 with SMTP id tp1so147802415pab.2 for ; Sun, 03 May 2015 18:54:36 -0700 (PDT) X-Received: by 10.67.15.102 with SMTP id fn6mr38873408pad.120.1430704476239; Sun, 03 May 2015 18:54:36 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id og11sm11022945pdb.91.2015.05.03.18.54.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:54:35 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Will Deacon , Marc Zyngier , Gleb Natapov , Paolo Bonzini , Joel Schopp , Don Dutile Subject: [PATCH for 3.14.y stable 15/47] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Date: Mon, 4 May 2015 09:52:10 +0800 Message-Id: <1430704362-6292-16-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Will Deacon commit 63afbe7a0ac184ef8485dac4914e87b211b5bfaa upstream. 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 base address or the size of GICV aren'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 Cc: Marc Zyngier Cc: Gleb Natapov Cc: Paolo Bonzini Cc: Joel Schopp Cc: Don Dutile Acked-by: Peter Maydell Acked-by: Joel Schopp Acked-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- virt/kvm/arm/vgic.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 4dc45e2..4eec2d4 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1526,17 +1526,33 @@ 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; + } + + if (!PAGE_ALIGNED(resource_size(&vcpu_res))) { + kvm_err("GICV size 0x%llx not a multiple of page size 0x%lx\n", + (unsigned long long)resource_size(&vcpu_res), + PAGE_SIZE); + 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: