Received: by 10.192.165.148 with SMTP id m20csp3552594imm; Mon, 30 Apr 2018 02:09:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGnNSDojqxouzRGJL1y/9hXOpTTMTNwhykNWpAqSYUC2BXQfxvB5abC5TrnDek2HJ0pxNB X-Received: by 2002:a63:b253:: with SMTP id t19-v6mr9682227pgo.212.1525079398490; Mon, 30 Apr 2018 02:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079398; cv=none; d=google.com; s=arc-20160816; b=VZKHhpphMkLwEyJzzcoLxC08KI9auzi7rnv+A8pwqSqzB/CogPPIfQqx65IeKGqGVh xb4U9ThRMwrvtzg4ar9iKAn4ufH3zrv/gmI+QwehJ8qwmMLZWCocm+R59V777Krv4rZZ tU7HrMpqm0G5GEl52spyPJCBHFoteldHL6Z2tJ2qvLhDgUgPV8GiX0dBL/iTZndrXgGy X5d7qAL0iW0sfQyDKpgLxNtnI4VlysIHVE0yIri/VXiwAvmI07otHbgS43Fy4nTlnRC0 lE2wHeprpHLca4XWw4BbsUBW90Ap36wKjLzsbJxYTK3DfSYzSrU4AzNjzeaCv7rWAjvM FDCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Hzc66wnNt0C/F/rwkzBGKOl2A53GXzWgly7LXcWaimE=; b=dcMp7qnX/iTstny5MBb3lIlrvotyi/kIgaoBuEmR19/plEuFkncFnWGr2nW43fSf+B dDVrAiTokg/rCmyiCY4pWfh/NrWrlqScn14RM2ql8TvIz8fqfkMqW4xC2T5NSqaBorCl fQEJq/2oJc1iCyYkoow+wcdEQhh1BPHJRxTwVgvqNRvpJa1EC61ES568qi3Z1nprVwVA ID0dp53YsoHserWRgvr9h9kXAUWMnDSjHXRcz83h4CvAUkAuLt/yW3DAGS9Q1UU/WpNq JgGMtzvXl6MG47K9BCWbzhf4r+iaUEUKNg4FsAwlx6AZA8/jSV75yW3Zate+08Is5div gvnQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t144-v6si5899047pgb.94.2018.04.30.02.09.43; Mon, 30 Apr 2018 02:09:58 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbeD3JJB (ORCPT + 99 others); Mon, 30 Apr 2018 05:09:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43322 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753062AbeD3JIH (ORCPT ); Mon, 30 Apr 2018 05:08:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91921FB67F; Mon, 30 Apr 2018 09:08:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E12692024CA1; Mon, 30 Apr 2018 09:08:04 +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, marc.zyngier@arm.com, cdall@kernel.org, peter.maydell@linaro.org Cc: andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com Subject: [PATCH v5 09/12] KVM: arm/arm64: Check all vcpu redistributors are set on map_resources Date: Mon, 30 Apr 2018 11:07:41 +0200 Message-Id: <1525079264-25533-10-git-send-email-eric.auger@redhat.com> In-Reply-To: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> References: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 30 Apr 2018 09:08:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 30 Apr 2018 09:08:06 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On vcpu first run, we eventually know the actual number of vcpus. This is a synchronization point to check all redistributors were assigned. On kvm_vgic_map_resources() we check both dist and redist were set, eventually check potential base address inconsistencies. Signed-off-by: Eric Auger Reviewed-by: Christoffer Dall --- v4 -> v5: - added Christoffer's R-b v3 -> v4: - use kvm_debug --- virt/kvm/arm/vgic/vgic-v3.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index c4a2a46..5563671 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -484,16 +484,25 @@ struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions) int vgic_v3_map_resources(struct kvm *kvm) { - int ret = 0; struct vgic_dist *dist = &kvm->arch.vgic; - struct vgic_redist_region *rdreg = - list_first_entry(&dist->rd_regions, - struct vgic_redist_region, list); + struct kvm_vcpu *vcpu; + int ret = 0; + int c; if (vgic_ready(kvm)) goto out; - if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) || !rdreg) { + kvm_for_each_vcpu(c, vcpu, kvm) { + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + + if (IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) { + kvm_debug("vcpu %d redistributor base not set\n", c); + ret = -ENXIO; + goto out; + } + } + + if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base)) { kvm_err("Need to set vgic distributor addresses first\n"); ret = -ENXIO; goto out; -- 2.5.5