Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp963342imm; Wed, 4 Jul 2018 08:59:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe28ajS3Y8d4wGMOvuQGg3HdSgbBG57EktovzBy/N9klwlAxkydMPAlcT4OF1ud9Tx4vjpJ X-Received: by 2002:a62:5d18:: with SMTP id r24-v6mr2793717pfb.87.1530719943164; Wed, 04 Jul 2018 08:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530719943; cv=none; d=google.com; s=arc-20160816; b=cUniXx+yifpLopnrWMHixmjgiCgtCyzenchXClDgs4Fnoono3xL88vZFYZztLYvZsR zDKkbXGWRPhgpw2VZgDvgcUf0gRdo+gI+th/m1v6iH6z3unhVwJuQhuPCeg/V7x5WyXJ Obp1SZC1yidbai99M2KNj2fC17pCa8AEG5UMl/dM8wQQNABNC3XM1SJEn3wUeIWfHSR4 Su9jLfJEugzEiwsaFywTSIke3IllCHHbi+bdV7nlJpVuYoIrr4t1SpTiAC1C46LZzIhy /kQvD9d8YiuPXWXqxfUC8/xQ+9JaeGUKDwVSJcMw+Xf9KD0Qfwr548DyhSA90ie+S7M1 WQMQ== 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=FXY9eOm1J3Nqqem9ohnhDK58eEYbvtXLB6V5MEas4ak=; b=WIyK8E1h/1ZujT3baXEKn0sQJCzwCiHTrUPw34IiXTkLnnPbcSNE5lz7P9kmWyrRuv UU3ubm320FRZc99Jsb+jlEbQRwXx+HOGyvSmElCpQMVhq4El7VsALLGOnK3+OcxTiVHY TT5DNyL7bBTj4aUelwWvsvtyg1NudNFk+TKBsSEEzM+GHYUQxgz5TXY9NFP2s6kasvZX rWeySauah23NSK2fqLAuKfD3Y8rULx3gHfvWS/NPOw7EZrhhQe1s1rcVBKSWgqFJSR6F BKoEcJfpS9LwnBDXz/jJ76ed1LbphdFK4RSjtvC0UWjBmgbQTfmUIcWGrL5zaed1hFad Ljrw== 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 78-v6si100804pfn.205.2018.07.04.08.58.48; Wed, 04 Jul 2018 08:59:03 -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 S1752946AbeGDP5x (ORCPT + 99 others); Wed, 4 Jul 2018 11:57:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39890 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752260AbeGDP5v (ORCPT ); Wed, 4 Jul 2018 11:57:51 -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 926327A9; Wed, 4 Jul 2018 08:57:51 -0700 (PDT) Received: from [192.168.0.21] (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8EE843F5AD; Wed, 4 Jul 2018 08:57:48 -0700 (PDT) Subject: Re: [kvmtool test PATCH 24/24] kvmtool: arm: Add support for creating VM with PA size To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, 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, catalin.marinas@arm.com, punit.agrawal@arm.com, qemu-devel@nongnu.org References: <1530270944-11351-1-git-send-email-suzuki.poulose@arm.com> <1530270944-11351-25-git-send-email-suzuki.poulose@arm.com> <20180704142241.GG4828@arm.com> From: Suzuki K Poulose Message-ID: <66e93016-91bd-5fbb-2479-9f1d87795e5e@arm.com> Date: Wed, 4 Jul 2018 16:58:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180704142241.GG4828@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 Will, On 07/04/2018 03:22 PM, Will Deacon wrote: > On Fri, Jun 29, 2018 at 12:15:44PM +0100, Suzuki K Poulose wrote: >> 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; >> +} > > Seems a bit weird that the "machine type identifier" to KVM_CREATE_VM is > dedicated entirely to holding the physical address shift verbatim. Is this > really the ABI? The bits[7:0] of the machine type has been reserved for the IPA shift. This version is missing the updates to the ABI documentation, I have it for the next version. > > Also, couldn't KVM figure it out automatically if you add memslots at high > addresses, making this a niche tunable outside of testing? The stage2 pgd size is really dependent on the max IPA. Also, unlike the stage1 (where the maximum size will be 1 page), the size can go upto 16 pages (and different number of levels due to concatenation), so we need to finalize this at least before the first memory gets mapped (RAM or Device). That implies, we cannot wait until all the memory slots are created. The first version of the series added a separate ioctl for specifying the limit, which had its own complexities. So, this ABI was suggested to keep things simpler. Suzuki