From patchwork Tue Nov 27 09:28:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1003687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 433z3h5QGBz9s29; Tue, 27 Nov 2018 20:28:16 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gRZfA-0000v8-8U; Tue, 27 Nov 2018 09:28:12 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gRZf9-0000v2-E3 for kernel-team@lists.ubuntu.com; Tue, 27 Nov 2018 09:28:11 +0000 Received: from mail-ed1-f71.google.com ([209.85.208.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gRZf9-0001wu-6J for kernel-team@lists.ubuntu.com; Tue, 27 Nov 2018 09:28:11 +0000 Received: by mail-ed1-f71.google.com with SMTP id x15so10554524edd.2 for ; Tue, 27 Nov 2018 01:28:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZkowNO6XkF6WjSE6fEuSwy09hZA949uGi8wE2ti3uIs=; b=oNt5VDcA+Gm+ydPkqA/ZwCKwX4AayWig6hYNt3t5gajvtIAm2dQ/C1x63tvAtxwJHS 0yYGQ/CYtLBnn91Xbpbrax425gPLIheW+OdGlt8CB5WOd0+SQXmlG8jiWSpm2Ut+Gv7H HFsTlJhEVa/0Tk93jhdhIEehvu6QlaWE4GxOwkWtbitoArMgaffUbKXnRDLm08KqOr0n eK+lGrstSybRK0V2Qfw0I+7Q0H1V1Zho0VlHniajHdJ5qxgvvOSY1kFVO4k6lmxUAa6X 1IfkpiKKoi7SQ8xQTp/Z45ffLGn8f3/J8uCHeoM+HCJTKeeEV9w9wmvk+yr1hzfAjSsJ NowA== X-Gm-Message-State: AA+aEWapHi4JMkbH0/uOzINtFSJkzmsAzpVNTFYX5s6gu98v+KRwsMkK r69xPS7c591OEKFWp7ZOlCRKAZj51mLvQpVapkgWxB34LDP5w8EXrmkNyV1ga6XZ9KPg/DtRfiF lCNgMFK0tWTdQxGdp3AwQiDBrBWYsyILuGZ01hnoQPg== X-Received: by 2002:a50:9f83:: with SMTP id c3mr26672173edf.33.1543310890543; Tue, 27 Nov 2018 01:28:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoZH1tf0Xl7el/AK1m1fKt+/e12v028/NnU3sdrxLaQsd9TGkv4TjLnbT+eUiGcZrhEnUHjA== X-Received: by 2002:a50:9f83:: with SMTP id c3mr26672160edf.33.1543310890283; Tue, 27 Nov 2018 01:28:10 -0800 (PST) Received: from localhost.localdomain ([81.221.192.120]) by smtp.gmail.com with ESMTPSA id g37sm839494edb.85.2018.11.27.01.28.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 01:28:09 -0800 (PST) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Trusty][PATCH] UBUNTU: SAUCE: x86/speculation: Only report IBPB/IBRS state changes Date: Tue, 27 Nov 2018 10:28:08 +0100 Message-Id: <20181127092808.27462-1-juergh@canonical.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121173113.13474-1-juergh@canonical.com> References: <20181121173113.13474-1-juergh@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: juergh@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Only print the IBPB/IBRS state to the log if it actually changes. Otherwise the log is polluted everytime the procfs file is read from. Signed-off-by: Juerg Haefliger Acked-by: Colin Ian King --- kernel/sysctl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 60e96b6e809d..a9380bfdc647 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -210,15 +210,17 @@ static unsigned int __ibpb_enabled = 0; /* procfs shadow variable */ int set_ibpb_enabled(unsigned int val) { int error = 0; + unsigned int prev = ibpb_enabled; mutex_lock(&spec_ctrl_mutex); /* Only enable IBPB if the CPU supports it */ if (boot_cpu_has(X86_FEATURE_IBPB)) { ibpb_enabled = val; - pr_info("Spectre V2 : Spectre v2 mitigation: %s Indirect " - "Branch Prediction Barrier\n", - ibpb_enabled ? "Enabling" : "Disabling"); + if (ibpb_enabled != prev) + pr_info("Spectre V2 : Spectre v2 mitigation: %s " + "Indirect Branch Prediction Barrier\n", + ibpb_enabled ? "Enabling" : "Disabling"); } else { ibpb_enabled = 0; if (val) { @@ -257,16 +259,18 @@ int set_ibrs_enabled(unsigned int val) { int error = 0; unsigned int cpu; + unsigned int prev = ibrs_enabled; mutex_lock(&spec_ctrl_mutex); /* Only enable/disable IBRS if the CPU supports it */ if (boot_cpu_has(X86_FEATURE_IBRS)) { ibrs_enabled = val; - pr_info("Spectre V2 : Spectre v2 mitigation: %s Indirect " - "Branch Restricted Speculation%s\n", - ibrs_enabled ? "Enabling" : "Disabling", - ibrs_enabled == 2 ? " (user space)" : ""); + if (ibrs_enabled != prev) + pr_info("Spectre V2 : Spectre v2 mitigation: %s " + "Indirect Branch Restricted Speculation%s\n", + ibrs_enabled ? "Enabling" : "Disabling", + ibrs_enabled == 2 ? " (user space)" : ""); if (ibrs_enabled == 0) { /* Always disable IBRS */