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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 7E932C4338F for ; Mon, 23 Aug 2021 09:36:39 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id ECF446136F for ; Mon, 23 Aug 2021 09:36:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ECF446136F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 81C5C4B1F5; Mon, 23 Aug 2021 05:36:38 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p5ZVqEM+RS4I; Mon, 23 Aug 2021 05:36:33 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9FA544B1FA; Mon, 23 Aug 2021 05:36:33 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A213A4B1EB for ; Mon, 23 Aug 2021 05:36:32 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YT8CaueeISbl for ; Mon, 23 Aug 2021 05:36:31 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 7D2234B14B for ; Mon, 23 Aug 2021 05:36:31 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AB4F61186; Mon, 23 Aug 2021 09:36:30 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mI6NY-006ct2-AI; Mon, 23 Aug 2021 10:36:28 +0100 Date: Mon, 23 Aug 2021 10:36:27 +0100 Message-ID: <87bl5oqz8k.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Subject: Re: [PATCH v2 3/3] kvmtool: arm64: Configure VM with the minimal required IPA space In-Reply-To: References: <20210822152526.1291918-1-maz@kernel.org> <20210822152526.1291918-4-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oupton@google.com, kvmarm@lists.cs.columbia.edu, andre.przywara@arm.com, kernel-team@android.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: Andre Przywara , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, Will Deacon X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Sun, 22 Aug 2021 21:05:16 +0100, Oliver Upton wrote: > > Marc, > > On Sun, Aug 22, 2021 at 8:25 AM Marc Zyngier wrote: > > > > There is some value in keeping the IPA space small, as it reduces > > the size of the stage-2 page tables. > > > > Let's compute the required space at VM creation time, and inform > > the kernel of our requirements. > > > > Signed-off-by: Marc Zyngier > > --- > > arm/aarch64/kvm.c | 20 +++++++++++++++++++- > > 1 file changed, 19 insertions(+), 1 deletion(-) > > > > diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c > > index d03a27f2..4e66a22e 100644 > > --- a/arm/aarch64/kvm.c > > +++ b/arm/aarch64/kvm.c > > @@ -3,6 +3,7 @@ > > #include > > > > #include > > +#include > > > > /* > > * Return the TEXT_OFFSET value that the guest kernel expects. Note > > @@ -59,5 +60,22 @@ int kvm__arch_get_ipa_limit(struct kvm *kvm) > > > > int kvm__get_vm_type(struct kvm *kvm) > > { > > - return KVM_VM_TYPE_ARM_IPA_SIZE(kvm__arch_get_ipa_limit(kvm)); > > + unsigned int ipa_bits, max_ipa_bits; > > + unsigned long max_ipa; > > + > > + /* If we're running on an old kernel, use 0 as the VM type */ > > + max_ipa_bits = kvm__arch_get_ipa_limit(kvm); > > + if (!max_ipa_bits) > > + return 0; > > + > > + /* Otherwise, compute the minimal required IPA size */ > > + max_ipa = ARM_MEMORY_AREA + kvm->cfg.ram_size - 1; > > + ipa_bits = max(32, fls_long(max_ipa)); > > + pr_debug("max_ipa %lx ipa_bits %d max_ipa_bits %d", > > + max_ipa, ipa_bits, max_ipa_bits); > > + > > + if (ipa_bits > max_ipa_bits) > > + die("Memory too large for this system (needs %d bits, %d available)", ipa_bits, max_ipa_bits); > > I imagine it may not be immediately obvious to a kvmtool user what > this log line means, like what 'bits' are being referred to here. > Would it be more helpful to report the maximum allowed memory size for > the system, as derived from the max IPA? That's consistent with what "the other VMM" does as well. But sure, happy to amend the message if people feel strongly about it. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm