Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1955361imm; Thu, 24 May 2018 03:33:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFTysBFZgF33NW5Grd9nQU2We4Z83IEiz4lPcrTloTd5/InNT/y/rXL6KBhol1DzgLFMYA X-Received: by 2002:a17:902:82cc:: with SMTP id u12-v6mr2887506plz.83.1527158021714; Thu, 24 May 2018 03:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158021; cv=none; d=google.com; s=arc-20160816; b=Bk9E4ljW3vVYxmdsOBbSAnx4xQm99wluNyF1h2JKrT6rFTOVvG3qI8lhs7mKWcj+YD li8LqcFaFM0PDfPENltP9/YcmqoDGJSg9ImDXSCCtTUHEZGwgpvnI/lsmUYT9lGAnSRi u2rI4QkQOVieBEAbeoDHwtD7KCLa2R0rLGPesuygQO1TFS11v/zDlejNL0SXWZY97dct 0EBCC/EmWqEV2XpuqwT8gTj0A1qrd2e+tx2XG5jZv3DQy9pfHqkQMrVJ9vFD3J7xJyA+ AJH9x0aHC462WBoWa47C9AYJD3I/pBlP8ZasBUhrvApEfdDlgmH6v73ZgYMz7jTskheX yicA== 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=kg4v8WQ0Dtg4Mm6WpBvv8rVRtTqncdT6FG416/YN3O0=; b=CHki/lIQ32BIKkNf8o+9pCE2AabqBflcuibSzBfSLpjmkYZ4KRkYjWH7pW+tjkulKi YG+y+Cx2s7N2DWJHgQGDk8h0bJbBSTveWSG+UbwRoD1+A38ZFrBsAcHqRmzGpBu8P2wf oFRJO8NPPcOfal3hO8im9vxn24GcQ1L6nW4DlhRx6cttkv7+y7yg7D9ZsuhGwGFPewfv DdnZjT+CPXEX6AS2isvmEqDIuSAN4byvdCrwIKcm74rDcEs0cWlL/vcdpHQ/RrNbWM6c SbEp+Fe6ajE4HSPSE/SgBh91O9uNZAL6Hec359IyeV40Qbr8xfTWpyMcGYtZacd3IFkD /QDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PWa68u2D; 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-v6si797541pge.373.2018.05.24.03.33.26; Thu, 24 May 2018 03:33: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=PWa68u2D; 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 S1032114AbeEXKcc (ORCPT + 99 others); Thu, 24 May 2018 06:32:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:44286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968490AbeEXKAu (ORCPT ); Thu, 24 May 2018 06:00:50 -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 A56952088E; Thu, 24 May 2018 10:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156050; bh=K886bIENC+r++504IElcXjYm3J8DwtPymEJhqXY/Za4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWa68u2D5jpTibDxnyj7+6U16hD34gosUs9oP3+8tGxN9FDhHoxDCmQRoPUSiFzJ/ Q2j3l5nojAzQTvnsro6rfExptW8D+3dyvOuJO2zNX1jiKVBdApYPR9nw5Ok5EYY/AP TIBezhCvPvrY7hieQdRncceR8DeJIlAeqxyvBQ9I= 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.16 045/161] powerpc/64s: Wire up cpu_show_spectre_v2() Date: Thu, 24 May 2018 11:37:50 +0200 Message-Id: <20180524093023.761898151@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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: 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; +}