Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1146029imm; Wed, 1 Aug 2018 10:57:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQIQsfLS16BQTcfLD+Z2aeEWD1cKNHGCqb+rHtL01I5B9+1E/iOlbof/ZlTSDj/b5O95fG X-Received: by 2002:a63:3089:: with SMTP id w131-v6mr1798713pgw.79.1533146261355; Wed, 01 Aug 2018 10:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146261; cv=none; d=google.com; s=arc-20160816; b=yRvkMQnQHnT8KOvwo3tBj34XKpgn5oQm0WEn9oPVpd0/914M3EeFfZjFipEWrD0Zad Nemk5K+guuT06o08y2UNri87dxBE8Hsen24NazNN+Xu85RMQoQrut6ZBACv0ZMjQcHoP JjzU6q8qZss/UFk2sa94an9+59BGyRwtd/QOrO4BdTTfVWw4Nl+EIDyYV9J7Zjxo42Cj cQJ+uoBYJnWLXExexVe7Yq/SB+rWSqFZ3zFMbFg3VucVeeOTGTrONsvmYKgatKSXaBlF qINIQ6h8GEX/QvyOmQB+lB9DCew/z0VVxLO1oTpB9ALKSmjCHHFrWrI1oFj3VcKRIiHG ai6A== 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=ishi+7MLyq00RuBEy/ii/gKZbRUmuQxIy7wHdiPNzJw=; b=GbPK7/zXo3RX12t0BC5cD5ChjaMSd8Z+MSAZZLFPOiLo/dKw5V9FhXR/5tFCn/EvyZ MEfkz+6jqRO3K1lAQEK64ewA+JGXg1JC3OTnXY/qxmkkfjkf5nele8wnMEMy2v364qF6 h+jJgV/k/yF89NLBtXtr9CoYjQ5+60YLY9Ma5rrZ43BwBorj1Lo2ImziEnisGtNK7ysH txGGeNrVdnx/TgPE/Y8tZETzLlCRGEVNjp8DAkw5F0qzYOZtrvduaVWnKi4uNCS5J+Y5 78GgfzUmDdHYGX1W+mXbv+c704DiW9b6B8mjrrpmU1Bn/M2Zjnk5gvdexl280zcAJRZD RZfg== 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 3-v6si13654322plv.314.2018.08.01.10.57.26; Wed, 01 Aug 2018 10:57: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; 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 S1731070AbeHATmq (ORCPT + 99 others); Wed, 1 Aug 2018 15:42:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50216 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405947AbeHATIk (ORCPT ); Wed, 1 Aug 2018 15:08:40 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 887091377; Wed, 1 Aug 2018 17:13:55 +0000 (UTC) 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.14 047/246] powerpc/64s: Add barrier_nospec Date: Wed, 1 Aug 2018 18:49:17 +0200 Message-Id: <20180801165013.964277932@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michal Suchanek [ Upstream commit a6b3964ad71a61bb7c61d80a60bea7d42187b2eb ] 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 Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/barrier.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/arch/powerpc/include/asm/barrier.h +++ b/arch/powerpc/include/asm/barrier.h @@ -76,6 +76,21 @@ do { \ ___p1; \ }) +#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 */