Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097226ybl; Thu, 30 Jan 2020 11:18:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxhytKtLCbb+G2NYeq1g8CK96UgXO8+VhPeirPsFj82wjCNicGmmSrKcG31nXeUh2ATd+u1 X-Received: by 2002:aca:1204:: with SMTP id 4mr3913691ois.143.1580411900237; Thu, 30 Jan 2020 11:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411900; cv=none; d=google.com; s=arc-20160816; b=TzizpmA4AIFhqUemPnxt225RZdbRguE9ha5b7Ti9L9LFbjW8s1qbUZSET2O1NYDWbx SwDsQrF01GdZx29dJlMcbSJwUQM3BoajQb166OP7niFwtvjF/jv9otm56+NOuAya+SU+ y4UMng08kdiPCdSwM/vqUNQXPD+nLD4womkh+yOQt08D9YjPK32GTjLpX3xteLePdyiH DQss2tHNXdS1idRJtNGwMW7Ak8O7ffZoPPeUJQIWbaLDIq6sY+ceaRxDKXdyQQFq3kUW GlQNyu+kn87zEEIj3HsMM1Hqt7V4bcy3TYaiPoL1lJzgZULplgu47jxzFAf//tKm88JV limg== 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=Vf7bso0CQXsAT5N1aQQB9BppTDc2pn/H2EWW2NUqCvs=; b=zTW0g36IpUCpB3ZwIVqVET7oCoEOiOWI/cYIi14ZhdWtW42p2QmdpoK4hJQmw+v5hM OyE7wuCaLHD2g1UWCNCDUtp3fTbQfbYgjcLwfryso96hRAI55EwUllHAWpavM6Ag1lSU ADfl+ijmZLPYSZ3EPift0+1HYHXuGh/ZYlpXGvkJ8HUFjK4r4UxHrO+z54yX72qYnoVn r2mUta2NHZidZ16zlLXn+B6ybANr8h3ITMcwqIMQ55t+F8q9hmB1W5zVGh3zUkp0c+bM N0o86NEkZ/Wr+PUh6tEIYaVrunlHOLwnvMzfgIStsLaCdchIdiQJn7+r70fBW2m5xH+2 NgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N+Plv1Ek; 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 a4si3362288otq.98.2020.01.30.11.18.08; Thu, 30 Jan 2020 11:18:20 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=N+Plv1Ek; 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 S1730854AbgA3Soi (ORCPT + 99 others); Thu, 30 Jan 2020 13:44:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:53724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730840AbgA3Soc (ORCPT ); Thu, 30 Jan 2020 13:44:32 -0500 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 187DB21734; Thu, 30 Jan 2020 18:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409871; bh=8OuebgqwLV2pZs9r42PHayOw/w5zaMYEWWmMvxUg8HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+Plv1Ekx4CPQy3dWcwe7eJVnUx9/ywa0AB8e1uEAOpvoc2Ht1k9HB+Em3GtlmldE qI1sktvZLtxyQgW/NiwFMC73wR65UAu6Bao7KfYfYJ2Q2c4Mf/7b7zhIR8wJqH2E3A PnAnrqKzPRhHewiiRNct5TzeONgGq+8j7vCscMCM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Fenghua Yu , Tony Luck , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 067/110] drivers/net/b44: Change to non-atomic bit operations on pwol_mask Date: Thu, 30 Jan 2020 19:38:43 +0100 Message-Id: <20200130183622.595145543@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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: Fenghua Yu [ Upstream commit f11421ba4af706cb4f5703de34fa77fba8472776 ] Atomic operations that span cache lines are super-expensive on x86 (not just to the current processor, but also to other processes as all memory operations are blocked until the operation completes). Upcoming x86 processors have a switch to cause such operations to generate a #AC trap. It is expected that some real time systems will enable this mode in BIOS. In preparation for this, it is necessary to fix code that may execute atomic instructions with operands that cross cachelines because the #AC trap will crash the kernel. Since "pwol_mask" is local and never exposed to concurrency, there is no need to set bits in pwol_mask using atomic operations. Directly operate on the byte which contains the bit instead of using __set_bit() to avoid any big endian concern due to type cast to unsigned long in __set_bit(). Suggested-by: Peter Zijlstra Signed-off-by: Fenghua Yu Signed-off-by: Tony Luck Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/b44.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c index 97ab0dd255522..1a7710c399d74 100644 --- a/drivers/net/ethernet/broadcom/b44.c +++ b/drivers/net/ethernet/broadcom/b44.c @@ -1519,8 +1519,10 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset) int ethaddr_bytes = ETH_ALEN; memset(ppattern + offset, 0xff, magicsync); - for (j = 0; j < magicsync; j++) - set_bit(len++, (unsigned long *) pmask); + for (j = 0; j < magicsync; j++) { + pmask[len >> 3] |= BIT(len & 7); + len++; + } for (j = 0; j < B44_MAX_PATTERNS; j++) { if ((B44_PATTERN_SIZE - len) >= ETH_ALEN) @@ -1532,7 +1534,8 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset) for (k = 0; k< ethaddr_bytes; k++) { ppattern[offset + magicsync + (j * ETH_ALEN) + k] = macaddr[k]; - set_bit(len++, (unsigned long *) pmask); + pmask[len >> 3] |= BIT(len & 7); + len++; } } return len - 1; -- 2.20.1