From patchwork Wed Jul 30 12:55:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 34522 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A8B1A20792 for ; Wed, 30 Jul 2014 12:57:36 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id cm18sf3010243qab.11 for ; Wed, 30 Jul 2014 05:57:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=4DENIZtvyOejQFTcIT9XhXA6x4zCbWXGKn7w1EMLX64=; b=Mx2fI2lxKhZHklqc2+U6LVhfspG+hLlMdAbxMZnDsOBWax9u4xDZgXanS2DO+q44HA S6DYctLGXLfqvpn6gAZzynmTPYhGftZTbiwrvTJr4ChyWJVmW2UiqanlLf/V6QmZ6WhJ waolozB7yOgDS4PP9WH2XnaBwPFlrqiyTMQGznDMZlXHsqOXL+FyE0evej0kMOnPnVn9 AEiZqZIPrlbOvQ7YEPogGAqfJlEVOKelcrh+zYR9tl9Cl+fxksekuYgSzVPRD7gI9pJZ sERLGWHQpMwP6o6CzGDhDiCCHUDo0wPr2LCbTIBhgBRLDZOM1IEU/R++V8VdLlBOIfiT csNQ== X-Gm-Message-State: ALoCoQkeg1OJULje30Q1BCZZW2gUV02dOjP/RQMuRChhElt+DMqdvaCLY05i/KaTsKgFYKecgqsm X-Received: by 10.236.86.178 with SMTP id w38mr1393469yhe.13.1406725056313; Wed, 30 Jul 2014 05:57:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.36 with SMTP id k33ls513581qgf.79.gmail; Wed, 30 Jul 2014 05:57:36 -0700 (PDT) X-Received: by 10.220.166.207 with SMTP id n15mr987786vcy.75.1406725056194; Wed, 30 Jul 2014 05:57:36 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ti11si1534450vdb.10.2014.07.30.05.57.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 05:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so1669023vcb.16 for ; Wed, 30 Jul 2014 05:57:36 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr3961038vcn.16.1406725056079; Wed, 30 Jul 2014 05:57:36 -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.221.37.5 with SMTP id tc5csp25474vcb; Wed, 30 Jul 2014 05:57:35 -0700 (PDT) X-Received: by 10.70.128.164 with SMTP id np4mr3108857pdb.168.1406725055219; Wed, 30 Jul 2014 05:57:35 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id mt6si1154815pdb.481.2014.07.30.05.57.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:57:35 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCTQZ-0008V4-95; Wed, 30 Jul 2014 12:56:19 +0000 Received: from mail-lb0-f169.google.com ([209.85.217.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCTQP-0008KV-Il for linux-arm-kernel@lists.infradead.org; Wed, 30 Jul 2014 12:56:10 +0000 Received: by mail-lb0-f169.google.com with SMTP id s7so862218lbd.28 for ; Wed, 30 Jul 2014 05:55:47 -0700 (PDT) X-Received: by 10.112.181.74 with SMTP id du10mr4356679lbc.40.1406724947107; Wed, 30 Jul 2014 05:55:47 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id lh6sm1202249lab.17.2014.07.30.05.55.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Jul 2014 05:55:46 -0700 (PDT) From: Christoffer Dall To: Gleb Natapov , Paolo Bonzini Subject: [PATCH] kvm: arm64: vgic: fix hyp panic with 64k pages on juno platform Date: Wed, 30 Jul 2014 14:55:41 +0200 Message-Id: <1406724941-4283-2-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1406724941-4283-1-git-send-email-christoffer.dall@linaro.org> References: <1406724941-4283-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140730_055609_806899_A2AB5CB9 X-CRM114-Status: GOOD ( 14.27 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.217.169 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Joel Schopp , kvm@vger.kernel.org, Marc Zyngier , Will Deacon , Don Dutile , Christoffer Dall , Linus Torvalds , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@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.220.171 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 From: Will Deacon 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 --- 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 56ff9be..476d3bf 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: