From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B0BDC433E1 for ; Fri, 17 Jul 2020 11:08:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31F7B2076A for ; Fri, 17 Jul 2020 11:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594984081; bh=wlEmND60T3ISX+955FSfwJ+sAtAP9IlDFmcnAiaB2s8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=Kdr58E9S9oipNRX0GUpggNHy5GN8yK/ifrFuM8ywghfPqLnmdeE9vSTrrBLfv/mGX 7ba/Nr/UPYQR6uh4WC1au8aInvNaeukAXhhbPRWsRfhCxQDnUP9+z1Ux+aTvJv1jko kFGCxucVxeAju28H2mDN7/2T5sJp5PSQXWlivdek= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbgGQLH7 (ORCPT ); Fri, 17 Jul 2020 07:07:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:58396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgGQLH7 (ORCPT ); Fri, 17 Jul 2020 07:07:59 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D37ED2070E; Fri, 17 Jul 2020 11:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594984079; bh=wlEmND60T3ISX+955FSfwJ+sAtAP9IlDFmcnAiaB2s8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CXKrgIrRSvPvUlBZer6b0UMHBY0fe7kSmEWHk1T9W8CSPTJRewS+aS/RRBXjW9Oof QQzPc/AtHoX/Ti52V8XVZqEFINXtzcmVhBS9yaB7UhZTHujm4OuqOIV6v0R9qkztRV eVzxGKKKBKAyZBlyvVFELiuy7UqGCIS7Houq0RA0= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwODd-00Cbez-AO; Fri, 17 Jul 2020 12:07:57 +0100 Date: Fri, 17 Jul 2020 12:07:56 +0100 Message-ID: <87h7u6xuur.wl-maz@kernel.org> From: Marc Zyngier To: Zenghui Yu Cc: , , , Subject: Re: [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR In-Reply-To: <20200709134959.1039-1-yuzenghui@huawei.com> References: <20200709134959.1039-1-yuzenghui@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: yuzenghui@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net, wanghaibin.wang@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.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 Thu, 09 Jul 2020 14:49:59 +0100, Zenghui Yu wrote: > > The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to issue a > register-based invalidation operation for a vPEID not mapped to that RD, > or another RD within the same CommonLPIAff group. > > To follow this rule, commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual > exclusion between vPE affinity change and RD access") tried to address the > race between the RD accesses and the vPE affinity change, but somehow > forgot to take GICR_INVALLR into account. Let's take the vpe_lock before > evaluating vpe->col_idx to fix it. > > Signed-off-by: Zenghui Yu Shouldn't this deserve a Fixes: tag? Thanks, M. > --- > drivers/irqchip/irq-gic-v3-its.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index da44bfa48bc2..50a04cca8207 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -4087,18 +4087,22 @@ static void its_vpe_4_1_deschedule(struct its_vpe *vpe, > static void its_vpe_4_1_invall(struct its_vpe *vpe) > { > void __iomem *rdbase; > + unsigned long flags; > u64 val; > + int cpu; > > val = GICR_INVALLR_V; > val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id); > > /* Target the redistributor this vPE is currently known on */ > - raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock); > - rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base; > + cpu = vpe_to_cpuid_lock(vpe, &flags); > + raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock); > + rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base; > gic_write_lpir(val, rdbase + GICR_INVALLR); > > wait_for_syncr(rdbase); > - raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock); > + raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock); > + vpe_to_cpuid_unlock(vpe, flags); > } > > static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info) > -- > 2.19.1 > > -- Without deviation from the norm, progress is not possible.