Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2377921pxu; Mon, 14 Dec 2020 00:16:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJytzBObGYIFCFKSUONF30yTobY/AcdKHE9WpcSR8OrXh4Oi8SQXcvyK4OGxDBfHHvnFAJvA X-Received: by 2002:a17:906:dc1:: with SMTP id p1mr21988998eji.9.1607933774299; Mon, 14 Dec 2020 00:16:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607933774; cv=none; d=google.com; s=arc-20160816; b=gVVambOxY5wBJZ6LSmiMxWPZiEd0orGfifyatuauOcF3v2qUI3VXI8lxP8MaE5m2r1 Nhu6apQFQWf8aHZU2wrKQcjJenWIHvqiQoXXYUcUwX+WpNnseR8c2NGQ14UE0kSJXihi zldXavtK1YWTokzNDBPmzHGTwzvMNB0bq66ozD0viHCrvAHqQKB3akV/83qQgqFOrp2m XbpugDxuUi1yRQPRGIBxmQXR4nQc6gZ76c6pjyh4xCFxeIMt/20HE6w/WxkynYT+dwvH I1pme6FZquR+6kr4qE/ISUIhIDGyqTjKGkDVhRLEpGpIF/TDmpbb0KHf+lRWR/w6AxU2 UxOQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aRu7FhoYj+iXi1m//Yx7IJ9OctRxhpZYB5NeyA8SUmk=; b=o6lvxs0Ay7XlMlmlIaZTfHjkSYuWvfx5A6FCnsbUvsoz82iOKI2zlNyE7Ckiwd18qI bpDMs1SnlGVY/NOjyDOfw5oWK1JTLzFLMsY+FwdnMZKn4vDFZxGYV4y+2jvQ56Xj4qQ9 17wQsq9E83Esh1Km9Z7n2kgcEziWE3z/0Sn3l5FFyMA4ilZF716tYSTj/Zad9RkOMdLS fWAgsxPLtZDf+Uj75bOvNxy3MqV/1gM33Bt/nutxb7LdXu/Z7AgKKH/jPIe5yhfrCl+l uZpUCmR+zSEYSn0M9d05uLXrEqeLb1NjJZ2PK+9elGQR2KHodCLpT3yfZvBc0+D75Xbt vnIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a4d1mcba; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si10571025edw.515.2020.12.14.00.15.51; Mon, 14 Dec 2020 00:16:14 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=a4d1mcba; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407822AbgLLS60 (ORCPT + 99 others); Sat, 12 Dec 2020 13:58:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34741 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407741AbgLLSwA (ORCPT ); Sat, 12 Dec 2020 13:52:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607799034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aRu7FhoYj+iXi1m//Yx7IJ9OctRxhpZYB5NeyA8SUmk=; b=a4d1mcbaQue/oOmbJfMa5A6IJJCpHA9/zEtRSWpwPKnzsbHJ/Bt/K4m4Tfl5cIsWfegI49 ccSkYIApzwylAI+vov/+E80319sz3ivlZW0JJSV62WI+ZQVqMuSoW7D/bDrQRORbM0kzYm xD4QxhzK+bjqlRq9qclo8xsPNs1upUo= 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-6-HqWWyWeLNnqf-MJRL5v7cQ-1; Sat, 12 Dec 2020 13:50:30 -0500 X-MC-Unique: HqWWyWeLNnqf-MJRL5v7cQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3246A107ACE3; Sat, 12 Dec 2020 18:50:29 +0000 (UTC) Received: from laptop.redhat.com (ovpn-115-41.ams2.redhat.com [10.36.115.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 492F01F069; Sat, 12 Dec 2020 18:50:26 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, maz@kernel.org, drjones@redhat.com Cc: alexandru.elisei@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com Subject: [PATCH 1/9] KVM: arm64: vgic-v3: Fix some error codes when setting RDIST base Date: Sat, 12 Dec 2020 19:50:02 +0100 Message-Id: <20201212185010.26579-2-eric.auger@redhat.com> In-Reply-To: <20201212185010.26579-1-eric.auger@redhat.com> References: <20201212185010.26579-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KVM_DEV_ARM_VGIC_GRP_ADDR group doc says we should return -EEXIST in case the base address of the redist is already set. We currently return -EINVAL. However we need to return -EINVAL in case a legacy REDIST address is attempted to be set while REDIST_REGIONS were set. This case is discriminated by looking at the count field. Signed-off-by: Eric Auger --- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 15a6c98ee92f..8e8a862def76 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -792,8 +792,13 @@ static int vgic_v3_insert_redist_region(struct kvm *kvm, uint32_t index, int ret; /* single rdist region already set ?*/ - if (!count && !list_empty(rd_regions)) - return -EINVAL; + if (!count && !list_empty(rd_regions)) { + rdreg = list_last_entry(rd_regions, + struct vgic_redist_region, list); + if (rdreg->count) + return -EINVAL; /* Mixing REDIST and REDIST_REGION API */ + return -EEXIST; + } /* cross the end of memory ? */ if (base + size < base) -- 2.21.3