Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525159pxf; Mon, 15 Mar 2021 11:29:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6zFtRzRMz6P+hruyQCN7Sc4IqBxlNeh9bHhetQhOhTsBOosLFOZmrDoQ1lQ7lQ8M8YQDg X-Received: by 2002:a05:6402:1c98:: with SMTP id cy24mr31509670edb.296.1615832980580; Mon, 15 Mar 2021 11:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832980; cv=none; d=google.com; s=arc-20160816; b=uQmSk3gwF18C9DGj7CBT1+5tGbMCYuWTpx+9LypCh+TnxGydgGpBtLxeiyMbw1z5Vp gwTN/5v6rKFu6j3+I/iI1VZdkj7QGR1X1b+iNgexvPRqxukVH8095Lt6yT7DRHiTvpNP vzDvXjgGrfzRHqJrog42YPOMjBihZYXcVmnKSquOfsqfvBjttZ9/6D3dnpiQ5IFMBuRd QB6luLIN4lLKSEazfYpqzzhydIXFyEd/EGPMdyUYACWTQd+2Ew6gKfKpIhdzRfFFlmmt G5Fg8tM0DNFmFsH9uprJt23/wdR8Z4gTgqhbbYNnMGA57kXqZ2oKx+inzyMEcuKY9JMH LT/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vXNOKx2Msg1n7lybcuBYabKIMwgLbbAeYZIhCiRN9UY=; b=GVkJ3m1k3SugYmANNROBr2rbo7fpmIyP7KJGw7wJljRwwEaBCkimqutRyhn08pOh+2 laN/aZdOaxqenO9jDM9HEXd1sNEfDMplnhM3GWPowg2oDgDvSi67fWGoo5R80f5BqpD1 fCvKb3KHJxhH/CGK2hlOny4KjpZx3qKGoOWwcIKR+q8Jx7voYHWuQLRnnrMGhEks2nqd fQ+vID8AVoTUlD7rhXk6Y6vwE5P6EDPLmqpAzB4v8Lil/pFTHmBagjIiIXmKQMy8Q8sS IpFU7R3JZrbBg48oKrXZcDygoN2PGyfU6Q1lTDUDtvYKgPUSemhDvFvKzM4XVuCm2NdE KPkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MXj56FFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si11466190edd.35.2021.03.15.11.29.12; Mon, 15 Mar 2021 11:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MXj56FFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233221AbhCOOdw (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233389AbhCOOBi (ORCPT ); Mon, 15 Mar 2021 10:01:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A01364FBC; Mon, 15 Mar 2021 14:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816868; bh=8BsP7PzX23kUwEpPHzsJwyJsQ7RWeraVnNiMuMxwPVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MXj56FFiFzNiSF6tmjGrSs3v+Wq9h47s5wPTKT4eEaSI6Fxm8Vu0Mw63T52f63Ag8 DPAMhSFwEYb5kuVn6F0sUaZVAgsSrPTQ7sJLo5PnXwD99XYR7Pfoo22iEsUBsm8EMi VFFwulCZjD7S8wjkk65rHqhWDmKQm0wFzBSBXWlA= 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.4 161/168] KVM: arm64: Fix exclusive limit for IPA size Date: Mon, 15 Mar 2021 14:56:33 +0100 Message-Id: <20210315135555.657668150@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- virt/kvm/arm/mmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -2307,8 +2307,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; down_read(¤t->mm->mmap_sem);