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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 7A0F3C43381 for ; Tue, 9 Mar 2021 16:41:11 +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 142AB651A8 for ; Tue, 9 Mar 2021 16:41:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 142AB651A8 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:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0bHc1FFennNlWoe0hGvBho11TEk/TRXG4WVoiYdWnaY=; b=KOg92c4Hwd4X1bmLJ1RClkW4j HjRLKeFv7/c1hYB+hWjx+GvTVuBN+ZYENPHm3UXaGRk4ufoS88PqYUUqrRpdhhBZrXZ+sjh7wXMqD RDdfnrfSU9+gZPFZKHJKZYe/45IaDReo/2zFabmFxsJKyiGz7fVgNiytxaQIkxEoFgOvlfU3NbnoF CsvU+onMNQxFKfF8e6A2RCzd9obvZ7Jx0lsfm5HYLgVNhcNqL4HXPknbg3o6+CYfYpTlGhXgYh07i dMc+F7EUco3JVUAfzIOH9ZOZPvpALJHPpHRusYk1CJdVIYIOjoENDJrtnFJd51xnQ2HrzfY0cbvt2 Yi/e3BB9w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJfOl-0056Lq-Hi; Tue, 09 Mar 2021 16:39:55 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJfOO-0056HE-4a for linux-arm-kernel@lists.infradead.org; Tue, 09 Mar 2021 16:39:35 +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 3A75665239; Tue, 9 Mar 2021 16:39:30 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lJfOK-000ayV-JY; Tue, 09 Mar 2021 16:39:28 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org Cc: Andre Przywara , Will Deacon , Alexandru Elisei Subject: [PATCH 2/3] kvmtool: arm64: Use the maximum supported IPA size when creating the VM Date: Tue, 9 Mar 2021 16:39:08 +0000 Message-Id: <20210309163909.822149-3-maz@kernel.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210309163909.822149-1-maz@kernel.org> References: <20210309163909.822149-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, Andre.Przywara@arm.com, 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-20210309_163932_495139_CDFA3AAD X-CRM114-Status: GOOD ( 14.02 ) 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 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); +} -- 2.30.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel