Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1737057iog; Tue, 14 Jun 2022 12:07:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1td952ZHe2EA048n6vqcwPYlimOV68joH1VKUdLC3QpxUB+fHS4l+J3J+NsTuJ7g8FJAMkw X-Received: by 2002:a17:906:d84:b0:715:7f3d:403f with SMTP id m4-20020a1709060d8400b007157f3d403fmr5714553eji.406.1655233668850; Tue, 14 Jun 2022 12:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655233668; cv=none; d=google.com; s=arc-20160816; b=zu82D4HpXpiS6LGfxXlrdkRxy2DbdxpfPaMYAwTDiow155t7Zn27h/WlDs/WRUgAVa ZcEpMta4QQktWl3uQJ+lfNnGejNDNW+6GZJwbiNGBHI7tpMYSdnSQx6fcaTm2VugRjvp dIINhi0DiQQzV1UySg1R9N9vug7kosg/1y80lJ/F2IWR2maz6PTt8hBTkEps8QPA+znp 5NaG4Q27pYl+XipSu2zTDMtOmxl5+7dU3v6PIa6vULkxQvLNlMbS/an9p0RVRtChY/Dl mNYeTIi8Pd+n2bEhWwpVUPklUeT71Uvqp5eZF/pfYUE17kkJ6frGYCjFbwyF6U7L8vcV vOBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cj4xH/8mnj7WtmRQAw3vk0DXwyOuozOXXxmzqjEf6oc=; b=pGeCFHrhCH8hjAAJabvIsJN7Hz+1zgIlcu7v2ZNz6q8kOv91UNwhnRFENXiiOmvI3N 4V3NTFFxYoPytrJMofyRdlSmvMf3FFfMveZjBQdCeEvqOfUYmmi/h8Wk72AiGvQ7DhTA XWr5/kVTEh+O1rNOfwrNkCfYn/amSU+DBBiua5fv/A4IixdsoVKHp9WBcwlNFtzfcIA/ gIWVq2QSiGaV5L26eYcVHPP5p/plLo0IrxqawcdpNcrCu5kRxIgd933CuaUOr6BwXdGR fSajSYM0cW6cC76jIBZtoYVc9d6VWS2JuPk2VNik0tL6cwNTg7rIsCacflyNZ5bJt/z4 ZV7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VJzB2MLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p21-20020a17090664d500b006e874b9da7fsi12100169ejn.28.2022.06.14.12.07.22; Tue, 14 Jun 2022 12:07:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VJzB2MLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357078AbiFNSlu (ORCPT + 99 others); Tue, 14 Jun 2022 14:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356667AbiFNSlY (ORCPT ); Tue, 14 Jun 2022 14:41:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DADCE49931; Tue, 14 Jun 2022 11:41:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 89D58B81AEF; Tue, 14 Jun 2022 18:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCB18C3411B; Tue, 14 Jun 2022 18:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655232078; bh=UmU3JoSkg88coxgK7WiDNTTgKhSETF29YA42o0WaihU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJzB2MLrg4bm6S3yB21JURHsFpTpJoDJTTVBII4vVFkafYS/1cmAKXjEJ9grTnCBv tz/K0O9xIAYiCj1pH8vwEgs3k/4PsvJ93eBF1km66Me4glBW7FDq2AvFPYESBrSB0F OZM++IbKDypu2vB1rzZ4kVV46NcNcyTNMmH7l3UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pawan Gupta , Borislav Petkov , Thomas Gleixner , Thadeu Lima de Souza Cascardo Subject: [PATCH 4.9 16/20] x86/speculation/mmio: Add sysfs reporting for Processor MMIO Stale Data Date: Tue, 14 Jun 2022 20:39:59 +0200 Message-Id: <20220614183725.921690236@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220614183722.061550591@linuxfoundation.org> References: <20220614183722.061550591@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawan Gupta commit 8d50cdf8b8341770bc6367bce40c0c1bb0e1d5b3 upstream Add the sysfs reporting file for Processor MMIO Stale Data vulnerability. It exposes the vulnerability and mitigation state similar to the existing files for the other hardware vulnerabilities. Signed-off-by: Pawan Gupta Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Greg Kroah-Hartman --- Documentation/ABI/testing/sysfs-devices-system-cpu | 1 arch/x86/kernel/cpu/bugs.c | 22 +++++++++++++++++++++ drivers/base/cpu.c | 8 +++++++ include/linux/cpu.h | 3 ++ 4 files changed, 34 insertions(+) --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -361,6 +361,7 @@ What: /sys/devices/system/cpu/vulnerabi /sys/devices/system/cpu/vulnerabilities/srbds /sys/devices/system/cpu/vulnerabilities/tsx_async_abort /sys/devices/system/cpu/vulnerabilities/itlb_multihit + /sys/devices/system/cpu/vulnerabilities/mmio_stale_data Date: January 2018 Contact: Linux kernel mailing list Description: Information about CPU vulnerabilities --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1809,6 +1809,20 @@ static ssize_t tsx_async_abort_show_stat sched_smt_active() ? "vulnerable" : "disabled"); } +static ssize_t mmio_stale_data_show_state(char *buf) +{ + if (mmio_mitigation == MMIO_MITIGATION_OFF) + return sysfs_emit(buf, "%s\n", mmio_strings[mmio_mitigation]); + + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) { + return sysfs_emit(buf, "%s; SMT Host state unknown\n", + mmio_strings[mmio_mitigation]); + } + + return sysfs_emit(buf, "%s; SMT %s\n", mmio_strings[mmio_mitigation], + sched_smt_active() ? "vulnerable" : "disabled"); +} + static char *stibp_state(void) { if (spectre_v2_in_eibrs_mode(spectre_v2_enabled)) @@ -1906,6 +1920,9 @@ static ssize_t cpu_show_common(struct de case X86_BUG_SRBDS: return srbds_show_state(buf); + case X86_BUG_MMIO_STALE_DATA: + return mmio_stale_data_show_state(buf); + default: break; } @@ -1957,4 +1974,9 @@ ssize_t cpu_show_srbds(struct device *de { return cpu_show_common(dev, attr, buf, X86_BUG_SRBDS); } + +ssize_t cpu_show_mmio_stale_data(struct device *dev, struct device_attribute *attr, char *buf) +{ + return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA); +} #endif --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -556,6 +556,12 @@ ssize_t __weak cpu_show_srbds(struct dev return sprintf(buf, "Not affected\n"); } +ssize_t __weak cpu_show_mmio_stale_data(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "Not affected\n"); +} + static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL); static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL); static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL); @@ -565,6 +571,7 @@ static DEVICE_ATTR(mds, 0444, cpu_show_m static DEVICE_ATTR(tsx_async_abort, 0444, cpu_show_tsx_async_abort, NULL); static DEVICE_ATTR(itlb_multihit, 0444, cpu_show_itlb_multihit, NULL); static DEVICE_ATTR(srbds, 0444, cpu_show_srbds, NULL); +static DEVICE_ATTR(mmio_stale_data, 0444, cpu_show_mmio_stale_data, NULL); static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_meltdown.attr, @@ -576,6 +583,7 @@ static struct attribute *cpu_root_vulner &dev_attr_tsx_async_abort.attr, &dev_attr_itlb_multihit.attr, &dev_attr_srbds.attr, + &dev_attr_mmio_stale_data.attr, NULL }; --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -62,6 +62,9 @@ extern ssize_t cpu_show_tsx_async_abort( extern ssize_t cpu_show_itlb_multihit(struct device *dev, struct device_attribute *attr, char *buf); extern ssize_t cpu_show_srbds(struct device *dev, struct device_attribute *attr, char *buf); +extern ssize_t cpu_show_mmio_stale_data(struct device *dev, + struct device_attribute *attr, + char *buf); extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata,