Received: by 10.192.165.148 with SMTP id m20csp2536933imm; Sun, 22 Apr 2018 09:05:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/11UCZ1WIBRJBi6rmGM4mi/xP13JDQ7rkVC80GVvepsatB+FzUN8mK2aqfiUVXm9ygY7U4 X-Received: by 2002:a17:902:b283:: with SMTP id u3-v6mr17893673plr.263.1524413126345; Sun, 22 Apr 2018 09:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413126; cv=none; d=google.com; s=arc-20160816; b=g+dP6cF2Eq7YhwRoCh9IlJnULQdwWekqvgNz+lP1VlLiiGN/yS7wXOEu4klgh10wlP /n5CAPPjWKGFjkmQxdAhi320Ki9qqLxDheqkAFnoC24xsgC58c+PoVYab49/WV2kCicF hBwZm2c8WbXd/DdIululhfyjluG26omjhcWQXJwPHqSGlhSqvNidxjdpjrPrNhy98TMY 77TWpk405cD6Ztn1x+LyouYPGNGxZc6Qoz1AtFYqt7BaLAiw8Dakm0CMKYg0MBESaAsN B9J+V3CH2xFTjdUnTm4di/VnloxbiZZa1gYmg12AssdO3lP3EZGro7OTbi8k9FeqDnQS /+BQ== 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:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I7s8WqU8ilWuLlcI3mAh0HFYT/elPvhT0LB4Jkv7gyg=; b=iwxVvmMSryKYz48tS41vHkCEKGYZlh0KGUP41kMVj8h2eTrJE6Z/Eyab7dVHvfr1hJ kYBHKoMrFoq9oqZJDcX9do6X6WzqPc/iHv9OKNKK1CIQLMievNIryLJsJvc2cEDlkPRl Mk2Nk9QL2m04ybb2pjTEx4xFhT8JFJE6OYZmO9nl/Pdn0JKy3EALp0JRzNIW+C1gkEVs VM+QnjgF+9h2EAoPZdJv7BRVJ0y6F6FbJOznAPsffTyVLXJL+KBDgDjEs+pdwQv4oj+h auoo1HgZFa9aITuQLXoCzwU2eCnTNOA2insbNOZ7wO5dO9Gz6v2f3EmEUK4R4kihZjfy NriA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si8523250pgo.310.2018.04.22.09.05.12; Sun, 22 Apr 2018 09:05:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754077AbeDVN6D (ORCPT + 99 others); Sun, 22 Apr 2018 09:58:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46012 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbeDVN56 (ORCPT ); Sun, 22 Apr 2018 09:57:58 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9C30FCD8; Sun, 22 Apr 2018 13:57:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aniruddha Banerjee , Marc Zyngier Subject: [PATCH 4.16 080/196] irqchip/gic: Take lock when updating irq type Date: Sun, 22 Apr 2018 15:51:40 +0200 Message-Id: <20180422135108.454224384@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aniruddha Banerjee commit aa08192a254d362a4d5317647a81de6996961aef upstream. Most MMIO GIC register accesses use a 1-hot bit scheme that avoids requiring any form of locking. This isn't true for the GICD_ICFGRn registers, which require a RMW sequence. Unfortunately, we seem to be missing a lock for these particular accesses, which could result in a race condition if changing the trigger type on any two interrupts within the same set of 16 interrupts (and thus controlled by the same CFGR register). Introduce a private lock in the GIC common comde for this particular case, making it cover both GIC implementations in one go. Cc: stable@vger.kernel.org Signed-off-by: Aniruddha Banerjee [maz: updated changelog] Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-gic-common.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/irqchip/irq-gic-common.c +++ b/drivers/irqchip/irq-gic-common.c @@ -21,6 +21,8 @@ #include "irq-gic-common.h" +static DEFINE_RAW_SPINLOCK(irq_controller_lock); + static const struct gic_kvm_info *gic_kvm_info; const struct gic_kvm_info *gic_get_kvm_info(void) @@ -53,11 +55,13 @@ int gic_configure_irq(unsigned int irq, u32 confoff = (irq / 16) * 4; u32 val, oldval; int ret = 0; + unsigned long flags; /* * Read current configuration register, and insert the config * for "irq", depending on "type". */ + raw_spin_lock_irqsave(&irq_controller_lock, flags); val = oldval = readl_relaxed(base + GIC_DIST_CONFIG + confoff); if (type & IRQ_TYPE_LEVEL_MASK) val &= ~confmask; @@ -65,8 +69,10 @@ int gic_configure_irq(unsigned int irq, val |= confmask; /* If the current configuration is the same, then we are done */ - if (val == oldval) + if (val == oldval) { + raw_spin_unlock_irqrestore(&irq_controller_lock, flags); return 0; + } /* * Write back the new configuration, and possibly re-enable @@ -84,6 +90,7 @@ int gic_configure_irq(unsigned int irq, pr_warn("GIC: PPI%d is secure or misconfigured\n", irq - 16); } + raw_spin_unlock_irqrestore(&irq_controller_lock, flags); if (sync_access) sync_access();