Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1890265ybh; Fri, 17 Jul 2020 04:08:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylEGHRtkJXQ03VTrFivFpmdlXMN17q0UamHRzSMaguVtuS7DY+47Sn1epIapVCPdxk8QlZ X-Received: by 2002:aa7:df08:: with SMTP id c8mr8474616edy.372.1594984126080; Fri, 17 Jul 2020 04:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594984126; cv=none; d=google.com; s=arc-20160816; b=OTvgRel2qECX+4yjeXZo4aJnKSgNutN8WxcfYj4zGNcM4FWsRcyR7+oPzY/0KXnaA+ GbPJ7iOXT85yF3d7CFhlMP3RElfliymwNY6iGkf7PYx3XaaDVCFCfkaGQWfukkhDJcTA WqXdkJnoL6WOmTxQEclEh2WGlTKfxlLiz6zIyGML9FnXwojjyrWJOpTFMHqN5b3+DaxU 88gIUug/EY8TaYXtXk1Fcnf5sNUciGlskEMrAAl2885AY4qDt4A//qw76zavCGsY7i4E CF9NfcssobZ3BlaUjzPGD0WuMW8Ov4FN968mxKlPuZfIw/aJoKaNrE3oqtimBl+OoCnA RqaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date:dkim-signature; bh=P6eXfucAGNw03e/TNI146gE3e/tenvaO6jJ/jmk0OcU=; b=STc6oxWnd8YwxpLS+/cX+gB0gO8Sd1xsEy/FvNDmcCg9ZLJba7yB/qe1Id5LWUHNBR 5jZbamXk+fCzATn7io8Pblz7co8COpMyWXyMVpaXuez59wTJafAgpOnIBRrL8JsFCu9e JkGWdrAOBAa5y2yGFYyx2ZtRk89lGBXzUefbzzUcCRkPiAtb/nO/pLrcq+zmlWlqS5g5 3uPDRSGdFyj8gW2m+lKNVkvC58MlMCffj1Blv2E5y+kOBIxATGUfmUeI0x7MVgZfodko aFMyUGzMvpI+hkfRnFMeQpI5IYIsAYZK5ZDF8eRG5zxCLOpksMzC/5nR89GhqYQmb/Wa 74aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CXKrgIrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si5039359ejj.461.2020.07.17.04.08.23; Fri, 17 Jul 2020 04:08:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CXKrgIrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbgGQLH7 (ORCPT + 99 others); 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.