From patchwork Tue Dec 17 18:31:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 3363821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20A7EC0D4A for ; Tue, 17 Dec 2013 18:32:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC797203AC for ; Tue, 17 Dec 2013 18:32:37 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01C85201BF for ; Tue, 17 Dec 2013 18:32:33 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VszR9-0006ak-Bn; Tue, 17 Dec 2013 18:32:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VszR0-00069A-Dw; Tue, 17 Dec 2013 18:31:58 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VszQx-000674-Ll for linux-arm-kernel@lists.infradead.org; Tue, 17 Dec 2013 18:31:56 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 17 Dec 2013 18:31:37 +0000 Received: from e104324-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 17 Dec 2013 18:31:35 +0000 From: Robin Murphy To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH 2/2] kvmtool/arm: Add option to override Generic Timer frequency Date: Tue, 17 Dec 2013 18:31:14 +0000 Message-Id: <1387305074-29421-3-git-send-email-robin.murphy@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387305074-29421-1-git-send-email-robin.murphy@arm.com> References: <1387305074-29421-1-git-send-email-robin.murphy@arm.com> X-OriginalArrivalTime: 17 Dec 2013 18:31:35.0846 (UTC) FILETIME=[3792F460:01CEFB56] X-MC-Unique: 113121718313700201 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131217_133155_871593_5D2863D3 X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) Cc: Robin Murphy , will.deacon@arm.com, kvm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some platforms have secure firmware which does not correctly set the CNTFRQ register on boot, preventing the use of the Generic Timer. This patch allows mirroring the necessary host workaround by specifying the clock-frequency property in the guest DT. This should only be considered a means of KVM bring-up on such systems, such that vendors may be convinced to properly implement their firmware to support the virtualisation capabilities of their hardware. Signed-off-by: Robin Murphy Acked-by: Will Deacon --- tools/kvm/arm/include/arm-common/kvm-config-arch.h | 15 ++++++++++----- tools/kvm/arm/timer.c | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/kvm/arm/include/arm-common/kvm-config-arch.h b/tools/kvm/arm/include/arm-common/kvm-config-arch.h index 7ac6f6e..f3baf39 100644 --- a/tools/kvm/arm/include/arm-common/kvm-config-arch.h +++ b/tools/kvm/arm/include/arm-common/kvm-config-arch.h @@ -5,13 +5,18 @@ struct kvm_config_arch { const char *dump_dtb_filename; + unsigned int force_cntfrq; bool aarch32_guest; }; -#define OPT_ARCH_RUN(pfx, cfg) \ - pfx, \ - ARM_OPT_ARCH_RUN(cfg) \ - OPT_STRING('\0', "dump-dtb", &(cfg)->dump_dtb_filename, \ - ".dtb file", "Dump generated .dtb to specified file"), +#define OPT_ARCH_RUN(pfx, cfg) \ + pfx, \ + ARM_OPT_ARCH_RUN(cfg) \ + OPT_STRING('\0', "dump-dtb", &(cfg)->dump_dtb_filename, \ + ".dtb file", "Dump generated .dtb to specified file"), \ + OPT_UINTEGER('\0', "override-bad-firmware-cntfrq", &(cfg)->force_cntfrq,\ + "Specify Generic Timer frequency in guest DT to " \ + "work around buggy secure firmware *Firmware should be " \ + "updated to program CNTFRQ correctly*"), #endif /* ARM_COMMON__KVM_CONFIG_ARCH_H */ diff --git a/tools/kvm/arm/timer.c b/tools/kvm/arm/timer.c index bd6a0bb..d757c1d 100644 --- a/tools/kvm/arm/timer.c +++ b/tools/kvm/arm/timer.c @@ -33,6 +33,8 @@ void timer__generate_fdt_nodes(void *fdt, struct kvm *kvm, int *irqs) _FDT(fdt_begin_node(fdt, "timer")); _FDT(fdt_property(fdt, "compatible", compatible, sizeof(compatible))); _FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop))); + if (kvm->cfg.arch.force_cntfrq > 0) + _FDT(fdt_property_cell(fdt, "clock-frequency", kvm->cfg.arch.force_cntfrq)); _FDT(fdt_end_node(fdt)); }