Received: by 10.192.165.148 with SMTP id m20csp3553477imm; Mon, 30 Apr 2018 02:10:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKpvDIBMW8oIvsQDmmNGJYsb/BrQdgz3P99a0wjj5mImqg7uDIHDPy9hcv22p4nNbdC9vu X-Received: by 10.98.33.151 with SMTP id o23mr11381432pfj.202.1525079455749; Mon, 30 Apr 2018 02:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079455; cv=none; d=google.com; s=arc-20160816; b=qr798Adsx8ld2sKXRu2C4Ld/e2PVRLmIssN65ogJlVOf2n7284HOGrfJhqwEA9sp86 7+vKe0A5/rhQDNooOSEeJCm13TdrZPs9m8mqnFiigzBnIVNTcvQDP2DJHWzFkLUTcgO0 23PBaZ1dIng609I8ylc7rJafjDRux7xkvGh3q2FDC/7RDE4Clv871/JZRWxT36lsl5Rl eRJpSLT9fykqmKQMuXEJaWJRkUZMRcmo5Efu7ERGwkM5vf4j2eWr856MHSEt955HqagV 9Iun5Tz51yHiKy/HaqdOfmXgV90iMGb/SbZC5GfjINidhlh0/cK8TIqb65YNS97XHfEQ iJQw== 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=IyZFRentG1VSVvmNWkxKcsgJRCBnf4czrhpjVB0aZ/nMuCor+8Wm+EbG1t8H4bTGh3 IsMb9k9RGEJ4AZLPPUTZCLOFoXKXYTbYV3r9bDVuVoHhqf/cZ1M3cfwhUYo8bMEKnm5k qpt3PndNpYWoTuhQ75F8k3wtR79A5ajp+QQXGgXvoNaPxC7o9OT1kVOFOYr5tdq9Ny0v gp8YAe2GU6tm2bHXqz/lgERRfL3deA01j8mP4sJ/GjH8DhjiCWIX1+NiTQIjZ5Nay0wk okyAZj9YLFuJWNWFz49B3KFwlzpDCSXTAntyVfJBluNnIs1r6Vbojmwe59U+cb6E9Icq JGzw== 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 j123si7478800pfd.207.2018.04.30.02.10.41; Mon, 30 Apr 2018 02:10:55 -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 S1752959AbeD3JIC (ORCPT + 99 others); Mon, 30 Apr 2018 05:08:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49504 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752102AbeD3JH7 (ORCPT ); Mon, 30 Apr 2018 05:07:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEE464023335; Mon, 30 Apr 2018 09:07:58 +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 3D7D42024CA1; Mon, 30 Apr 2018 09:07:57 +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 v5 05/12] KVM: arm/arm64: Revisit Redistributor TYPER last bit computation Date: Mon, 30 Apr 2018 11:07:37 +0200 Message-Id: <1525079264-25533-6-git-send-email-eric.auger@redhat.com> In-Reply-To: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> References: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 30 Apr 2018 09:07:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 30 Apr 2018 09:07:58 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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