From patchwork Fri Apr 24 05:27:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47518 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1A5420553 for ; Fri, 24 Apr 2015 05:32:41 +0000 (UTC) Received: by wizk4 with SMTP id k4sf1567838wiz.2 for ; Thu, 23 Apr 2015 22:32:41 -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=y6K6vH3f2MtSoF8QLzDFCaIDOq/pGsb7EMHiI9+eZZU=; b=W+jpjOZ+Fv68aRFjjYu9UUsXEE5HwiP9LTNIdgSGu7EwhaqChGrfs2fsT1mXZ2LCja pmMhrUKIhKkh0iwd7hTgNuk+f1uhPFv515IB/pWALJbUF10TGy7d0/FNTdfbOmb9SrJx 3Y0g/t99u4Y/I0WTMaQ5VGVwoga2M0opK2gy2UgypTrwlNwaHAKkTIRAiPQxQLj9xF0h N79Xvex8aETxTrHi4Qlhh1IKJekOoGg8UxvelN9SL+1nMLIKv0YOnd3N57ByrYiwN+Y+ KI/5ZjzznJRHKbgkqczhpw5m/bj5yZ053rJs9nVl1D/Y71ENkLte0UDJkOOtjeIL9Bma 4nTQ== X-Gm-Message-State: ALoCoQlSeNKIvi0Skac2a2W07adRb9nFk0VLCXRhode4NdMPPJSSuE05ceUgzDuzHdh+Oc8jICoA X-Received: by 10.180.106.136 with SMTP id gu8mr165483wib.6.1429853561041; Thu, 23 Apr 2015 22:32:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.106 with SMTP id ud10ls442368lac.60.gmail; Thu, 23 Apr 2015 22:32:40 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr5347561lbc.117.1429853560779; Thu, 23 Apr 2015 22:32: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 l16si7472672lab.64.2015.04.23.22.32.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:32: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 layy10 with SMTP id y10so27608788lay.0 for ; Thu, 23 Apr 2015 22:32:40 -0700 (PDT) X-Received: by 10.112.204.72 with SMTP id kw8mr5457032lbc.88.1429853560343; Thu, 23 Apr 2015 22:32: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 l1csp978109lbt; Thu, 23 Apr 2015 22:32:39 -0700 (PDT) X-Received: by 10.68.190.9 with SMTP id gm9mr11562071pbc.110.1429853558589; Thu, 23 Apr 2015 22:32:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.32.37; Thu, 23 Apr 2015 22:32: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 S1754543AbbDXFch (ORCPT + 2 others); Fri, 24 Apr 2015 01:32:37 -0400 Received: from mail-ob0-f178.google.com ([209.85.214.178]:33097 "EHLO mail-ob0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754544AbbDXFcg (ORCPT ); Fri, 24 Apr 2015 01:32:36 -0400 Received: by oblw8 with SMTP id w8so30273400obl.0 for ; Thu, 23 Apr 2015 22:32:36 -0700 (PDT) X-Received: by 10.60.103.133 with SMTP id fw5mr5705717oeb.17.1429853556372; Thu, 23 Apr 2015 22:32:36 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id d10sm6073526obf.17.2015.04.23.22.32.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:32:35 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Will Deacon , Marc Zyngier , Gleb Natapov , Paolo Bonzini , Joel Schopp , Don Dutile Subject: [PATCH for 3.12.y stable 33/63] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Date: Fri, 24 Apr 2015 13:27:31 +0800 Message-Id: <1429853281-6136-34-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-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 46221c9..7ee14f0 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1365,17 +1365,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: