Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2362734imm; Mon, 28 May 2018 06:45:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqW5iezKaXWVhE8OPkOuKPAqS1EldjcI16/8Ra3F1x2g5e61GxvLDMUdRiuWwlz4nDde7Jo X-Received: by 2002:a63:4384:: with SMTP id q126-v6mr10533825pga.294.1527515144171; Mon, 28 May 2018 06:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527515144; cv=none; d=google.com; s=arc-20160816; b=MfphmDoXAAgyiOELAsHrug8NpNYmHjP+xGSvMoKySf8AO8yKwEHDA/5Eu1DEA1ovTc 8E9jOqN6nkT96Qz7dbwTi0wzD8NLXvFHzvqjvyW83/z1NcLUMyR9EpbahYS0YmM4jWoZ UTZFABjnoSag0kQLd5pfohdi4NIl8dSKczJliisngIfk4aYA8TJZAU9CGXCRCnrnukOM JgtmXey9DeqSKub4QXuujHeOTNPrKgN/7638xY7HJii4ldl5v957AhJBBY2rOZ8Qml9f nQZY6j2itz9LVUSeTD/VTp+B53dJ+kgvz8p7pYeBIby62u04U/0n2CAma0OSFsKLml/e d9YQ== 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:dkim-signature :arc-authentication-results; bh=MTkJfEbczhFShuI8KIhboL6IP7N1Rkg6/vgKd3okxs4=; b=Mur8GkHzdPODexNmA40R5NLJPFuXS7jK52RU5OWTCA8t2/jRzlLsY7KsGqLmjwHudq cjWJqaJ/o73exxL4e547llmS6eIav9NBnoAlgDTE67zK5nrTCNfmn+M9MfwTfUdJZsLz xaQwthMWp+2dPCcxBoEwTcAiZ65zRiKiH4PLD6IRUCG1irMDIn9GKh4R4KLIwoQKiE0Y BVcvDte+LFqrfVSS7Td1jUc4fk2xpghm4nqf2EbKCVp2/t6TFwdmH6duXoRxTU/zKId3 oxukNbuZHBPITAkWwTTDnCx1BMXp3YXSRpDmBSFlL+YHV/otGgkhfFnV0UYMQ5HLp1Rp 3ILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ouQobfE5; 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 67-v6si8398832pge.373.2018.05.28.06.45.29; Mon, 28 May 2018 06:45:44 -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=ouQobfE5; 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 S937588AbeE1KnY (ORCPT + 99 others); Mon, 28 May 2018 06:43:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:34386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932439AbeE1KnS (ORCPT ); Mon, 28 May 2018 06:43:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 BCCB7204EE; Mon, 28 May 2018 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504198; bh=rDKSKTYaJOdK0WMILr7/GDEajfbbsRzkDdFy1a0TxXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ouQobfE5pFX9bQ4gGPxHkL8zyg9g6ZzgwRDtHNBf/6NU9/nxeD/lo8zZ8Mre45wg8 bOtQy0lcRRiE94/tZC0hC2t/Qo7j9ES+SX96pYyl4zHsjwYa6ztUWKpT5fBAQEYuTo 5QPyTrh2miK+Ex3n80tuaLsoPxD9/oBAEKV7jDt0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, greg@kroah.com Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman Subject: [PATCH 4.14 051/496] powerpc/64s: Wire up cpu_show_spectre_v2() Date: Mon, 28 May 2018 11:57:16 +0200 Message-Id: <20180528100321.915067075@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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: Michael Ellerman commit d6fbe1c55c55c6937cbea3531af7da84ab7473c3 upstream. Add a definition for cpu_show_spectre_v2() to override the generic version. This has several permuations, though in practice some may not occur we cater for any combination. The most verbose is: Mitigation: Indirect branch serialisation (kernel only), Indirect branch cache disabled, ori31 speculation barrier enabled We don't treat the ori31 speculation barrier as a mitigation on its own, because it has to be *used* by code in order to be a mitigation and we don't know if userspace is doing that. So if that's all we see we say: Vulnerable, ori31 speculation barrier enabled Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/security.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) --- a/arch/powerpc/kernel/security.c +++ b/arch/powerpc/kernel/security.c @@ -58,3 +58,36 @@ ssize_t cpu_show_spectre_v1(struct devic return sprintf(buf, "Vulnerable\n"); } + +ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, char *buf) +{ + bool bcs, ccd, ori; + struct seq_buf s; + + seq_buf_init(&s, buf, PAGE_SIZE - 1); + + bcs = security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED); + ccd = security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED); + ori = security_ftr_enabled(SEC_FTR_SPEC_BAR_ORI31); + + if (bcs || ccd) { + seq_buf_printf(&s, "Mitigation: "); + + if (bcs) + seq_buf_printf(&s, "Indirect branch serialisation (kernel only)"); + + if (bcs && ccd) + seq_buf_printf(&s, ", "); + + if (ccd) + seq_buf_printf(&s, "Indirect branch cache disabled"); + } else + seq_buf_printf(&s, "Vulnerable"); + + if (ori) + seq_buf_printf(&s, ", ori31 speculation barrier enabled"); + + seq_buf_printf(&s, "\n"); + + return s.len; +}