Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp808742imm; Fri, 29 Jun 2018 06:47:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzG6DmALbBOvTc76SoSxsxcqV/srJZ29ESogOchHpUIu+bDwi8eKoYV9gTqDDpIv6og4Dn X-Received: by 2002:a17:902:5a83:: with SMTP id r3-v6mr14720858pli.78.1530280065719; Fri, 29 Jun 2018 06:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530280065; cv=none; d=google.com; s=arc-20160816; b=vtnQoMUY8u5l66JEr27UEZkPmlotDF7ldJuDjG5Jer9iH/2s4xrFOcqsPDiwDgqm6h cdRfKfgs+tix/Fad8VHe2pUIGkMYWA7y62fkq2LHLjCDljFVHH/uyuVc35n/IVzXCF6m 3ZMo4H1Q559MwRvBw/eAhvbNGQBgt1zsDDcyj3kq08hb9oVHFoh5nds2Co82AjkpowdG pfe6euu4R5OUAVXgPxbJCYQG2FMpOrjdNXNr01G+Tg4EkMw+2z9p0nbaGhRinaVgYwz8 LwDc6BhtFFQfTETRg8EdHp/LpSV5ocbKaiCxNAzbt/2LmwwSW6aoN2dHjm7Oul2rqoBZ I7eQ== 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=REdwiAIMakpixQgOYf4x+sGvm7U1eXPClm77fl20ViA=; b=xEuBeqfBiBzuU1jmgcJ6xKXRrryBEZuS+hieMNn9gqrKBQj8c3Lv7EdX+tETSzEq0q +hfejgXc74uZiGZ3HqvtBqx8H6zkyZj+QkYh8SHKIoLRkv47GlhuTjkn5UPPLwerV+1J JJILh16Y+ufSaMsmQjwOoCKKa567lDoQVBXgEYbY+1T+Fx5djI5eeZ9vf5Ya4nOSG3oK YzbnOYfy91TJVjxQ9fxz3pZYfI2DRNJDCZ0gOSOfRNK1RLllL1G++0iBUD3v8ImC4eyp 7qnRf4QAFq9fS00tGTPEusL7LqKfdSweAdiBYx9cQqCfJCWnKwlXKDvQqvJOxkTEE/5R +keA== 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 p1-v6si9589087plb.204.2018.06.29.06.47.31; Fri, 29 Jun 2018 06:47:45 -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 S936024AbeF2LRa (ORCPT + 99 others); Fri, 29 Jun 2018 07:17:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60402 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935996AbeF2LRS (ORCPT ); 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 Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, james.morse@arm.com, marc.zyngier@arm.com, cdall@kernel.org, eric.auger@redhat.com, julien.grall@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, punit.agrawal@arm.com, qemu-devel@nongnu.org, Suzuki K Poulose Subject: [kvmtool test PATCH 24/24] kvmtool: arm: Add support for creating VM with PA size 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> 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 | 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. */ -- 2.7.4