Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448338yba; Mon, 15 Apr 2019 11:51:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt84vJNmbsRJe7nbKGtFmsE2xgHcpCf8/4UphXQSz4TuXDczVuUqf1tjAo+xllWJUZxXLN X-Received: by 2002:a65:6489:: with SMTP id e9mr71234081pgv.364.1555354286122; Mon, 15 Apr 2019 11:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354286; cv=none; d=google.com; s=arc-20160816; b=M2jjO1nbUOjrKvxNMCEqgKrquEzuWRxUe1s9tEs7AcMxYClifhyeOOJRUXRBTpVanl AJUkvadfzH4709FXRpHWIy6rGE7467NbHf9CiIPVFT3wZQONdXlgz87cnjQrGLUpd+uD CI6rx742Cv3sKT1WTsbglQw3pTs4gjjCckXyHRDaAOBq9ihdj0IFS/mWT0HbsV9SXYjZ NLGGzMYCD/QOu9ySU5pCxKeyi4Qy5vlM3FFziRVyXMx40YPlsK6YxmSY+GpHdtqfoYNJ CGSCZJ6wQHcgAAB9/hqIEHpMhqziVieubF9aXXJpc6qYhibhm47Qf1W7JwPj9eXaG9Nm KZDg== 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=3p3YbjTNRWgn80C6eX6OG2QvtsJKkygn6Qybvx/5Mkw=; b=c3poCb+FpPHGN+17KS+HmZEKduEwGP/IZHuLYlmALMzNAiAglz3ycty8Df+EgVQwkj 61cKwhIz4UWgXl/OzNTfZyfdRrxVP2XXQimU6nZptuM1VwH7G6h885fK9bJj3CaNR+B7 exclAGlXLJy2mwRIUmSPSJf3ievQeOn7LPx2gP748MbuR+ZQe5IkeqA2BaV9uXqqaePu fP5kH6P5StxjXVCSrv1DaVrS6TD8WHs/FkKCuXnQH3lUSi5F96n/pjOof7OmWyRSrfOb SQy+BOkzD6eh34GiGbdbT9Cl6cecnYDTxbw7JvamFeRjHsOVDpxxFZBRlybbgT2QgHVj mtcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwhyeQ8L; 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 n1si30660153pld.280.2019.04.15.11.51.10; Mon, 15 Apr 2019 11:51:26 -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=zwhyeQ8L; 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 S1729136AbfDOSty (ORCPT + 99 others); Mon, 15 Apr 2019 14:49:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728816AbfDOSrF (ORCPT ); Mon, 15 Apr 2019 14:47:05 -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 EBE5A218FE; Mon, 15 Apr 2019 18:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354024; bh=LsWhlKTZ57qXkctU6wKVmoIgK3TxtGKw5y8zlV7orIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwhyeQ8LAY/q7UqnadnHe6p5L+PHK5OPPDbHRiYVlcDCfKhmvhf7nI67rfzqXmou7 x/ycoHIzxkoKM6p60UQpCFUYrHKXN/j67K10QFDEE0Pl/qroxv4MxIu76EkDTaIym6 lUKzp4sfe1lCJyPF++VRFaq1KDjubsgz6Pu7BIeI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Michael Neuling , Diana Craciun , Sasha Levin Subject: [PATCH 4.9 44/76] powerpc/security: Fix spectre_v2 reporting Date: Mon, 15 Apr 2019 20:44:08 +0200 Message-Id: <20190415183719.014987788@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 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: Sasha Levin --- arch/powerpc/kernel/security.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c index 43ce800e73bf..30542e833ebe 100644 --- a/arch/powerpc/kernel/security.c +++ b/arch/powerpc/kernel/security.c @@ -190,29 +190,22 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c 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 { -- 2.19.1