From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA6F9C6778C for ; Wed, 4 Jul 2018 14:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E99E23E3C for ; Wed, 4 Jul 2018 14:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E99E23E3C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753322AbeGDOlj (ORCPT ); Wed, 4 Jul 2018 10:41:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38586 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511AbeGDOlh (ORCPT ); Wed, 4 Jul 2018 10:41:37 -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 7CD4018A; Wed, 4 Jul 2018 07:41:37 -0700 (PDT) Received: from big-swifty.misterjones.org (big-swifty.cambridge.arm.com [10.1.25.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0549F3F5A0; Wed, 4 Jul 2018 07:41:26 -0700 (PDT) Date: Wed, 04 Jul 2018 15:41:18 +0100 Message-ID: <8636wzysfl.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Will Deacon Cc: Suzuki K Poulose , , , , , , , , , , , Subject: Re: [kvmtool test PATCH 24/24] kvmtool: arm: Add support for creating VM with PA size In-Reply-To: <20180704142241.GG4828@arm.com> 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> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 04 Jul 2018 15:22:42 +0100, 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? > > Also, couldn't KVM figure it out automatically if you add memslots at high > addresses, making this a niche tunable outside of testing? Not really. Let's say I want my IPA space split in two: memory covers the low 47 bit, and I want MMIO spanning the top 47 bit. With your scheme, you'd end-up with a 47bit IPA space, while you really want 48 bits (MMIO space implemented by userspace isn't registered to the kernel). M. -- Jazz is not dead, it just smell funny.