From patchwork Fri Jun 29 11:15:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 10496401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5661F6022E for ; Fri, 29 Jun 2018 11:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44A0D295CF for ; Fri, 29 Jun 2018 11:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3690A295D2; Fri, 29 Jun 2018 11:32:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6433295CF for ; Fri, 29 Jun 2018 11:32:37 +0000 (UTC) Received: from localhost ([::1]:41290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrdk-0005Yi-Qu for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jun 2018 07:32:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrOx-0000VU-PM for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:17:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYrOw-0003CV-PX for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:17:19 -0400 Received: from foss.arm.com ([217.140.101.70]:39614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrOw-0003Br-Ih for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:17:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E1E91168F; Fri, 29 Jun 2018 04:17:17 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8ADA13F266; Fri, 29 Jun 2018 04:17:15 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Date: Fri, 29 Jun 2018 12:15:44 +0100 Message-Id: <1530270944-11351-25-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530270944-11351-1-git-send-email-suzuki.poulose@arm.com> References: <1530270944-11351-1-git-send-email-suzuki.poulose@arm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.140.101.70 Subject: [Qemu-devel] [kvmtool test PATCH 24/24] kvmtool: arm: Add support for creating VM with PA size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cdall@kernel.org, kvm@vger.kernel.org, Suzuki K Poulose , marc.zyngier@arm.com, catalin.marinas@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, eric.auger@redhat.com, julien.grall@arm.com, james.morse@arm.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Specify the physical size for the VM encoded in the vm type. Signed-off-by: Suzuki K Poulose --- arm/include/arm-common/kvm-arch.h | 6 +++++- arm/kvm.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index b29b4b1..d77f3ac 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -44,7 +44,11 @@ #define KVM_IRQ_OFFSET GIC_SPI_IRQ_BASE -#define KVM_VM_TYPE 0 +extern unsigned long kvm_arm_type; +extern void kvm__arch_init_hyp(struct kvm *kvm); + +#define KVM_VM_TYPE kvm_arm_type +#define kvm__arch_init_hyp kvm__arch_init_hyp #define VIRTIO_DEFAULT_TRANS(kvm) \ ((kvm)->cfg.arch.virtio_trans_pci ? VIRTIO_PCI : VIRTIO_MMIO) diff --git a/arm/kvm.c b/arm/kvm.c index 5701d41..b1969be 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -11,6 +11,8 @@ #include #include +unsigned long kvm_arm_type; + struct kvm_ext kvm_req_ext[] = { { DEFINE_KVM_EXT(KVM_CAP_IRQCHIP) }, { DEFINE_KVM_EXT(KVM_CAP_ONE_REG) }, @@ -18,6 +20,26 @@ struct kvm_ext kvm_req_ext[] = { { 0, 0 }, }; +#ifndef KVM_ARM_GET_MAX_VM_PHYS_SHIFT +#define KVM_ARM_GET_MAX_VM_PHYS_SHIFT _IO(KVMIO, 0x0b) +#endif + +void kvm__arch_init_hyp(struct kvm *kvm) +{ + int max_ipa; + + max_ipa = ioctl(kvm->sys_fd, KVM_ARM_GET_MAX_VM_PHYS_SHIFT); + if (max_ipa < 0) + max_ipa = 40; + if (!kvm->cfg.arch.phys_shift) + kvm->cfg.arch.phys_shift = 40; + if (kvm->cfg.arch.phys_shift > max_ipa) + die("Requested PA size (%u) is not supported by the host (%ubits)\n", + kvm->cfg.arch.phys_shift, max_ipa); + if (kvm->cfg.arch.phys_shift != 40) + kvm_arm_type = kvm->cfg.arch.phys_shift; +} + bool kvm__arch_cpu_supports_vm(void) { /* The KVM capability check is enough. */