Received: by 10.192.165.148 with SMTP id m20csp773812imm; Fri, 27 Apr 2018 07:19:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpraL9riWndCWoj9I4a9lHwxwN84nK7jxRVNFSHHZ1+dwtDaXZfATKOIxHdb4LeGzY6DIUR X-Received: by 2002:a63:ab05:: with SMTP id p5-v6mr2219960pgf.387.1524838742644; Fri, 27 Apr 2018 07:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838742; cv=none; d=google.com; s=arc-20160816; b=q94m3YY8htuKqYznyYD5i8UIcXW//jYLiv6cbgCeKZnAmBNSY9eKwm5s5eaH9UsJ86 iaAe0v6r8eyDrRkwlJOMiwcxI7BMvyR+A763IbCcQ8SqbnB8Nqk/BhaRd2vOwTq/AOH2 JsxrSqUabbQRh4fvxuguob0WScCJO1zLPdzFv+75DTRPpjghi1m7X9zQkq3tAdxAST/A WEugLn/bI3HQ9N55uVHocECBVBOsx1qk2YnfzVS72PL7lE4n96XNbU8VV1I872SZs3OM WDwGcUg81Cht8LBn0btP48PjX3ZyOq8IlqVaePdHIUsaRunsbV5QPzBzQX5NLnl3zZWF OC0w== 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=3Cgs8Ov6/wZf1rtTsFPndBk6vafkd6JfhcFppMJmeLo=; b=laBgjtSe8IJ8FSCenDzM/w5uY/1z/a7VoiU3LULEZYzRqHFG5uGsCdYm/Pk53HHy7L 3Ucbrfw05NuNf2qbksAFswOHQtHBC9O8QSC9orn6ER2cXFhP3HcNksEJ3jksILVi1Th0 qvgfP8jw2ipTBvesPnomZlXgJ4XQRd4HCwAejXlZJ0OCo7162vubx/ICnBxX52cVMlIG BPzcgYz6HJaHQeYJ3iBlLkL7rB1DuZwRFX8tZ6N/xhhvG57gJOvCn56faoQygDO8KM1q aQ8CLOFqXQqjCa+o6+kgf3N+f5VrMn8iBNeDatzrHUifYJr1XGh3q/PXw7PcSaKvg4vt 7bUw== 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 y6-v6si1224294pgv.520.2018.04.27.07.18.48; Fri, 27 Apr 2018 07:19:02 -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 S935380AbeD0ORE (ORCPT + 99 others); Fri, 27 Apr 2018 10:17:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935308AbeD0OPf (ORCPT ); Fri, 27 Apr 2018 10:15:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FF4211F54C; Fri, 27 Apr 2018 14:15:34 +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 C37D3AB3FF; Fri, 27 Apr 2018 14:15:32 +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 v4 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev Date: Fri, 27 Apr 2018 16:15:01 +0200 Message-Id: <1524838505-3823-9-git-send-email-eric.auger@redhat.com> In-Reply-To: <1524838505-3823-1-git-send-email-eric.auger@redhat.com> References: <1524838505-3823-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 27 Apr 2018 14:15:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 27 Apr 2018 14:15:34 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 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