Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp685810ybv; Thu, 13 Feb 2020 07:45:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxb7zfSQ7aUmbYq6aScx68kpoYzq74vnY1TCWlwVWadx8X+KyuvFK+0zFIq+OVsBvToFjG+ X-Received: by 2002:a9d:7f83:: with SMTP id t3mr10249295otp.63.1581608723659; Thu, 13 Feb 2020 07:45:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608723; cv=none; d=google.com; s=arc-20160816; b=a6aV1+aXzq/mIz3jTnCvmZ/JeoGOhZwZLFdVVO6lK5Psv1FnKwFd2zH88yJGUoJhu/ JJVg6K5yiTKBSkLe1dsgVCD9tbf83Ae+qh/mfGbYmVjZhHDmZAwhjPDAf6wvVLwoSG8x C9ndO1mY9r46jzmNsaZlIPOF44luJETLPG+UzuZEVEonbV4oiFR2VdhQAJM85llnnSO5 ikpxJKwNc86BzEXQSMIJWGVTowZXpld0Ogk6rXJTMStY/6qvRjKRymHf1WUfGuCs/m/p j1txN0tI+iA57RMlXI+BBvL2aVK/S9Crvc0RYRwf5qqGT7JXNzEhC7LgaFeH1kslcU7q 2uUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1HYkNFAxFoFwyj37E3YuTCqIRDUhP0EiP9aPie7+4xQ=; b=EDslY7IU28MlgEde67pLfB0RQBelncUxwMy8VWMc8XCT/LGBv+pL0kaA7JwTX2SfVl LOA0PrKmnp2Nv8+60IM1DiLX5tPaIsSWYnF5iWkeDKwITHADWyas+asbBtSyu48ZJcjv K7B9KNW3WBxfi200SiNMY2PVldIgX1kCckSKU3Ju/H1/oFGIZEERmT/X5WgU5bnciRer GlAVapDK+KvuI2A1L2V8o3mMLXUWMhbY9JIO06uncRVGhGbza4gdAt6w7Ofmd7B1sDlF yk6CTd/fBe478kQw/BndKCEgmbfE3kzgq2BgMwJJo25RtKEW64glgYk+PKNkJ+6AfxEl MUYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2V4EXcal; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si1258724oic.260.2020.02.13.07.45.10; Thu, 13 Feb 2020 07:45:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2V4EXcal; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729682AbgBMPoh (ORCPT + 99 others); Thu, 13 Feb 2020 10:44:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:52056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728894AbgBMP1l (ORCPT ); Thu, 13 Feb 2020 10:27:41 -0500 Received: from localhost (unknown [104.132.1.104]) (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 2A63F20661; Thu, 13 Feb 2020 15:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607661; bh=VE7PXwSmSw9JapI9rq7+PLy8h/PzC/94PCA7N3oN+B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2V4EXcalSzMq2uMDnMnv1iq075VRrztzTn0CBRFtneaPER66Rx0hNxtr/GPfFw75k Z/EzfwY4pTBL3NVa+7WYrZvAv1j+rgeTWPmDwLbBuUOIh1UY7IYJ6Q/3IwDPBLjHyT IOCNlbe1rflwpsnhbtC8OzL2YcLXmaPy3168UkaY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Marc Zyngier , Zenghui Yu Subject: [PATCH 5.4 62/96] KVM: arm/arm64: vgic-its: Fix restoration of unmapped collections Date: Thu, 13 Feb 2020 07:21:09 -0800 Message-Id: <20200213151903.026499129@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Auger commit 8c58be34494b7f1b2adb446e2d8beeb90e5de65b upstream. Saving/restoring an unmapped collection is a valid scenario. For example this happens if a MAPTI command was sent, featuring an unmapped collection. At the moment the CTE fails to be restored. Only compare against the number of online vcpus if the rdist base is set. Fixes: ea1ad53e1e31a ("KVM: arm64: vgic-its: Collection table save/restore") Signed-off-by: Eric Auger Signed-off-by: Marc Zyngier Reviewed-by: Zenghui Yu Link: https://lore.kernel.org/r/20191213094237.19627-1-eric.auger@redhat.com Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/vgic/vgic-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -2472,7 +2472,8 @@ static int vgic_its_restore_cte(struct v target_addr = (u32)(val >> KVM_ITS_CTE_RDBASE_SHIFT); coll_id = val & KVM_ITS_CTE_ICID_MASK; - if (target_addr >= atomic_read(&kvm->online_vcpus)) + if (target_addr != COLLECTION_NOT_MAPPED && + target_addr >= atomic_read(&kvm->online_vcpus)) return -EINVAL; collection = find_collection(its, coll_id);