From patchwork Mon Dec 5 09:32:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 86523 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1384085qgi; Mon, 5 Dec 2016 01:33:29 -0800 (PST) X-Received: by 10.98.102.197 with SMTP id s66mr55815297pfj.146.1480930409131; Mon, 05 Dec 2016 01:33:29 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d9si14003821pgg.146.2016.12.05.01.33.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Dec 2016 01:33:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cDpdS-0004Pe-UG; Mon, 05 Dec 2016 09:32:34 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cDpdP-0004Hy-Eu for linux-arm-kernel@lists.infradead.org; Mon, 05 Dec 2016 09:32:32 +0000 Received: by mail-wm0-x234.google.com with SMTP id a197so87493101wmd.0 for ; Mon, 05 Dec 2016 01:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FT695CqBUnm6dzqDbWJ7L021XmRYHuv6URkVLA14kcw=; b=PQWEi3SscMpMpP+zBUwAlKG/sRasoIddrc6HPKxwdlNwRhS0HIwELV8Bp/nktQRgA0 lHbGj+5TU1gC5t2nxS6PMZGVlTKQr3hfV96XBgsQ1t+KCX+xVgw7HCLJ4wDXP0zk8z/J S+HgRy4FyihNRWIQyEICBGqMUWCPopAzwMjIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FT695CqBUnm6dzqDbWJ7L021XmRYHuv6URkVLA14kcw=; b=DqCYp5m3TCfFYBwvciN/GwGRv5CrxJ10TqRqAKbbrTy3FHZ0s8xwVTqymQoqWWZ4Du cYdnHp3TN/a+VbLV4Dm+bXPK/uZKTdV79geMRR2kHIGmsdUIMTmuQSurgS8fAmn4mBU5 E2dxEmMcW1D0b4pl99c/wqh/TdHxnFWqKP5nn4UEF7KIOe0xyaYlMp15YF8qtCQQD/We wqPb+F0CGHwPS+c1fy1y9xY5F3xjvi4HGopORbeBCgug6qixUI4WqD0I6a9X8XY3n+Rq DR40TvDoZuFb6lhwRVnSenND2zJ5i3jO7vDIC+MX+pBSraVmAdYEJzQH/tPl1zrJ32XE CQzg== X-Gm-Message-State: AKaTC0398A/LD+bdAnXG484Fn0y4vhDNoAJz6yp60lUqjeRC/F+7owBXL938hnmAtFWdsbVh X-Received: by 10.46.76.18 with SMTP id z18mr26650641lja.38.1480930329211; Mon, 05 Dec 2016 01:32:09 -0800 (PST) Received: from localhost.localdomain (x1-6-50-6a-03-de-ec-c2.cpe.webspeed.dk. [2.108.209.202]) by smtp.gmail.com with ESMTPSA id c2sm2774012ljb.8.2016.12.05.01.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Dec 2016 01:32:08 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Subject: [PATCH] arm/arm64: KVM: Check for properly initialized timer on init Date: Mon, 5 Dec 2016 10:32:11 +0100 Message-Id: <20161205093211.11870-1-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161205_013231_707393_011A9C48 X-CRM114-Status: GOOD ( 10.03 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:234 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Shih-Wei Li , Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org When the arch timer code fails to initialize (for example because the memory mapped timer doesn't work, which is currently seen with the AEM model), then KVM just continues happily with a final result that KVM eventually does a NULL pointer dereference of the uninitialized cycle counter. Check directly for this in the init path and give the user a reasonable error in this case. Cc: Shih-Wei Li Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 27a1f63..5c12f53 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -425,6 +425,11 @@ int kvm_timer_hyp_init(void) info = arch_timer_get_kvm_info(); timecounter = &info->timecounter; + if (!timecounter->cc) { + kvm_err("arch_timer: uninitialized timecounter\n"); + return -ENODEV; + } + if (info->virtual_irq <= 0) { kvm_err("kvm_arch_timer: invalid virtual timer IRQ: %d\n", info->virtual_irq);