Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1261992pxa; Thu, 20 Aug 2020 07:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNsMhCxsyTPPNlfrYYMk4xVVot3MDJ9zJewZY1jl5hRc9wbHhzX4N4gbsnROviteQJcCfo X-Received: by 2002:a17:906:2987:: with SMTP id x7mr1422969eje.358.1597932173425; Thu, 20 Aug 2020 07:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597932173; cv=none; d=google.com; s=arc-20160816; b=sDJsTrWT2HQiUCu51SC6hauyqNTsoq4X9ZdRnSur0wDXN3ftSk4mWwls70BaKWg+Wx 2HOJ5sRPbxp3xDJNgLlhq5iaXPWmFeqExmCNfADiFdF0pmS2tglHX7y5BHrUC30rmIj5 uZEey9i3TEFwhXRGM04T+jCEmdLbbGFLzUHxT1EvQKvDuNKwVZe0+O7juf/a4dAOOHXS xzTIRXSC07vs6ysE2nB7SNUHRHpGXTVTyJ2LbsuSvrffBM6iaTW3fY6lsUVRU9rz+UBs Ts4eYjxn3pqUIrpUDKheEi2lyXExitQTok48spSu+5oi6ZpLqjVmdqv6kMmMyX7niH3C o1cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s3Y5xYymYpM2sKFJJm5caBLGeS60SfkCTaO+d7VlSew=; b=U/RvbdoEMe2eMcVMrw5VFwMDCC1dGl7aVyjCGyWWSSiCPTMgyM5GidorAkaB4psieS XW8UrZdT50WjOsgp1jtrO/HR88mQ0Q+FE3N3/YcHDQUW8etWiIt/yHr1mo8VVMXWQz0/ 5RraS+xy6iHOg8zKBm/9LdFOzqDLhnGCfEP9/Pz7GR47R5vEkev5MtGPslp4cOZlBR65 wnT/LhTmHAsZKIEluXP+5PbneMe/X3BInTda7THm0eqM13t7/Fz8qdMaI9mefahOyG7j HmCSZrvcHYoZhicGXhdFkdCiiqHTJoceeC1+192S1Xx4kzjTyjthTV7zQHSYOQt4RwLe K/tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V84LmdLo; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si1390131edy.309.2020.08.20.07.02.28; Thu, 20 Aug 2020 07:02:53 -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=V84LmdLo; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbgHTN77 (ORCPT + 99 others); Thu, 20 Aug 2020 09:59:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:33422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727895AbgHTJ0c (ORCPT ); Thu, 20 Aug 2020 05:26:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7252122B4B; Thu, 20 Aug 2020 09:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915592; bh=4TN8b/w1O6wpn+41nQXj3b70jxrH9CAppsWwXRewTgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V84LmdLo+jFUDcKecDrODRGUTrynLJgP/FxCSdanQrYg/D1x+ifhadlnjuFuByCCM 91YuUd4NF9yrBN+P+L+7muTiqc5td+AuMwbrRZ4JO+wMzeQTFGWfAfeEK0V+8/Y7Dk lfp/18Ngoykfv9stSRcp3xQkF6h9wlufmLAenN5s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zenghui Yu , Marc Zyngier Subject: [PATCH 5.8 060/232] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR Date: Thu, 20 Aug 2020 11:18:31 +0200 Message-Id: <20200820091615.701346985@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zenghui Yu commit 3af9571cd585efafc2facbd8dbd407317ff898cf upstream. 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. Fixes: f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between vPE affinity change and RD access") Signed-off-by: Zenghui Yu Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200720092328.708-1-yuzenghui@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-gic-v3-its.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4090,18 +4090,22 @@ static void its_vpe_4_1_deschedule(struc 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)