Received: by 10.192.165.148 with SMTP id m20csp2185331imm; Thu, 26 Apr 2018 07:10:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx486sj48gZdqGWw2/ypgcUzB2FRgIqyzaijao1nN4DBWdSKWqtoLzxIMoHGBYZHw9ge7zIZ8 X-Received: by 10.98.217.5 with SMTP id s5mr30606679pfg.20.1524751850281; Thu, 26 Apr 2018 07:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524751850; cv=none; d=google.com; s=arc-20160816; b=VQkDyiOA1Jw4d+XXTel1klPq8gwae1K8332sOnPlIFOg5Fv20PW3D54ZlSqZFBh4sT IOsCgKMKCZ5U4KFTupWYUliVssXPHddnEsmkqaW+o38hFRDv2AN/xP9zajh3e9C8OV+L f4SGllaYdy9KW6BqCOPCMqtAn2NrqFk1uEcfX8s1wtXGHdnih5+xVOQ1NNVtd5tTnZgW Ye8lCYH3F9MBxkvGZf3XHP/lzfFsywRGbqfVsjPztCIPR2YnC6PQvWSwnq+4mS2+eNU/ QcDF90UfdPWiktfuHH2oJYP0hIg6fBsOCEY1B3Hkq9B9IKs9+NrDZO/4yrjuJQOAmguC SP4Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=7I02O2UbbZm8AV7FhtepkmKBRvYgAKcMNRHAvVg/sxA=; b=hUojvO1kywGjocJNZNEDgIe04/FT/llsi8bGYBK0Y494MVPN3iIWSTqf4oE7q13Led xa49DZhuctcO5JxmaoeVgWo/3uwGFMDnjVOJ0NeCkeiXeXg3DnYptxVAae+oJ4TuFC1u 5Gn1eho+uG9IsUDHlUdUa4+AueAcYPB+fgeiKy2GP2iIDbRFla2E3slwxvYQSTpuLf0M rA+EH0WmnkSDBY+nNag3x7m1GAoOnjhmaOhLPJ5lhunS1AspvaCwqwUnPjUQQ4HMNJeY kKim52h37TN6UeUlOrZQdlfz5RUhSFDFu/9JeAC2n79yW275CwlT8EhUtGM+EH3fPZvC AwGw== 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 y22si4641788pfm.33.2018.04.26.07.10.36; Thu, 26 Apr 2018 07:10:50 -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 S932251AbeDZOJG (ORCPT + 99 others); Thu, 26 Apr 2018 10:09:06 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54160 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932216AbeDZOI7 (ORCPT ); Thu, 26 Apr 2018 10:08:59 -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 A4475165D; Thu, 26 Apr 2018 07:08:58 -0700 (PDT) Received: from [10.1.206.53] (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB9F23F4FF; Thu, 26 Apr 2018 07:08:56 -0700 (PDT) Subject: Re: [kvmtool PATCH 21/17] kvmtool: arm: Add support for creating VM with PA size To: Suzuki K Poulose , linux-arm-kernel@lists.infradead.org Cc: ard.biesheuvel@linaro.org, kvm@vger.kernel.org, marc.zyngier@arm.com, catalin.marinas@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kristina.martsenko@arm.com, pbonzini@redhat.com, kvmarm@lists.cs.columbia.edu References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> <1522156531-28348-22-git-send-email-suzuki.poulose@arm.com> From: Julien Grall Message-ID: Date: Thu, 26 Apr 2018 15:08:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1522156531-28348-22-git-send-email-suzuki.poulose@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Suzuki, On 27/03/18 14:15, Suzuki K Poulose wrote: > 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 Once the IOCTL is agreed, I think you would need to update include/linux/kvm.h. > + > +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; FWIW, older Linux will not accept a KVM type other than 0. So I think the best would be to bail out if KVM_ARM_GET_MAX_VM_PHYS_SHIFT does not exist. For safety, you could even check that arch.phys_shift is always 40 when running under older Linux. Cheers, -- Julien Grall