Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp486136yba; Mon, 1 Apr 2019 10:15:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAafQOeUEvOAiCpvld41MiJ3htih2+6RbnLRHMVybWH53xgo1r74Z/e4Hnx6ehBZUSCm75 X-Received: by 2002:a17:902:7481:: with SMTP id h1mr24371624pll.206.1554138914261; Mon, 01 Apr 2019 10:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554138914; cv=none; d=google.com; s=arc-20160816; b=Cf6/xF10i7SA+9L1JZGmtAu7PvNcA4Bm39Izigw8/jS2PEK5TJVkv65JtImY+lgvQr bi2V1lABwft/lmk9CXRdovBd6qObQpWSo9z37w7RABkLTMocrAcBc+xtr0TRquvZNJuA iA1VSUqutG0BvF1rvexEqOiPF6fpWA3eJoKxY1iXA1LCAwlzErELZ7arRaKblDD/lLNx ZbCmDBFPprgofGkvOUpc1tqC3ZPEwxC+o64/WnWL9GUApJvkSbMn/SsE61UtFm8+jR+7 w4XBFTdcmlK8cZ9hLBH4Vfm+IGa9YRhrP+mRSmXmBDjP5KIqkNdE7WCAN5FFXo5JSkky xQCA== 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=GUE1G5PtjPusAADM/fM9QYHWVn+WIY5M+2P//nEc1So=; b=oPo1NKTuUw/Zmgg92Q1w8CDSzB9cnADyeTOcFKWGyMBUlLrgJdF2ZImLizWyJg4+sr MhBTamAStHaP7sOWzq9ZJ9m6mDf00Z5cSg3h02QZGQWYxr9KAbJ/jiAb2AiwPsi+d2bX ynoH79irUk9RxZJ4nTVcV75q7kDGeXVqXtQwqvH4aOx5aUjElrf0FmkoMxo764z/kmKv cfccrkEpcvysiO2ofpt+Jb3Up74apk7lWBdIx+ck4C3p3EJRinjZ2+ZGilqfkwu4ZIQx AMeU44DPdIPy2W+jK4ci0If+uZ5R2nrV00DWekSaY1u+an/JH+hzVXs4FpFoUD+DgoCt 8uFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gp6qPZ2+; 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 v5si8962961plp.392.2019.04.01.10.14.58; Mon, 01 Apr 2019 10:15:14 -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=gp6qPZ2+; 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 S1730741AbfDARO0 (ORCPT + 99 others); Mon, 1 Apr 2019 13:14:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:37668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729057AbfDAROZ (ORCPT ); Mon, 1 Apr 2019 13:14:25 -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 35A7220883; Mon, 1 Apr 2019 17:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138864; bh=sMCTVvsTFapU2inGj55tEGgsAo2wS/AcB8E1TAqkiBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gp6qPZ2++PNZsoqnuhcmos2hqjphdT2yl3mIUZ7LoZ6nxFklfm8ACWUtaXjfomjlj e/3o8a0lzFavUncbyZ81rVw8ZOUjNiNk96oYn8u1S41p1dHEX7iAxqBk3gqCNUOQFu iAoXK4TvctEJ+T77vpY7xsxJJRG9TCe7h/154SSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Michael Neuling , Diana Craciun Subject: [PATCH 4.19 044/134] powerpc/security: Fix spectre_v2 reporting Date: Mon, 1 Apr 2019 19:01:20 +0200 Message-Id: <20190401170048.733217781@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170044.243719205@linuxfoundation.org> References: <20190401170044.243719205@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman commit 92edf8df0ff2ae86cc632eeca0e651fd8431d40d upstream. When I updated the spectre_v2 reporting to handle software count cache flush I got the logic wrong when there's no software count cache enabled at all. The result is that on systems with the software count cache flush disabled we print: Mitigation: Indirect branch cache disabled, Software count cache flush Which correctly indicates that the count cache is disabled, but incorrectly says the software count cache flush is enabled. The root of the problem is that we are trying to handle all combinations of options. But we know now that we only expect to see the software count cache flush enabled if the other options are false. So split the two cases, which simplifies the logic and fixes the bug. We were also missing a space before "(hardware accelerated)". The result is we see one of: Mitigation: Indirect branch serialisation (kernel only) Mitigation: Indirect branch cache disabled Mitigation: Software count cache flush Mitigation: Software count cache flush (hardware accelerated) Fixes: ee13cb249fab ("powerpc/64s: Add support for software count cache flush") Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Michael Ellerman Reviewed-by: Michael Neuling Reviewed-by: Diana Craciun Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/security.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) --- a/arch/powerpc/kernel/security.c +++ b/arch/powerpc/kernel/security.c @@ -189,29 +189,22 @@ ssize_t cpu_show_spectre_v2(struct devic bcs = security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED); ccd = security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED); - if (bcs || ccd || count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) { - bool comma = false; + if (bcs || ccd) { seq_buf_printf(&s, "Mitigation: "); - if (bcs) { + if (bcs) seq_buf_printf(&s, "Indirect branch serialisation (kernel only)"); - comma = true; - } - if (ccd) { - if (comma) - seq_buf_printf(&s, ", "); - seq_buf_printf(&s, "Indirect branch cache disabled"); - comma = true; - } - - if (comma) + if (bcs && ccd) seq_buf_printf(&s, ", "); - seq_buf_printf(&s, "Software count cache flush"); + if (ccd) + seq_buf_printf(&s, "Indirect branch cache disabled"); + } else if (count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) { + seq_buf_printf(&s, "Mitigation: Software count cache flush"); if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW) - seq_buf_printf(&s, "(hardware accelerated)"); + seq_buf_printf(&s, " (hardware accelerated)"); } else if (btb_flush_enabled) { seq_buf_printf(&s, "Mitigation: Branch predictor state flush"); } else {