Received: by 10.213.65.68 with SMTP id h4csp696041imn; Tue, 27 Mar 2018 07:09:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELtzIZSGtlkOdYML0UWY+xlb6wxkgmwu6fL1Pv6c77gaFKe6/v/ywfPk2LliT7DxolBapbjg X-Received: by 10.98.102.79 with SMTP id a76mr17018491pfc.162.1522159770042; Tue, 27 Mar 2018 07:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522159770; cv=none; d=google.com; s=arc-20160816; b=0YSeMeoLoEPk7QEm06uP+/fhhrBtwU1xdt7ukw+uuphEXZs8fzncyn10Ef5mMVNOp6 PyclzBwPgpV5LnjGsf689r7+rgf+GH0MjTC/KcBjk6Zds2Ary3nBwSo4/B0jvYiHIcnO 21AtLXxkkJb+JcyrgEJsJjS7Rn7cgj8o4/09DheY0UHtMCkJ0+lASWh3trrAlQSygD3E KZER/2SJaYaej+3IT+NEYBJdQGbDGDtQu/Yn+ZTV66uETUguHC3raNGSJNxfUz9kmno9 W5mmnLjEpYqVLgm0I0yhI8c+y10fKvwFye+BXkvxFnD+vPS6mk6rss8Vrud35VEEmWqZ v5Tw== 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=bQjAcrSH0ZF80tKBBysBrbabkWvIKNYHquSaeMDd7Zo=; b=i+Z8LpkHBNIlFWOulV9DN67QnxhSkzLfAxUegjV+IXPHWNhg95WpO/uthqk8xi6ICv eERyc9uFvexu75q4rg+B6TplFf4I39m2/WqWfR0UxmdUHBvGssmJzz8LpHpO7h3jOJ7J 7nmCXsreBJkaxFQcTZ3+e0Bu30GME7b3DYFSmqjMG1unFijpszlb7HDleaxmmzdlFsHO SHsrK/k2Lv3lPJtrbQi0Qe4ObOmfwpEEjr3wLSahfnzDBhwv+xX9SsxnICq+KaOW62+w ejvnNx6MAViViXi6RqSGz6MWUtuERvRpNHf6Pt1F8QSRPu3VXPMbAxKbPtgiP4uSSTuS 710Q== 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 q3si897526pgv.794.2018.03.27.07.09.15; Tue, 27 Mar 2018 07:09:29 -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 S1753042AbeC0OEq (ORCPT + 99 others); Tue, 27 Mar 2018 10:04:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752995AbeC0OEn (ORCPT ); Tue, 27 Mar 2018 10:04:43 -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 4D8E9406E97F; Tue, 27 Mar 2018 14:04:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-135.ams2.redhat.com [10.36.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A1C1215CDB5; Tue, 27 Mar 2018 14:04:40 +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: [RFC v2 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev Date: Tue, 27 Mar 2018 16:04:12 +0200 Message-Id: <1522159456-10419-9-git-send-email-eric.auger@redhat.com> In-Reply-To: <1522159456-10419-1-git-send-email-eric.auger@redhat.com> References: <1522159456-10419-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]); Tue, 27 Mar 2018 14:04:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Mar 2018 14:04:42 +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 ef509e6..78e0c2f 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 2f3b9e5..89faadc 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