Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6703941ybn; Mon, 30 Sep 2019 02:21:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl71czKq1WTGtK4olB7THM8CPLrqd0IqjXHON3ZPmB4SWSCBT6Tk8hlNPFdzdvhuUE2jTB X-Received: by 2002:aa7:d7d3:: with SMTP id e19mr18594951eds.80.1569835283582; Mon, 30 Sep 2019 02:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569835283; cv=none; d=google.com; s=arc-20160816; b=IGi2gILGKtua1hLHI/KzvIJMU/Z9chBm9ZPTE3EqWr9O6+jw/Q3SU7QcixjniJjGQF E1xrtfEG+8c6kZdlnegx3wId1EyOWiWHZVjvxiodaJufiMOacQFv6TdzY8FrmPneyRPR YZOPZgy5CSSYe4SQXqDZQ0OhcTARnpjYSBXrxRmmHpYHkzdMupb402aij4/RPUhy2vfd 7yPSRXrg1WX3OdG7KCkQ2cHa6KgJ373ZuttTOGYIChnGNl/TKGQ+b2IRLaEtVQhW+Cwq Yio+rgf76AZmsAbTbnhLfq30Dx2sNpziErsJ396X4lPc3HmGnXbu9A0wVe2n+ACoySEl tvqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=3+AY6A3E7NsFc0CgbUB/hP+tPY7Zij6AUB/Pq21BVkQ=; b=bKSCYKcJvlgJGp+s9xEKo+yJldZJ3vGRSfir+vTI37v8UnPmvX+0F+xN7hPxIwE+Ck JlzWqjrnmLpc3NAPFx24IBoYP3R0HTlVUTax9uv7MbiT8kVC/tjPPBCAudr1i9lBxX6e DhHNtNjfMJDaI6ohjgte0wnxNfRCQHsX0QG6uh/k3rDfaPSrq4AUVefI7Zm6uwGVqhqJ kydWZ/rLGwl6bHEQMufAbQQw3TpH4FDo7EiDvoqwpLud69qdGmg1k8Jnkixfbz8lpAmg P9V/RE10CclR4BCLrGq7Grog3tw9DRiXgdcnDeTbOCHnut8hcbBTj7LOJiVNUChNrGS4 Y5Pw== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si6751676ejq.395.2019.09.30.02.20.59; Mon, 30 Sep 2019 02:21:23 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730359AbfI3JUL (ORCPT + 99 others); Mon, 30 Sep 2019 05:20:11 -0400 Received: from inca-roads.misterjones.org ([213.251.177.50]:54925 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbfI3JUL (ORCPT ); Mon, 30 Sep 2019 05:20:11 -0400 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1iErqf-0001rF-5T; Mon, 30 Sep 2019 11:20:05 +0200 To: Zenghui Yu Subject: Re: [PATCH 20/35] irqchip/gic-v4.1: Allow direct invalidation of VLPIs X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 30 Sep 2019 10:20:05 +0100 From: Marc Zyngier Cc: , , Lorenzo Pieralisi , Jason Cooper , Thomas Gleixner In-Reply-To: References: <20190923182606.32100-1-maz@kernel.org> <20190923182606.32100-21-maz@kernel.org> Message-ID: <1c96d38da22a97b1fda94a940b60e345@www.loen.fr> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: yuzenghui@huawei.com, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, lorenzo.pieralisi@arm.com, jason@lakedaemon.net, tglx@linutronix.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-28 03:02, Zenghui Yu wrote: > On 2019/9/24 2:25, Marc Zyngier wrote: >> Just like for INVALL, GICv4.1 has grown a VPE-aware INVLPI register. >> Let's plumb it in and make use of the DirectLPI code in that case. >> Signed-off-by: Marc Zyngier >> --- >> drivers/irqchip/irq-gic-v3-its.c | 19 +++++++++++++++++-- >> include/linux/irqchip/arm-gic-v3.h | 1 + >> 2 files changed, 18 insertions(+), 2 deletions(-) >> diff --git a/drivers/irqchip/irq-gic-v3-its.c >> b/drivers/irqchip/irq-gic-v3-its.c >> index b791c9beddf2..34595a7fcccb 100644 >> --- a/drivers/irqchip/irq-gic-v3-its.c >> +++ b/drivers/irqchip/irq-gic-v3-its.c >> @@ -1200,13 +1200,27 @@ static void wait_for_syncr(void __iomem >> *rdbase) >> static void direct_lpi_inv(struct irq_data *d) >> { >> + struct its_vlpi_map *map = get_vlpi_map(d); >> struct its_collection *col; >> void __iomem *rdbase; >> + u64 val; >> + >> + if (map) { >> + struct its_device *its_dev = irq_data_get_irq_chip_data(d); >> + >> + WARN_ON(!is_v4_1(its_dev->its)); >> + >> + val = GICR_INVLPIR_V; >> + val |= FIELD_PREP(GICR_INVLPIR_VPEID, map->vpe->vpe_id); >> + val |= FIELD_PREP(GICR_INVLPIR_INTID, map->vintid); >> + } else { >> + val = d->hwirq; >> + } >> >> /* Target the redistributor this LPI is currently routed to */ >> col = irq_to_col(d); > > I think irq_to_col() may not work when GICv4.1 VLPIs are involved in. > > irq_to_col() gives us col_map[event] as the target redistributor, > but the correct one for VLPIs should be > vlpi_maps[event]->vpe->col_idx. > These two are not always pointing to the same physical RD. > For example, if guest issues a MOVI against a VLPI, we will update > the > corresponding vlpi_map->vpe and issue a VMOVI on ITS... but leave the > col_map[event] unchanged. > > col_map[event] usually describes the physical LPI's CPU affinity, but > when this physical LPI serves as something which the VLPI is backed > by, > we take really little care of it. Did I miss something here? You didn't miss anything, and this is indeed another pretty bad bug. The collection mapping is completely unused when the LPI becomes a VLPI, and it is only the vpe->col_id that matters (which gets updated on VMOVP). This shows that irq_to_col() is the wrong abstraction, and what we're interested is something that is more like 'irq to cpuid', allowing us to directly point to the right distributor. Please see the patch I just pushed[1], which does that. Thanks, M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/gic-v4.1-devel&id=aff363113eb26b6840136b69c2c7db2ea691db20 -- Jazz is not dead. It just smells funny...