Received: by 10.192.165.148 with SMTP id m20csp771967imm; Fri, 27 Apr 2018 07:17:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrG0YiVfDN/Qwq5E3VmMtj4ziut6VI5qWdhJY6lsoyp10bdcXlus7Mk1kwX0MU/I2H87Amo X-Received: by 2002:a63:b559:: with SMTP id u25-v6mr2233500pgo.302.1524838642915; Fri, 27 Apr 2018 07:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838642; cv=none; d=google.com; s=arc-20160816; b=tGuelkczkzxmk6MH0GEsbqDz1F4XE/Kl220CF1kVbTjf7LNB4frSkWbAZJLDvdfPqj us3umR1FX60Go2w9EMkKxqFCaxUMTT2Qt/GaU4aY56gCJaPMoSXx2/BcjzWbN0HD5Wj/ ifpR22+vUL2wMR/CdYVeSICRLPWcrj5Y5eYSAWm69e57gXl6SBM3992PRaEXHDqHdUrf GEFZ7HfV6d4HqTW+dREIGRwAwWNtiOiYkQu6s15I7QMv4AYh4RIXA77sHIBZsCN1UbCw tjl6Uax/lW6qxcACkKCwISVLdQIeVmQOFPVO2p3NXSq1ReoNMkmzh77t+ViXpW+a7GjD yQuA== 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=NOt+fvmBRrdKAGW5LpTxz1b2hNddpxFiKdY2szIDjmk=; b=Xb7IWSsKX7wTvvHr4+xmpHA/tQIb/j/Pj1MvGtID13xZV/zl+G7j51Z3S9reZ20R+8 r76UtNKEPnjCYglyTbFdcmhl4KAagKT1X0N8Q8GG9IiuiN2pdcDuZd8A9qjaipPqKIF5 LDIwqzuDC31Dos6lVXSwuxUivels2lsD9P2eIHSfiTybVP3Wma4ciGJ1Vy5LDn4w/5xm J6+Qgpn5ZPW6MYXg1PjNzEbSayC01vr3c5iXlR34H76tIS9z3W869ruvJSN0+Gpn3x4x QIOoWtVG1y8us9avRE9b+mcEpX+6A2uu4YmXCEhfvlMlDbuGAIjuJ3bgOzMdEqR6x3mR 9IKw== 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 33-v6si1329799plu.385.2018.04.27.07.17.09; Fri, 27 Apr 2018 07:17:22 -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 S935453AbeD0OP1 (ORCPT + 99 others); Fri, 27 Apr 2018 10:15:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935440AbeD0OPY (ORCPT ); Fri, 27 Apr 2018 10:15:24 -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 B8D3E40201DF; Fri, 27 Apr 2018 14:15:23 +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 146D0AB3F6; Fri, 27 Apr 2018 14:15:21 +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 05/12] KVM: arm/arm64: Revisit Redistributor TYPER last bit computation Date: Fri, 27 Apr 2018 16:14:58 +0200 Message-Id: <1524838505-3823-6-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.6]); Fri, 27 Apr 2018 14:15:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 27 Apr 2018 14:15:23 +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 reflects whether the rdist is the last one of the redistributor region. Let's compare the TYPER GPA against the address of the last occupied slot within the redistributor region. Signed-off-by: Eric Auger Reviewed-by: Christoffer Dall --- v3 -> v4: - added Christoffer's R-b --- virt/kvm/arm/vgic/vgic-mmio-v3.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 49ca176..ce5c927 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -184,12 +184,17 @@ static unsigned long vgic_mmio_read_v3r_typer(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len) { unsigned long mpidr = kvm_vcpu_get_mpidr_aff(vcpu); + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + struct vgic_redist_region *rdreg = vgic_cpu->rdreg; int target_vcpu_id = vcpu->vcpu_id; + gpa_t last_rdist_typer = rdreg->base + GICR_TYPER + + (rdreg->free_index - 1) * KVM_VGIC_V3_REDIST_SIZE; u64 value; value = (u64)(mpidr & GENMASK(23, 0)) << 32; value |= ((target_vcpu_id & 0xffff) << 8); - if (target_vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1) + + if (addr == last_rdist_typer) value |= GICR_TYPER_LAST; if (vgic_has_its(vcpu->kvm)) value |= GICR_TYPER_PLPIS; -- 2.5.5