From patchwork Mon Mar 15 14:24:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 401112 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=-19.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, 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 75F96C433E6 for ; Mon, 15 Mar 2021 14:26:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E09F64FBE for ; Mon, 15 Mar 2021 14:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbhCOOZ6 (ORCPT ); Mon, 15 Mar 2021 10:25:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbhCOOYz (ORCPT ); Mon, 15 Mar 2021 10:24:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6BA56502F; Mon, 15 Mar 2021 14:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615818290; bh=Nvd5oyWF3MKdqkR35kmrDZ3iVMDnsuBZfQep6tSGnG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rVQx6ZrXk3HoqT/AC7B+X36YYbj6ti3FQIURWSlMYAe+qMgw6AoG5gOdeNGPNHj5G gUtokMDm4924rmJPuzRNE6qynxF2p+GCnAHa2L+6d5a4feEqFP7zARqi8fkbUJmACd SuspYeocmcMJuSmyiaNIXyOrDSjdShenrgmrSkGw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Marc Zyngier , Andrew Jones Subject: [PATCH 5.11 299/306] KVM: arm64: Fix exclusive limit for IPA size Date: Mon, 15 Mar 2021 15:24:24 +0100 Message-Id: <20210315135517.808594942@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135517.556638562@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> <20210315135517.556638562@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Greg Kroah-Hartman From: Marc Zyngier commit 262b003d059c6671601a19057e9fe1a5e7f23722 upstream. 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: 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 Reviewed-by: Andrew Jones Link: https://lore.kernel.org/r/20210311100016.3830038-3-maz@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/mmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1309,8 +1309,7 @@ int kvm_arch_prepare_memory_region(struc * 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);