Received: by 10.213.65.68 with SMTP id h4csp647459imn; Tue, 27 Mar 2018 06:18:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELvI945UlUN0rjHH5jhPqkmFuG54XfSicSruGXT6U4WByjGtN15BUrICytmY4TKjM6ynI1qT X-Received: by 10.98.155.137 with SMTP id e9mr27175925pfk.109.1522156721620; Tue, 27 Mar 2018 06:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522156721; cv=none; d=google.com; s=arc-20160816; b=QuFsY7rHQPy76D+hVzT1eOQ9pWRNbqVs1G5PFMdPS7Mr9pjPj5okFQlIFNtkE5T9p8 +8UkyEjkKsPt5bvMio24gyDN/2msRd7jJWeSfHcfckrjohv9DJVPzxiI7uEmk2VXRHLM iWOF3Dg1y433Nq9rxzKMqYfLAfl7IuVKmGvmnyvWTdF2h4gLwC3rn8GXdZrdbVu/psM9 OLaLsGeE/8wKTod205YiqekG/YBaevnlNONW/+zJBfp1AOQrRoEHxGjiSpNCy0jQvO9/ CN1AW6h+ekU1DHQyo4L0Cu8ow/9s1BwKqL5RZkjOLiPb+Qs7+xUFTRYlzBguR1hhq0Pg 0Qsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=gaXuOJjj3KMyeyqwmr/X3OE+6WzDRumvSivbgBscoDU=; b=UQAKs/Tv5fbbzrlOiOAcun7NeXShj/kDcw4KdfIG5ok236B+HUGssKyj/T/qTBh03J E6HdYxm13BL4ooECKA+a9YiJNU6YZsSw/jo3w5rZ6DtKtSBvFSITcyQZP0+NDMszODuB ygw1yJEEpqVknoN5zZjDpuHWw7ufvVYZzIx6aVE1Z17FcfYsuAocAId+IxpmJUty1HOp v8FFD9I/QP3XxAEeTrq96RoQv2M637RXGg4faLMA/3akg9nhm3MQUXRGCEDP3lqU54QN j7hmLEpj/RsjZbZGoCWWztklGqY6yxDC49sb1TOhL4QdWRt2lrdHeoLrl18XIZ/cBfjt JdNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38-v6si1299059plh.476.2018.03.27.06.18.27; Tue, 27 Mar 2018 06:18:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752980AbeC0NRN (ORCPT + 99 others); Tue, 27 Mar 2018 09:17:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55260 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752943AbeC0NRC (ORCPT ); Tue, 27 Mar 2018 09:17:02 -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 6AE541650; Tue, 27 Mar 2018 06:17:02 -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 C1E7B3F24A; Tue, 27 Mar 2018 06:16:59 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Suzuki K Poulose Subject: [kvmtool PATCH 21/17] kvmtool: arm: Add support for creating VM with PA size Date: Tue, 27 Mar 2018 14:15:31 +0100 Message-Id: <1522156531-28348-22-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index ca7ab0f..64bc92a 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -42,7 +42,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..a9a9140 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,25 @@ 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, 0x0a) +#endif + +void kvm__arch_init_hyp(struct kvm *kvm) +{ + unsigned 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); + kvm_arm_type = kvm->cfg.arch.phys_shift; +} + bool kvm__arch_cpu_supports_vm(void) { /* The KVM capability check is enough. */ -- 1.9.1