Received: by 10.213.65.68 with SMTP id h4csp1396189imn; Mon, 19 Mar 2018 03:03:11 -0700 (PDT) X-Google-Smtp-Source: AG47ELu7+KYN/2HqZ3hHo7H1JApbinkIAQ4RbwR5+tTMDCR9a8qbmJp0uZtW1u5EMIJ4zXaZw1gG X-Received: by 10.99.50.66 with SMTP id y63mr8887637pgy.207.1521453791264; Mon, 19 Mar 2018 03:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521453791; cv=none; d=google.com; s=arc-20160816; b=1AXxlcs2nFHZWOdBDJ0s7aL4HWTN4UfTDEUaKUaSQVCct2bOgpbZKO6p1owPil3ehd A/0WvpTusBeppvvBxXWeCUXw1S7T1SiNbr0PTR7Y+1RYuyL0f6MY+AVciynymjnqKIqX RJZ2uv/HVsFqAvFn5A1+8CjGckHo+J3HoQRunXIj3ToC9PMM1EE5tY+7T20nobqTp1xu EARC7kVkIG8757peUX25oMXQYeOIfqzjuQ4Z379D2jYcRiex44uu1RqDrfPCNH05QB13 9Ad/QjONIQ1tMATxp/ucTFILBdd/pagsMTgYNTWbEjsCmr9MLZVoT6ihu6cQPExjXjvk ggpQ== 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=xy1BfRZIEqYNCDoYqMIbJEyorqoJ5I+dtOWBcF+Dm1M=; b=JBWJmwZa7zKJ839iQMQcZZ+3VORe3weD1TExNXI+/x/BCiImS/lq9kYhT4oyZFS5r2 uFgl0f5JhKX6jF7bZQqBt7VXFVbOJoQuLLtNj8xN2O9nhHbsPCvhiB2NkO6JmxiPhAKA 25BWxO+KhC+H+fXTSsOyl+blPHsFWTiHxGEYmRuaO3+M9O3ot+OYyTdVQtg6pClVj2Si Q/uNynbp+oHlys9W0s4sYPp5gncIYJ0sadVFWa5Xd93CeS/joHVeKSjTEpZXMd/0PJN9 wxzZULmOwduiiQKWHWLEMhFETbtmDmoxJfYp19dUKe5KLYLK83jwD9X7MqhtKtHm14o2 +dVQ== 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 c16-v6si879964plo.675.2018.03.19.03.02.57; Mon, 19 Mar 2018 03:03:11 -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 S933135AbeCSJYB (ORCPT + 99 others); Mon, 19 Mar 2018 05:24:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36464 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933003AbeCSJUu (ORCPT ); Mon, 19 Mar 2018 05:20:50 -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 D61524068034; Mon, 19 Mar 2018 09:20:49 +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 8A8396352A; Mon, 19 Mar 2018 09:20:43 +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 06/12] KVM: arm/arm64: Helper to detect whether an RDIST is the last one Date: Mon, 19 Mar 2018 10:20:14 +0100 Message-Id: <1521451220-27754-7-git-send-email-eric.auger@redhat.com> In-Reply-To: <1521451220-27754-1-git-send-email-eric.auger@redhat.com> References: <1521451220-27754-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.5]); Mon, 19 Mar 2018 09:20:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 19 Mar 2018 09:20:49 +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 The TYPER of an redistributor needs to reflect whether the rdist is the last one of the redistributor region. With a single region we compared the vcpu id against the number of online vcpus. With multiple regions, we also need to check the region is not full. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +-- virt/kvm/arm/vgic/vgic.h | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 227b8b6..5768034 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -637,8 +637,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) } rdreg->free_pfn_offset += 2; - vgic_cpu->rdist_last = - (vcpu->vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1); + vgic_cpu->rdist_last = vgic_v3_last_rdist(vcpu, rdreg); out: mutex_unlock(&kvm->slots_lock); return ret; diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 38b2406..04456d3 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -254,6 +254,15 @@ vgic_v3_redist_region_full(struct vgic_redist_region *region) return (region->free_pfn_offset > region->pfns - 2); } +static inline bool +vgic_v3_last_rdist(struct kvm_vcpu *vcpu, struct vgic_redist_region *region) +{ + if (vcpu->vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1) + return true; + + return vgic_v3_redist_region_full(region); +} + struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions, uint32_t *free_pfn_offset); -- 2.5.5