Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1864874rwb; Fri, 28 Jul 2023 16:53:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLSMjEPpSxTQZKRnkyfpQXNi6yKkltPhSspumTfTzFDQiztyt4s6G37AbJ6sGbDKUAm5Tx X-Received: by 2002:a17:903:120c:b0:1b9:ea60:cd91 with SMTP id l12-20020a170903120c00b001b9ea60cd91mr3100951plh.7.1690588423201; Fri, 28 Jul 2023 16:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690588423; cv=none; d=google.com; s=arc-20160816; b=xO2QicpXOkgNHFEawUu2JdZmw4EosRXELxYPu98edR0ldiKNipqEzn6RzFAILB/E9s PXXhClsn/k6LvVksV/6UPua5JqnxiHYL9+XQfxEpiUpVCZuXQAuwZ3tXO6MTxH6vZXhk uOQ2HyYSqXI5265yQ9nVFNoIiTz2XxNm4/VGxDCafE1usgirVsnXLCAcbHtvwrCPWuTJ UAL4TA6sHYgYjKzxivDdBOiZH+VQQAzRVs41WY6dXVsdEf/ux6A6A1Zba1qLQn26sZnz 1oW9/XE6FITlSJ950aMocJnBtj1//RtIMTc8yh56WwyQCaxOs8Xd+Ar1euEUQOmwzYD1 7bpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8M6m7FnBn2hcD9VyxkENamrr2LSREZqNS21+eB1WG1Y=; fh=GZhzAklz/XEnwXck9u6TP122j1BsV3HxDK+4xG/HU3M=; b=j5qyNvtbDVVzpujA9m3JhJl3qgyhqJb1nDwSU82ws1U2rJW/crIgEbK03nVqDETdER tCuNyazhXqrND5QgBsSRuaDThHYx512bhn3DkMvvk7AD76OuHlWHRo52QrARlxdcVG86 CuYUlRUhl/q8OE7RV0284NKKtIORYWX6AZP5+KerbQBJsJZS9R+x3wKTiLq0N878eLo/ su5Zf3IQgdbj/2+L2cLX09Bc2BVl7iSGRvVuA1whklR+kcj1/fbfOQ3TLNt74UvdL9Ym TeKoDt47SSpEIWGxLFqqbg1NDzigQb1z4PdO3odEX2v5v7QrSrTslKA/x54Xnqd2VRil jfoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W4rTl1rO; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a170902ac9700b001b8a6bf59cfsi1129896plr.378.2023.07.28.16.53.29; Fri, 28 Jul 2023 16:53:43 -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=@intel.com header.s=Intel header.b=W4rTl1rO; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235476AbjG1XOx (ORCPT + 99 others); Fri, 28 Jul 2023 19:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbjG1XOw (ORCPT ); Fri, 28 Jul 2023 19:14:52 -0400 Received: from mgamail.intel.com (unknown [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF8B2D7D for ; Fri, 28 Jul 2023 16:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690586091; x=1722122091; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=fLe4Ct711d/Zn0z3CT2OW6j2I1oNFAQYdsbRkTnNbnQ=; b=W4rTl1rO6VtcJ6Dy1luPOzkqWI3DLWs9NBneAedF9MaiqTZjePZyF8uT eOrEW+tCzh6oRuG18F/Pxwon8jHjo5WaGegDBMI5kl0y5qE+6CxDPOa3o fIc39MNc8zgyZXgXMgxuvpoh2cUKRz2BFPBDIZNZUPHT+88W72KheOP1S dq9sFFdLFxhYk/yn7yXHCsmCOeB+e81WYaPz/Uea/kZ6S7JcmxnS6uNdj SvQ4Sg8TE/7wQEkNf7sULG6cjVEX09ms0+sXuK1Js39eHA0391HFeLIs/ gcq/d2pJQn0xNeVn7wSSUX4XPPB6usILhSgtoDAFworA6IwX90Jy0CSYE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10785"; a="372334225" X-IronPort-AV: E=Sophos;i="6.01,238,1684825200"; d="scan'208";a="372334225" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2023 16:14:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10785"; a="762735849" X-IronPort-AV: E=Sophos;i="6.01,238,1684825200"; d="scan'208";a="762735849" Received: from rhedaoo-mobl1.amr.corp.intel.com (HELO desk) ([10.252.141.89]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2023 16:14:50 -0700 Date: Fri, 28 Jul 2023 16:14:25 -0700 From: Pawan Gupta To: Nikolay Borisov Cc: x86@kernel.org, bp@alien8.de, tglx@linutronix.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/cpu/amd: Report zenbleed in sysfs Message-ID: <20230728231425.mku5wnsgfzx2kyeo@desk> References: <20230727075446.1749969-1-nik.borisov@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727075446.1749969-1-nik.borisov@suse.com> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Thu, Jul 27, 2023 at 10:54:46AM +0300, Nikolay Borisov wrote: > Initial submission of Zenbleed fix omitted reporting the bug in sysfs. > There's no reason why it shouldn't be reported so let's add it among > the other vulnerabilities. > > Signed-off-by: Nikolay Borisov > --- > .../ABI/testing/sysfs-devices-system-cpu | 1 + > arch/x86/kernel/cpu/amd.c | 15 +++++++++++++++ > drivers/base/cpu.c | 8 ++++++++ > include/linux/cpu.h | 2 ++ > 4 files changed, 26 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu > index ecd585ca2d50..30bb4196e451 100644 > --- a/Documentation/ABI/testing/sysfs-devices-system-cpu > +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu > @@ -524,6 +524,7 @@ What: /sys/devices/system/cpu/vulnerabilities > /sys/devices/system/cpu/vulnerabilities/itlb_multihit > /sys/devices/system/cpu/vulnerabilities/mmio_stale_data > /sys/devices/system/cpu/vulnerabilities/retbleed > + /sys/devices/system/cpu/vulnerabilities/zenbleed > Date: January 2018 > Contact: Linux kernel mailing list > Description: Information about CPU vulnerabilities > diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c > index 26ad7ca423e7..3ab9745eafc5 100644 > --- a/arch/x86/kernel/cpu/amd.c > +++ b/arch/x86/kernel/cpu/amd.c > @@ -1279,6 +1279,21 @@ u32 amd_get_highest_perf(void) > } > EXPORT_SYMBOL_GPL(amd_get_highest_perf); > > +ssize_t cpu_show_zenbleed(struct device *dev, struct device_attribute *attr, char *buf) > +{ > + Extra newline. > + if (!cpu_has_amd_erratum(&boot_cpu_data, amd_zenbleed) || > + !boot_cpu_has(X86_FEATURE_AVX) || > + boot_cpu_has(X86_FEATURE_HYPERVISOR)) > + return sysfs_emit(buf, "Not affected\n"); > + > + if (!cpu_has_zenbleed_microcode()) { For readability this can check of microcode present case, and drop the NOT operator. > + return sysfs_emit(buf, "Mitigation: Chickenbit\n"); Shouldn't this be checking if the chicken bit is set? And if its not set then report "Vulnerable". But, looking at zenbleed_check() it appear that the chicken bit for zenbleed will always be present, and it will always be set if microcode is not present. > + } else { > + return sysfs_emit(buf, "Mitigation: Microcode\n"); > + } > +}