Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3964437img; Mon, 25 Mar 2019 23:40:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHMHP6PDCNWZSCWDkvi4y9b4CRGMHWVcsMobUoKgjiS8qiJAeFrCnZ3PbZJINa0KtuV/v9 X-Received: by 2002:a17:902:282b:: with SMTP id e40mr29273590plb.111.1553582416388; Mon, 25 Mar 2019 23:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582416; cv=none; d=google.com; s=arc-20160816; b=l+NCWXDABy2Vf3k0/IBUFgP6RyrK6Urbg2454pT9bu6frazLG7Ukq5wG1qd8ySLh20 nYFdKIr2Wy4q2ULrXudNzFuEn9R0UoKUICKaQNSus6qXdY9D4vlhxOh5o9Xd06XBxyih AophmB19Ax/eXQBTGKWXxo2jnJve8zhdpGJq3ip8ZaKt+72GqZ4+v+vejMtcm+/fP41R UGEd1MFAx1X3rKBykBdNx1UPZI1Ej6YY2smZJHMs/5wySOVwhjmRZ9cjmSDP6LLvSORX AxNRl1incbTUQNSpOzLUjui47cHud8gyLHZOw3nq5DW8cvU7kZzv/V0GiMMTXY0Dvlo3 d7gQ== 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=5OdMIZnsqmBkPUaL3kV9bpK4laJJGpx8DjQ4Z3UkWgo=; b=F85zP671JDiiiWlDkUYg5x5C7j8+xtXRkvM+exLv8aoN0+G36coDKGzbttlKjg2EJZ J7X++ifF44SoeSkidbYeBXhtmvRThxIq3c1fc6FOyx6Lxv4OBkuWhjx+IkZ36FdyR7YV n4raDUT/S+O1eoxh1zOfC2VnMWlfeGJzl3yB2zrIxX43Vg1czZ28gH51cobNm3NJCaI1 WtO+Z1drxyZx7RRwSsNNHSSxRXrRkH8XKu2VcmMxsMSgK0AJyULYp2uZFrP47RPH3nrP aOjjyLEiItKE6cP+TPh15cN4eus6k9XqXqyxSxi7/8iIJnupEJHJLraTQR33TINC8Oif VPwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gFdXdZ3l; 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 k1si15938807pls.208.2019.03.25.23.40.01; Mon, 25 Mar 2019 23:40:16 -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=gFdXdZ3l; 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 S1732632AbfCZGjD (ORCPT + 99 others); Tue, 26 Mar 2019 02:39:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732620AbfCZGjB (ORCPT ); Tue, 26 Mar 2019 02:39:01 -0400 Received: from localhost (unknown [104.132.152.111]) (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 5FE3520879; Tue, 26 Mar 2019 06:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582341; bh=e6i2jCMXun9qMo/nQ5cXNw/iQrVXnj9mi1DMu1Irfr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFdXdZ3lSoyxHIGn1weHf7nZn6uS9AeirUpdmSJ+cv7YekFq78njLnPvIDnG+VscN YS3jDu3Zf+/mryDtLftKoCvffESHBTJVJb35t0MY1S+VFssJ9aG61aYC/HfxfUE5+Y IqI8hcaawg4qQTX2P24wsIIzlBJyVK/O6qa4/XUA= 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 5.0 18/52] powerpc/security: Fix spectre_v2 reporting Date: Tue, 26 Mar 2019 15:30:05 +0900 Message-Id: <20190326042701.828130213@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042700.963224437@linuxfoundation.org> References: <20190326042700.963224437@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 5.0-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 @@ -190,29 +190,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 {