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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 E2809C433DB for ; Thu, 11 Mar 2021 11:15:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DB2E64FCD for ; Thu, 11 Mar 2021 11:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232518AbhCKLPP (ORCPT ); Thu, 11 Mar 2021 06:15:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58617 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232611AbhCKLPO (ORCPT ); Thu, 11 Mar 2021 06:15:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615461314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HLjJbWr4BucAiEq+UPFMlG+jYewhjm6x9TggCNo+wzk=; b=H/jvSlnxM8LY2jkmwL37jZv0AWchHhoffq6yZPlIHkM9SN4uNp/1zLXG3ebtLY0BOobPpJ tSjZdUlY/Qq2qEsf4lvu+M0Q3/WWK7NgINUbwFcL9TSVVBEpQus07Tb6QIS8n/DumuJCus 2d/BVXfDcfVF41UQHa+9KziuVM7rwvQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-u3Nb2-jMM2qT9pMPrj0aJg-1; Thu, 11 Mar 2021 06:15:12 -0500 X-MC-Unique: u3Nb2-jMM2qT9pMPrj0aJg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48E8118460E1; Thu, 11 Mar 2021 11:15:10 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.40.193.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BDC950D38; Thu, 11 Mar 2021 11:15:03 +0000 (UTC) Date: Thu, 11 Mar 2021 12:15:00 +0100 From: Andrew Jones To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Eric Auger , Alexandru Elisei , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH v3 2/2] KVM: arm64: Fix exclusive limit for IPA size Message-ID: <20210311111500.uqy4lolxtp7t4xd4@kamzik.brq.redhat.com> References: <20210311100016.3830038-1-maz@kernel.org> <20210311100016.3830038-3-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311100016.3830038-3-maz@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Thu, Mar 11, 2021 at 10:00:16AM +0000, Marc Zyngier wrote: > When registering a memslot, we check the size and location of that > memslot against the IPA size to ensure that we can provide guest > access to the whole of the memory. > > Unfortunately, this check rejects memslot that end-up at the exact > limit of the addressing capability for a given IPA size. For example, > it refuses the creation of a 2GB memslot at 0x8000000 with a 32bit > IPA space. > > Fix it by relaxing the check to accept a memslot reaching the > limit of the IPA space. > > Fixes: e55cac5bf2a9 ("kvm: arm/arm64: Prepare for VM specific stage2 translations") Isn't this actually fixing commit c3058d5da222 ("arm/arm64: KVM: Ensure memslots are within KVM_PHYS_SIZE") ? > Reviewed-by: Eric Auger > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org > --- > arch/arm64/kvm/mmu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > 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); > -- > 2.29.2 > Otherwise Reviewed-by: Andrew Jones Thanks, drew 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 99D16C433E0 for ; Thu, 11 Mar 2021 11:15:20 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id D785264FA8 for ; Thu, 11 Mar 2021 11:15:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D785264FA8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 442DD4B4FA; Thu, 11 Mar 2021 06:15:19 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com 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 oml7dNsX8Cbu; Thu, 11 Mar 2021 06:15:18 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 164504B53E; Thu, 11 Mar 2021 06:15:18 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 34EE24B51E for ; Thu, 11 Mar 2021 06:15: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 tPEaotXy2W7M for ; Thu, 11 Mar 2021 06:15:16 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3D1204B4FA for ; Thu, 11 Mar 2021 06:15:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615461316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HLjJbWr4BucAiEq+UPFMlG+jYewhjm6x9TggCNo+wzk=; b=P7luaMEOg9x45dfQzDju/XGYYPDFYCkVnxF0rd9jAilnz4AW2gG4bOuB7MWYv4DoaT8xA6 BS8XbwoLyhbHZDfN3b2b4/vjVN58Y1Q9ekDGVSc2+Iz9+mpLAF6/CCXG9UTXOD6BWweFrF 9sTbpgd3ZSzb/NseOreiYE6h93OTI5U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-u3Nb2-jMM2qT9pMPrj0aJg-1; Thu, 11 Mar 2021 06:15:12 -0500 X-MC-Unique: u3Nb2-jMM2qT9pMPrj0aJg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48E8118460E1; Thu, 11 Mar 2021 11:15:10 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.40.193.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BDC950D38; Thu, 11 Mar 2021 11:15:03 +0000 (UTC) Date: Thu, 11 Mar 2021 12:15:00 +0100 From: Andrew Jones To: Marc Zyngier Subject: Re: [PATCH v3 2/2] KVM: arm64: Fix exclusive limit for IPA size Message-ID: <20210311111500.uqy4lolxtp7t4xd4@kamzik.brq.redhat.com> References: <20210311100016.3830038-1-maz@kernel.org> <20210311100016.3830038-3-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210311100016.3830038-3-maz@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Cc: kernel-team@android.com, kvm@vger.kernel.org, stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , 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 On Thu, Mar 11, 2021 at 10:00:16AM +0000, Marc Zyngier wrote: > When registering a memslot, we check the size and location of that > memslot against the IPA size to ensure that we can provide guest > access to the whole of the memory. > > Unfortunately, this check rejects memslot that end-up at the exact > limit of the addressing capability for a given IPA size. For example, > it refuses the creation of a 2GB memslot at 0x8000000 with a 32bit > IPA space. > > Fix it by relaxing the check to accept a memslot reaching the > limit of the IPA space. > > Fixes: e55cac5bf2a9 ("kvm: arm/arm64: Prepare for VM specific stage2 translations") Isn't this actually fixing commit c3058d5da222 ("arm/arm64: KVM: Ensure memslots are within KVM_PHYS_SIZE") ? > Reviewed-by: Eric Auger > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org > --- > arch/arm64/kvm/mmu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > 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); > -- > 2.29.2 > Otherwise Reviewed-by: Andrew Jones Thanks, drew _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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,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 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 7D7AEC433DB for ; Thu, 11 Mar 2021 11:16:43 +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 C727A64F01 for ; Thu, 11 Mar 2021 11:16:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C727A64F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.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:In-Reply-To:MIME-Version:References: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=UxUVN6ymIqvFC6wlf8XfQB29OkARgIQlhE8CNmY6o2w=; b=Uo7F94EazSYeE/zXgcymiumct kZzHh1pEJmrb91XRIp58SvtG1DQYJcFSaJfATQpmvpetkiIskrJXARzAtyT15JVQt6DKK3C59Hbg3 pqmyyx7fx8PbsMrNLvRtyuIL/Eyt+cfj/7RIOeg15nJOvVWSbF4SiWwRmqHzfw/QTjWPuVkVihKpi 1Mdyr3sFwvtn/K3VJjNlZzEmNWwIMIFXntjGCtpUmswzPkIhi7571XT+/y4wTYts5/Qjn+ISAQ/Fx 0JYiLyfBB1thGcfoSMfx7YOyNtQvb3e4MYcBDD0cIqisjhq5EnixueLV+ToiVS382zrREQyOhxqKx kasoBPkCQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKJHl-008vRJ-Mt; Thu, 11 Mar 2021 11:15:21 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKJHh-008vQa-Cf for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 11:15:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615461316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HLjJbWr4BucAiEq+UPFMlG+jYewhjm6x9TggCNo+wzk=; b=P7luaMEOg9x45dfQzDju/XGYYPDFYCkVnxF0rd9jAilnz4AW2gG4bOuB7MWYv4DoaT8xA6 BS8XbwoLyhbHZDfN3b2b4/vjVN58Y1Q9ekDGVSc2+Iz9+mpLAF6/CCXG9UTXOD6BWweFrF 9sTbpgd3ZSzb/NseOreiYE6h93OTI5U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-u3Nb2-jMM2qT9pMPrj0aJg-1; Thu, 11 Mar 2021 06:15:12 -0500 X-MC-Unique: u3Nb2-jMM2qT9pMPrj0aJg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48E8118460E1; Thu, 11 Mar 2021 11:15:10 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.40.193.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BDC950D38; Thu, 11 Mar 2021 11:15:03 +0000 (UTC) Date: Thu, 11 Mar 2021 12:15:00 +0100 From: Andrew Jones To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Eric Auger , Alexandru Elisei , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH v3 2/2] KVM: arm64: Fix exclusive limit for IPA size Message-ID: <20210311111500.uqy4lolxtp7t4xd4@kamzik.brq.redhat.com> References: <20210311100016.3830038-1-maz@kernel.org> <20210311100016.3830038-3-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210311100016.3830038-3-maz@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_111517_587648_64A5FF2B X-CRM114-Status: GOOD ( 21.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, Mar 11, 2021 at 10:00:16AM +0000, Marc Zyngier wrote: > When registering a memslot, we check the size and location of that > memslot against the IPA size to ensure that we can provide guest > access to the whole of the memory. > > Unfortunately, this check rejects memslot that end-up at the exact > limit of the addressing capability for a given IPA size. For example, > it refuses the creation of a 2GB memslot at 0x8000000 with a 32bit > IPA space. > > Fix it by relaxing the check to accept a memslot reaching the > limit of the IPA space. > > Fixes: e55cac5bf2a9 ("kvm: arm/arm64: Prepare for VM specific stage2 translations") Isn't this actually fixing commit c3058d5da222 ("arm/arm64: KVM: Ensure memslots are within KVM_PHYS_SIZE") ? > Reviewed-by: Eric Auger > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org > --- > arch/arm64/kvm/mmu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > 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); > -- > 2.29.2 > Otherwise Reviewed-by: Andrew Jones Thanks, drew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel