Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp973911imm; Wed, 26 Sep 2018 09:35:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV616DNyBWTo3gKL39T4eLIHTRTdX9tP8wO+mYdZnh7siJ022wBIlIcSLHsPdtZ40LBs36kxH X-Received: by 2002:a62:990f:: with SMTP id d15-v6mr7125818pfe.162.1537979709171; Wed, 26 Sep 2018 09:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537979709; cv=none; d=google.com; s=arc-20160816; b=PUAvm0FxnIM2M22B8vsSxS+bX4GCzd4Zkv6z/IuTxp/nSPdh8vLwQkL3Ej1rz8iIka /jIG6kA6Q8JwRRFbYj4gWgYMzge+QDwvxVq0LJAQf/y6huh8JUggaD+3wi2H0tQbDyHI 1CH0Y2GuvwRYxYOieugReyB3qbF1WXNxu5xtlCGOUBgCUyBWQG/QRL787rKUwH0Grk1+ RcGB/escX5DfzWYzd+/viV3L1LhXyceYd3L7l6lV8lH87B/lM+Rc6dJwV3zMPnKm+MYm TzTPq3Rr9SCoV2t46nucMZunq8jAIhws1bsQI6cJ6mhw23IAREMQLOG/AWqCCrMmHJJq 9dZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gObJOuj6u44LFLEc39mO79ZaHQlsWhX2NmK9sTQoFzQ=; b=s5AETb9oz6XlIELHChqsOAIS32WHYk00G9/JcVslqa9hLz1s/oh9G/KmMnYhDq7XRV RednxkTtHOWv4GVLzJn3qT+LtCM9afx0E0Vsnu0SwJ/I6bOPRj+CEYLrcgbvWMIBBU6u n0e2Ox88HpILhJTcn+A47B9Okc+XAuO9Qy3XMx2vYoVEejtZb/7mhx5bakDeizUxSotx sgrTscrMDEwIZdqkQjn0JH9VNL3zfqlyNqTQySRKnXBXHTp+XJP9vsqPu4uOE8g+hqS9 rR5xIxLkx3EVoH9f2tJX+WP0Sf88MAl3AznquyI4wHUQcDcliV1Ff3FsxOdweTbBhUhJ BaxQ== 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 m2-v6si5327356pfi.351.2018.09.26.09.34.53; Wed, 26 Sep 2018 09:35:09 -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 S1729143AbeIZWsO (ORCPT + 99 others); Wed, 26 Sep 2018 18:48:14 -0400 Received: from foss.arm.com ([217.140.101.70]:50236 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbeIZWsO (ORCPT ); Wed, 26 Sep 2018 18:48:14 -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 64E95237B; Wed, 26 Sep 2018 09:34:28 -0700 (PDT) Received: from en101.Emea.Arm.com (en101.emea.arm.com [10.4.13.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E94493F5B3; Wed, 26 Sep 2018 09:34:25 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, marc.zyngier@arm.com, cdall@kernel.org, eric.auger@redhat.com, suzuki.poulose@arm.com, will.deacon@arm.com, dave.martin@arm.com, peter.maydell@linaro.org, pbonzini@redhat.com, rkrcmar@redhat.com, julien.grall@arm.com, linux-kernel@vger.kernel.org Subject: [kvmtool PATCH v6 22/18] kvmtool: arm: Add support for creating VM with PA size Date: Wed, 26 Sep 2018 17:32:58 +0100 Message-Id: <20180926163258.20218-23-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926163258.20218-1-suzuki.poulose@arm.com> References: <20180926163258.20218-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 32 +++++++++++++++++++++++++++++++ 2 files changed, 37 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 eac2ad2..c8db6b3 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,36 @@ struct kvm_ext kvm_req_ext[] = { { 0, 0 }, }; +#ifndef KVM_CAP_ARM_VM_IPA_SIZE +#define KVM_CAP_ARM_VM_IPA_SIZE 159 +#endif + +#ifndef KVM_VM_TYPE_ARM_IPA_SIZE +#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL +#define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ + ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) +#endif + +void kvm__arch_init_hyp(struct kvm *kvm) +{ + int max_ipa; + + if (!kvm->cfg.arch.phys_shift) + kvm->cfg.arch.phys_shift = 40; + if (kvm->cfg.arch.phys_shift == 40) + return; + max_ipa = ioctl(kvm->sys_fd, + KVM_CHECK_EXTENSION, KVM_CAP_ARM_VM_IPA_SIZE); + if (!max_ipa) + die("Kernel doesn't support IPA size configuration\n"); + if ((kvm->cfg.arch.phys_shift > max_ipa) || + (kvm->cfg.arch.phys_shift < 32)) + die("Requested PA size (%u) is not supported by the host" + " [32 - %u]bit\n", + kvm->cfg.arch.phys_shift, max_ipa); + kvm_arm_type = KVM_VM_TYPE_ARM_IPA_SIZE(kvm->cfg.arch.phys_shift); +} + bool kvm__arch_cpu_supports_vm(void) { /* The KVM capability check is enough. */ -- 2.19.0