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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 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 8BBFFC433DB for ; Thu, 18 Mar 2021 10:23:58 +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 1C6F464E98 for ; Thu, 18 Mar 2021 10:23:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C6F464E98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=067VQkB5jt7De86wnpOkoUcw/nRLpoMNVi4RMzp9VSE=; b=oJcauPbmtguA+OqUQD+6SiCuv eUccDhmbvTOvoL/IXSW8YJXPPCvdFrLyih43mQroR1GcYO987lSoaACDR0dkrcWNffjN5Q60jlqFe H8wY5QLQ2nzlc17kT+kL+Dbxa6Z75qAITLte0QSi2E96o+avp0zZRJuiE+8X9eq/6R1THgBZ6He/T YVyNG6c+WKOoU+gritt9pF9n6EM4PZE5Z6qik94HtRr0J7TpLlLt8T4oiU894f2E2Bu8sV01c1HAI sREchYdZ2TCjYtJ8jLbJBeqHVPCtVENMf3uHYPOzkjEAefgLD5lKrHNMX73gBqf7ULlzX+Nb5y5U/ s1EFF0Srw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMpmr-004zWh-7P; Thu, 18 Mar 2021 10:21:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMpmh-004zVz-K3 for linux-arm-kernel@lists.infradead.org; Thu, 18 Mar 2021 10:21:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B1A231B; Thu, 18 Mar 2021 03:21:42 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECB793F792; Thu, 18 Mar 2021 03:21:41 -0700 (PDT) Date: Thu, 18 Mar 2021 10:21:25 +0000 From: Andre Przywara To: Marc Zyngier 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 Message-ID: <20210318102125.68de47db@slackpad.fritz.box> In-Reply-To: <20210309163909.822149-3-maz@kernel.org> References: <20210309163909.822149-1-maz@kernel.org> <20210309163909.822149-3-maz@kernel.org> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210318_102143_842927_9BA5AC3D X-CRM114-Status: GOOD ( 19.88 ) 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 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. Other than that looks good. Cheers, Andre > +} _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel