Received: by 10.192.165.148 with SMTP id m20csp3553464imm; Mon, 30 Apr 2018 02:10:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp0tc8btfLuOHm2cwdt/stq2iK0gKFYqOKQTwPd3UX5ysCR3Uzd3K2PIg37SZ/xakDGrznC X-Received: by 2002:a63:b008:: with SMTP id h8-v6mr9458875pgf.448.1525079454890; Mon, 30 Apr 2018 02:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079454; cv=none; d=google.com; s=arc-20160816; b=ZpYdGTv7pJxyKIlkb4RK28vU607RhOfdCERhaVco9IlTL39J+7mjcz3mX5D+JZGF9p pZmri5hqCZVrGaId0EfzCDshnaZtzzQ0FT6IvZ4cbxfrVFMoI5fqdZ1It/nHRIh3C3u3 Jj6eM387hUDIE0GQvgQehtUFVIddxEul9mcaPPT/bDMnTpB+KkmJS4L7f0aYrBPao1mJ UDUITuz0vImJcf7QeOVWTpzPAi/qcddDpwnLQt/D3OdhOSJsw+lPL3jlTh2ZwS/NGuVP 9OOlrc1DbseYGzEuAOoKPKGES3zi5iv2lYPRDnoMbepPXKlgRqpdgWycJXfEnBEqsxoF iSuw== 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=bi9SZhiXOwMHA3M56MBtvkf1ZA4agRJsI0tQ91+I8TE=; b=i7YmcK5MkqHSEP6TfsUO1inObe/aRFK5ofpjG6UB3REMA2GCEhDVY1y5f38C+kLtHq cnFLeI2p6sOkB+tEGDip0UCVRhsP3AgNuZ6fWgPoA1qTwmdoAhAX2vMkPrYnwQ1kf5Vf SwI24H1o0ejFFetb9Z3GjCe8Zq25/KBPhs4uXUmRzL5bLc6JEfsGMtA7qfLpBHo42kYy Pq0P9KOkFgv7xbi3Gs4CjlMW4f5IV1onOaGBJ1HoJ+KJ6g/dLPLs1j8q8t5o9jRR3k5o ci/k2LkR5we6rMYNQv7TwkuCaJrgBOPQEw/Nx1iEBm+uiOnraUBjge9OYsJfqlgJBZA0 puGQ== 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 w68si3344006pfb.325.2018.04.30.02.10.41; Mon, 30 Apr 2018 02:10:54 -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 S1753119AbeD3JIH (ORCPT + 99 others); Mon, 30 Apr 2018 05:08:07 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40758 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752877AbeD3JIF (ORCPT ); Mon, 30 Apr 2018 05:08:05 -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 A600B410FBB4; Mon, 30 Apr 2018 09:08:04 +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 F35C52024CA1; Mon, 30 Apr 2018 09:08:02 +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 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev Date: Mon, 30 Apr 2018 11:07:40 +0200 Message-Id: <1525079264-25533-9-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.7]); Mon, 30 Apr 2018 09:08:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 30 Apr 2018 09:08:04 +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 As we are going to register several redist regions, vgic_register_all_redist_iodevs() may be called several times. We need to register a redist_iodev for a given vcpu only once. So let's check if the base address has already been set. Initialize this latter in kvm_vgic_vcpu_early_init(). Signed-off-by: Eric Auger Acked-by: Christoffer Dall --- v4 -> v5: - added Christoffer's A-b --- virt/kvm/arm/vgic/vgic-init.c | 3 +++ virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 6456371..7e040e7 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -82,6 +82,9 @@ void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu) INIT_LIST_HEAD(&vgic_cpu->ap_list_head); spin_lock_init(&vgic_cpu->ap_list_lock); + vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF; + vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF; + /* * Enable and configure all SGIs to be edge-triggered and * configure all PPIs as level-triggered. diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index cbf8f4e..1b1e07f 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -592,6 +592,9 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) gpa_t rd_base, sgi_base; int ret; + if (!IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) + return 0; + /* * We may be creating VCPUs before having set the base address for the * redistributor region, in which case we will come back to this -- 2.5.5