Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2520302yba; Mon, 15 Apr 2019 13:27:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8Q2kgHzuFQaBb1qTw12JR3Fjo2enN1Ux+OCPDI3PDGdldEhN2keu+qS1zgSYQA4ChMHow X-Received: by 2002:aa7:818a:: with SMTP id g10mr75579513pfi.178.1555360061559; Mon, 15 Apr 2019 13:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555360061; cv=none; d=google.com; s=arc-20160816; b=QYxDeWZ67xoduEleBTmX6nJRJ+FVuQtjV63hbFgneOYyjfvaPtq+7HZCUDXIR3UxLp 1ofpfDQJffGFtad4F+wJFTntZILOGfHs2wGAkmV5gOo/Nd20gLAnXAM18oR+4Nk6URJh pFoeDIHaRnAZcntczfPBzc2SqvnGnl1xcdYXXw2T+xTQLG2780D5A9Cv0bYegwmwtopX MXO/YFExprXNsLGVd/DqTUG5dLThVwbb8Qg6RrficX//wXkBJAuvx8+s1zs4n+4nmiDl 2SQIBZNcRaHjOHRouS3q6ut3mf/bGspzWdnEDu3UVZ6lw3QKIkapAEQIxHuT8yLIxE2Y ZAfA== 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=MBpjtvSsUjcYoqz4iSJd3ecKoiiYwjPzR8XftJulTTA=; b=tvTjbOr9xsAb19FnIxOdUAR+yk2+sUt5R8N2EENaJva44BYiHGnTIcBNxNLNkGtiyp rvXYn4ge4WG7Jl9VHba2WNUkuH+Dk6Qv0YdTUX7pWqQCWZrRX7GrppADTl2AhIgcTsev 70Nz5XqGRJ+OP0BUBjAf1TCqwDp/LbvtVOM11wpPj2q06wrJkzRYkNPLmPg0flsOezNY Wc9tGyk0E10bX+slmIT03kG7em+9BIKfN3JfIlk2PfqB6SJKgXT59saL7ihmEsMBFySX GV2WrLhekR54kZpfN9mk51YpepnB4P7ShnwqIkkOdQnAnrikPPnplnTrcv2rdgJi426W UMQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IlvgevrC; 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 b16si42147907pgb.501.2019.04.15.13.27.25; Mon, 15 Apr 2019 13:27:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=IlvgevrC; 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 S1728428AbfDOSpl (ORCPT + 99 others); Mon, 15 Apr 2019 14:45:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbfDOSpi (ORCPT ); Mon, 15 Apr 2019 14:45:38 -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 DF2022073F; Mon, 15 Apr 2019 18:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555353937; bh=mNhIKaxM/xSuPTzdI6LQDBw0ScqlJ3Eo65HcxlsQcfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IlvgevrC99y7K+PfSHwOJ11grcL6C+eW7Bv19PWsCJnZfiX0d7z0ceMDpQc8pnRM1 SBoX15vScxggeu3q0gigRyDRPG9vuYugPRgSTrefvIHKAfFe1OYVXGc/l/iynJifh1 1HLO87BNcs4LwPGvkG6vflwbBoDan2eBvXBHnh44= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Suchanek , Michael Ellerman , Sasha Levin Subject: [PATCH 4.9 11/76] powerpc/64s: Add barrier_nospec Date: Mon, 15 Apr 2019 20:43:35 +0200 Message-Id: <20190415183711.099200937@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@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 commit a6b3964ad71a61bb7c61d80a60bea7d42187b2eb upstream. A no-op form of ori (or immediate of 0 into r31 and the result stored in r31) has been re-tasked as a speculation barrier. The instruction only acts as a barrier on newer machines with appropriate firmware support. On older CPUs it remains a harmless no-op. Implement barrier_nospec using this instruction. mpe: The semantics of the instruction are believed to be that it prevents execution of subsequent instructions until preceding branches have been fully resolved and are no longer executing speculatively. There is no further documentation available at this time. Signed-off-by: Michal Suchanek Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/barrier.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h index 798ab37c9930..352ea3e3cc05 100644 --- a/arch/powerpc/include/asm/barrier.h +++ b/arch/powerpc/include/asm/barrier.h @@ -77,6 +77,21 @@ do { \ #define smp_mb__before_spinlock() smp_mb() +#ifdef CONFIG_PPC_BOOK3S_64 +/* + * Prevent execution of subsequent instructions until preceding branches have + * been fully resolved and are no longer executing speculatively. + */ +#define barrier_nospec_asm ori 31,31,0 + +// This also acts as a compiler barrier due to the memory clobber. +#define barrier_nospec() asm (stringify_in_c(barrier_nospec_asm) ::: "memory") + +#else /* !CONFIG_PPC_BOOK3S_64 */ +#define barrier_nospec_asm +#define barrier_nospec() +#endif + #include #endif /* _ASM_POWERPC_BARRIER_H */ -- 2.19.1