From patchwork Tue Feb 4 16:53:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 3578151 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AEB0F9F383 for ; Tue, 4 Feb 2014 16:55:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBBF120158 for ; Tue, 4 Feb 2014 16:55:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B88120181 for ; Tue, 4 Feb 2014 16:55:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932156AbaBDQzb (ORCPT ); Tue, 4 Feb 2014 11:55:31 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:49547 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932149AbaBDQx5 (ORCPT ); Tue, 4 Feb 2014 11:53:57 -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 s14GrXkk003310; Tue, 4 Feb 2014 16:53:34 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id 46195C2B1A; Tue, 4 Feb 2014 16:53:33 +0000 (GMT) From: Will Deacon To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, penberg@kernel.org, marc.zyngier@arm.com, arnd@arndb.de Subject: [PATCH 14/17] kvm tools: ARM: route guest PCI accesses to the emulation layer Date: Tue, 4 Feb 2014 16:53:29 +0000 Message-Id: <1391532812-2043-15-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1391532812-2043-1-git-send-email-will.deacon@arm.com> References: <1391532812-2043-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.5 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 This patch routes guest PCI accesses to kvm__emulate_mmio, rather than exiting lkvm via a die invocation. The guest command-line is also updated to prevent the guest from attempting to program the BARs with new addresses (i.e. probe-only). Signed-off-by: Will Deacon --- tools/kvm/arm/include/arm-common/kvm-arch.h | 6 +++--- tools/kvm/arm/kvm-cpu.c | 4 ++-- tools/kvm/arm/kvm.c | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/kvm/arm/include/arm-common/kvm-arch.h b/tools/kvm/arm/include/arm-common/kvm-arch.h index 348e88d00b1c..8adfcd495c03 100644 --- a/tools/kvm/arm/include/arm-common/kvm-arch.h +++ b/tools/kvm/arm/include/arm-common/kvm-arch.h @@ -46,10 +46,10 @@ static inline bool arm_addr_in_virtio_mmio_region(u64 phys_addr) return phys_addr >= KVM_VIRTIO_MMIO_AREA && phys_addr < limit; } -static inline bool arm_addr_in_pci_mmio_region(u64 phys_addr) +static inline bool arm_addr_in_pci_region(u64 phys_addr) { - u64 limit = KVM_PCI_MMIO_AREA + ARM_PCI_MMIO_SIZE; - return phys_addr >= KVM_PCI_MMIO_AREA && phys_addr < limit; + u64 limit = KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE + ARM_PCI_MMIO_SIZE; + return phys_addr >= KVM_PCI_CFG_AREA && phys_addr < limit; } struct kvm_arch { diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c index d31e7b154ae8..b017994f4014 100644 --- a/tools/kvm/arm/kvm-cpu.c +++ b/tools/kvm/arm/kvm-cpu.c @@ -107,8 +107,8 @@ bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, int direction = is_write ? KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN; u16 port = phys_addr & USHRT_MAX; return kvm__emulate_io(kvm, port, data, direction, len, 1); - } else if (arm_addr_in_pci_mmio_region(phys_addr)) { - die("PCI emulation not supported on ARM!"); + } else if (arm_addr_in_pci_region(phys_addr)) { + return kvm__emulate_mmio(kvm, phys_addr, data, len, is_write); } return false; diff --git a/tools/kvm/arm/kvm.c b/tools/kvm/arm/kvm.c index 008b7fe75d7d..6db646b4f4fd 100644 --- a/tools/kvm/arm/kvm.c +++ b/tools/kvm/arm/kvm.c @@ -56,6 +56,11 @@ void kvm__arch_read_term(struct kvm *kvm) void kvm__arch_set_cmdline(char *cmdline, bool video) { + /* + * We don't support movable BARs, so force the guest to use what + * we tell it. + */ + strcpy(cmdline, "pci=firmware"); } void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)