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.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,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 BDE7EC433E0 for ; Thu, 18 Mar 2021 14:08:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38AC164EB9 for ; Thu, 18 Mar 2021 14:08:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38AC164EB9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:Cc:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gqacc6s4oGRMXpmpFixU19HfgQV6g7kqIBMRPXoGk4g=; b=mIX9pm63qVEfW1JTB4K78lH66 glfBhx3ExI6mM7WLUp4JSxi+KuWcrzZDeBKLoD0hNjKfAuchz4R6Er5zOVY/YVK3/ETOJm5cdy0eg SsIyPglGp+fBvt0BN7g2UOzunq/7EP7bkV17D6QcsamygggqJS9zBS/Dk1uLIYBcKfzEyXXLu4Trf 47sXdp9bqjKBUUwJDeOvzRXyQ6o4RQrYQNHYC+XW1O9nB3D26KL5MpiEG57Y/MvguvWO7qpJm6oyr +dZ4uGuQfcjpgzvSS4huOiRZw+9v9C6f0lzTfyYa0RIRC1O+X706VoI3KeK6jN3AY6CWjxH+MsHBH XOxIQDG6w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMtIr-005RNL-7g; Thu, 18 Mar 2021 14:07:09 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMtIn-005RMi-8F for linux-arm-kernel@lists.infradead.org; Thu, 18 Mar 2021 14:07:07 +0000 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 335AD64EB9; Thu, 18 Mar 2021 14:07:02 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] 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) (envelope-from ) id 1lMtIi-002Pny-1x; Thu, 18 Mar 2021 14:07:00 +0000 Date: Thu, 18 Mar 2021 14:06:59 +0000 Message-ID: <8735wsimik.wl-maz@kernel.org> From: Marc Zyngier To: Andre Przywara Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Alexandru Elisei Subject: Re: [PATCH 2/3] kvmtool: arm64: Use the maximum supported IPA size when creating the VM In-Reply-To: <20210318102125.68de47db@slackpad.fritz.box> References: <20210309163909.822149-1-maz@kernel.org> <20210309163909.822149-3-maz@kernel.org> <20210318102125.68de47db@slackpad.fritz.box> 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: 62.31.163.78 X-SA-Exim-Rcpt-To: andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org, will@kernel.org, alexandru.elisei@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210318_140705_630794_734AE7DF X-CRM114-Status: GOOD ( 27.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 18 Mar 2021 10:21:25 +0000, Andre Przywara wrote: > > On Tue, 9 Mar 2021 16:39:08 +0000 > Marc Zyngier wrote: > > Hi, > > > Instead of just asking the the default VM size, request the maximum > > IPA size to the kernel, and use this at VM creation time. > > > > The IPA space is parametrized accordingly. > > > > Signed-off-by: Marc Zyngier > > --- > > arm/aarch64/include/kvm/kvm-arch.h | 19 ++++++++++++++++--- > > arm/aarch64/kvm.c | 15 +++++++++++++++ > > 2 files changed, 31 insertions(+), 3 deletions(-) > > > > diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h > > index 55ef8ed..159567b 100644 > > --- a/arm/aarch64/include/kvm/kvm-arch.h > > +++ b/arm/aarch64/include/kvm/kvm-arch.h > > @@ -3,10 +3,23 @@ > > > > struct kvm; > > unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd); > > +int kvm__arch_get_ipa_limit(struct kvm *kvm); > > > > -#define ARM_MAX_MEMORY(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ > > - ARM_LOMAP_MAX_MEMORY : \ > > - ARM_HIMAP_MAX_MEMORY) > > +#define ARM_MAX_MEMORY(kvm) ({ \ > > + u64 max_ram; \ > > + \ > > + if ((kvm)->cfg.arch.aarch32_guest) { \ > > + max_ram = ARM_LOMAP_MAX_MEMORY; \ > > + } else { \ > > + int ipabits = kvm__arch_get_ipa_limit(kvm); \ > > + if (ipabits <= 0) \ > > + max_ram = ARM_HIMAP_MAX_MEMORY; \ > > + else \ > > + max_ram = (1ULL << ipabits) - ARM_MEMORY_AREA; \ > > + } \ > > + \ > > + max_ram; \ > > +}) > > > > #include "arm-common/kvm-arch.h" > > > > diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c > > index 49e1dd3..c4f81d0 100644 > > --- a/arm/aarch64/kvm.c > > +++ b/arm/aarch64/kvm.c > > @@ -46,3 +46,18 @@ fail: > > return 0x80000; > > } > > > > +int kvm__arch_get_ipa_limit(struct kvm *kvm) > > +{ > > + int ret; > > + > > + ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_VM_IPA_SIZE); > > + if (ret <= 0) > > + ret = 0; > > + > > + return ret; > > +} > > + > > +int kvm__get_vm_type(struct kvm *kvm) > > +{ > > + return kvm__arch_get_ipa_limit(kvm); > > Shouldn't that be funnelled through KVM_VM_TYPE_ARM_IPA_SIZE()? > Granted, that doesn't really do anything, but if I understand the > api.rst directly, it's logically needed to convert the IPA size into a > VM type. It wouldn't do anything indeed, until we get the magic extension that bumps the IPA space beyond 255 bits. Doesn't hurt, I guess... M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel