From patchwork Mon Jan 6 17:38:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 3439941 Return-Path: X-Original-To: patchwork-kvm@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 C884AC02DC for ; Mon, 6 Jan 2014 17:39:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A47242016A for ; Mon, 6 Jan 2014 17:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75B6C2015F for ; Mon, 6 Jan 2014 17:39:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755789AbaAFRjB (ORCPT ); Mon, 6 Jan 2014 12:39:01 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:34054 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755663AbaAFRjA (ORCPT ); Mon, 6 Jan 2014 12:39:00 -0500 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.203.36]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s06Hchki017445; Mon, 6 Jan 2014 17:38:43 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id 66F8BC2B19; Mon, 6 Jan 2014 17:38:39 +0000 (GMT) From: Will Deacon To: penberg@kernel.org Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Robin Murphy , Robin Murphy , Will Deacon Subject: [PATCH 5/5] kvm tools: arm: add option to override generic timer frequency Date: Mon, 6 Jan 2014 17:38:37 +0000 Message-Id: <1389029917-23773-6-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1389029917-23773-1-git-send-email-will.deacon@arm.com> References: <1389029917-23773-1-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Robin Murphy 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. Acked-by: Will Deacon Signed-off-by: Robin Murphy Signed-off-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 7ac6f6e88550..f3baf392704d 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 bd6a0bb2c324..d757c1dd8c08 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)); }