Received: by 10.192.165.156 with SMTP id m28csp426511imm; Fri, 13 Apr 2018 01:25:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Ste7lKW+7jdDryoyCl/4G49jeWN8keIi6aqVis8krQt695SP/zRBJS8qln5bMPH4Aobrq X-Received: by 10.98.159.129 with SMTP id v1mr10501536pfk.25.1523607948179; Fri, 13 Apr 2018 01:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523607948; cv=none; d=google.com; s=arc-20160816; b=nlChMj+2kkg62mfWbwukvmcC9zLq6hHdVHES1CnJos4Uk3OyHyfrwdt7vCTPY5YrcQ 8MJXVDuMLaPq/e7y+BHQESAXkxCxEmJt9o0sP5ykc8zMOW3zS/H+bYPbxKN4rmhu223t k8VV01bVxnZ2W24LucBK7V1eT+tgdLkBRBLYjuI8HwCJMDQiWJZFxNbzPT85wEi/N/Lo daF517DE6ynsAdkju8gSra4+9u9WLgzg0Olq7KZ/90tsFSOB4mdYRMvPPpGnONA4Ebrs Kc/ir3umYfqg2sBKpu3W5phSYoXH5TAr6bGLmoW3fOBEo1WRwzcBhXBzjhxS3TfrU3DC KB9A== 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=A/hY/hSr0Nh9/TDhdRSr9HM8YzIb1m8eNybdiR6K82I=; b=nceM5/4+TGDkowNFwOfijSK6+EORaOzFmtKNH8Hfii5ADTPS6DxhI8F4HYXp6bYbKs DHWtjPMeYYGJxkOI+R+5qiakjpcTrXxgBLNf9/HsffkAVAH1K5Tk1OYd10NFbyYq3Y/H NzePEGet+ZT9GCgJLOpLMjqqx8zYYToOlBQsxyH9KlvFZffxhWjr8UtfkvWVULYwIzB2 3cK6vlWN87aLaEcK6pHHx05mMOrq5bqIXkdHBI6Ulcfc78tRO8Ej45i65vbjCC+XTS1p r5jNmjzG11hQw3/lUODktfipTsuXLcOG1tZmFV9xh8e5haTVOW5Y2U9v8EtxzHuSbpSK 3sfA== 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 y6si1624266pgv.520.2018.04.13.01.25.34; Fri, 13 Apr 2018 01:25:48 -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 S1754002AbeDMIXM (ORCPT + 99 others); Fri, 13 Apr 2018 04:23:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44960 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753657AbeDMIVW (ORCPT ); Fri, 13 Apr 2018 04:21:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23F2940704BE; Fri, 13 Apr 2018 08:21:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-192.ams2.redhat.com [10.36.116.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 238FB215CDC8; Fri, 13 Apr 2018 08:21:19 +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 v3 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev Date: Fri, 13 Apr 2018 10:20:54 +0200 Message-Id: <1523607658-9166-9-git-send-email-eric.auger@redhat.com> In-Reply-To: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 13 Apr 2018 08:21:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 13 Apr 2018 08:21:22 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 --- 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 5273fb8..df23e66 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