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 AECC6C433E9 for ; Tue, 9 Mar 2021 14:25:18 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id DBEBE651B9 for ; Tue, 9 Mar 2021 14:25:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBEBE651B9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 522934B363; Tue, 9 Mar 2021 09:25:17 -0500 (EST) 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 GcQoumXzgOcr; Tue, 9 Mar 2021 09:25:13 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4F1394B374; Tue, 9 Mar 2021 09:25:13 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E527C4B369 for ; Tue, 9 Mar 2021 09:25:11 -0500 (EST) 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 L1PfyassR+WH for ; Tue, 9 Mar 2021 09:25:07 -0500 (EST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id B54FD4B363 for ; Tue, 9 Mar 2021 09:25:07 -0500 (EST) 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 71E15651B2; Tue, 9 Mar 2021 14:25:06 +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 1lJdIG-000ZGV-Bc; Tue, 09 Mar 2021 14:25:04 +0000 Date: Tue, 09 Mar 2021 14:25:03 +0000 Message-ID: <87lfawxv40.wl-maz@kernel.org> From: Marc Zyngier To: Suzuki Poulose Subject: Re: [PATCH] KVM: arm64: Cap default IPA size to the host's own size In-Reply-To: References: <20210308174643.761100-1-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: 62.31.163.78 X-SA-Exim-Rcpt-To: suzuki.poulose@arm.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, alexandru.elisei@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kvm@vger.kernel.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu 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 Hi Suzuki, On Tue, 09 Mar 2021 11:09:48 +0000, Suzuki Poulose wrote: > > > > > On 8 Mar 2021, at 17:46, Marc Zyngier wrote: > > > > KVM/arm64 has forever used a 40bit default IPA space, partially > > due to its 32bit heritage (where the only choice is 40bit). > > > > However, there are implementations in the wild that have a *cough* > > much smaller *cough* IPA space, which leads to a misprogramming of > > VTCR_EL2, and a guest that is stuck on its first memory access > > if userspace dares to ask for the default IPA setting (which most > > VMMs do). > > > > Instead, cap the default IPA size to what the host can actually > > do, and spit out a one-off message on the console. The boot warning > > is turned into a more meaningfull message, and the new behaviour > > is also documented. > > > > Although this is a userspace ABI change, it doesn't really change > > much for userspace: > > > > - the guest couldn't run before this change, while it now has > > a chance to if the memory range fits the reduced IPA space > > > > - a memory slot that was accepted because it did fit the default > > IPA space but didn't fit the HW constraints is now properly > > rejected > > > > The other thing that's left doing is to convince userspace to > > actually use the IPA space setting instead of relying on the > > antiquated default. > > > > Signed-off-by: Marc Zyngier > > --- > > Reviewed-by: Suzuki K Poulose Thanks for that. Whilst I have your attention and given that you are responsible for most of the variable IPA stuff... ;-) I think we have another issue around the handling of our IPA size. Let's say I create a VM with a 32bit IPA space. If I register a 2GB memslot at 0x8000000, I'm getting an error, which I think is bogus. I came to the conclusion that kvm_arch_prepare_memory_region() is a bit overzealous when rejecting the memslot, and I used the following patchlet to address it. Does this seem sensible to you? M. diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 77cb2d28f2a4..8711894db8c2 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1312,8 +1312,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, * Prevent userspace from creating a memory region outside of the IPA * space addressable by the KVM guest IPA space. */ - if (memslot->base_gfn + memslot->npages >= - (kvm_phys_size(kvm) >> PAGE_SHIFT)) + if ((memslot->base_gfn + memslot->npages) > (kvm_phys_size(kvm) >> PAGE_SHIFT)) return -EFAULT; mmap_read_lock(current->mm); -- 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