From patchwork Thu Aug 10 09:11:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 133822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp304252vqi; Thu, 10 Aug 2023 02:56:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHso10Pbff0b0MooR3/BWUuNpyxHbzUSVxRIpiV08kXCxGdKXtq5uyTOma1Mk01yqJHoG6B X-Received: by 2002:a05:6808:912:b0:3a1:f237:ec62 with SMTP id w18-20020a056808091200b003a1f237ec62mr2032045oih.48.1691661393840; Thu, 10 Aug 2023 02:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691661393; cv=none; d=google.com; s=arc-20160816; b=BEEwIC9hP+J1zDXwHy+3fUhz30wweTbLGdSbzdTDgPJa5teq7OlKqfh50aAGA3OgOa TQp/ab2HXkmIw6Kt9KP3ySkLYECxTl3OWZ9bmpdr7Ur4moYKcITdzs4u3vV7JSkPlEB8 /gwSU140kCP7GWqpzUhsJzFQ9qs9ij+IX5bULpfHY/aE8ugatNT4UPHQiiVy/bl7s9BI Xu4+feeqql6HMMC2OJabkAFNNub43EiMe4wow/wwRCKKE5DKQZIdvlNqGF5Bd7d6hovP 4KCO3JucmCamscuMZR2RvPeBI7RmRg9Z7GqY+O7A9mP5oHXq8g1CnDQYAYo3lXmRZZPZ L7Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=lxD26mpXhaVJ9Wv7T3hpLCp448s7AxP7phiyVMQatdk=; fh=v04ZgAqgT6xxY1amZBwnL8XrZl+PjPVFNMs5T51LxgU=; b=eRiTzy0jLmaE+cDYO4z4kPtooKpx4IrVle6bNPutl56r0BwXHL3tQctJhf23t9PbIS 1DekiFyE0nkwMPGV8MPK4Vie9JGD4TzkVAJa0X0wLyaa3QdUILrKSle4+neH4gB7v+Q+ DtEYlZ7ZaJqWurGJyBeOSgYFO4MOWMv6E7TbdL+OlkwEbrLDwMt1RoblmtpBANntuvDO Ldc4arplB+R8UVl0OMisQ1/rBwzNOHKa99nqIqivhGKe/E/AuLUozAzWdczquxWgm3bD GQSZdmCvabRz8kCfR8Umq0nJRFhzdpBupZm9eN8pULyYbVPQJMMmedlryhyjzMxt3twG QA0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=j8ubHTFO; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az9-20020a17090b028900b0026948ad4d0asi3325745pjb.123.2023.08.10.02.56.20; Thu, 10 Aug 2023 02:56:33 -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=@linutronix.de header.s=2020 header.b=j8ubHTFO; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234602AbjHJJMj (ORCPT + 99 others); Thu, 10 Aug 2023 05:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234585AbjHJJMQ (ORCPT ); Thu, 10 Aug 2023 05:12:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D142D43; Thu, 10 Aug 2023 02:11:51 -0700 (PDT) Date: Thu, 10 Aug 2023 09:11:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691658709; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lxD26mpXhaVJ9Wv7T3hpLCp448s7AxP7phiyVMQatdk=; b=j8ubHTFOjRJQg6EsUi0Qkvx4Vm5w+APH9zTCgWLD1Jg+9mehMuBPr5WAYzJ0+A0jX7YAVx 4q2E1n8FkkeJaqBlrS1iWKzP5B9TBa8+PpqbVRRcdfMwDmLZfPguPQnqW14YwiBacQjCOx zSrGXIBnEeYlTlmimj8x2Dy5gt7sI/Lfnb2FD9RNZ7tRNcJ0QSBxgwFmv5GlTQ3xPsDQar wTG8kLUoCnvUzLH039GQ84KUzdgQGD68ANtZg4t0blxzr12ZdVGX92sOT6mpOdhMcoJN0A bRFD41YE/pKtZO/kT5DZklaGvRwDbFkjgIvgvdup/5n1dgMyTT4ARVyaoTe+qg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691658709; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lxD26mpXhaVJ9Wv7T3hpLCp448s7AxP7phiyVMQatdk=; b=FgK+fzQlxcLqODNjVQQmIWC4h8steYDVZiTYuquM/PeXhoLuGjQmFroqkQasmMiUlASSdD fdAFjVhX05eYiNDQ== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] driver core: cpu: Unify redundant silly stubs Cc: Linus Torvalds , "Borislav Petkov (AMD)" , "Greg Kroah-Hartman" , Nikolay Borisov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230809102700.29449-3-bp@alien8.de> References: <20230809102700.29449-3-bp@alien8.de> MIME-Version: 1.0 Message-ID: <169165870902.27769.2974713899040967098.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773751827802603932 X-GMAIL-MSGID: 1773835537665915301 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 0fddfe338210aa018137c03030c581f5ea4be282 Gitweb: https://git.kernel.org/tip/0fddfe338210aa018137c03030c581f5ea4be282 Author: Borislav Petkov (AMD) AuthorDate: Sat, 29 Jul 2023 17:20:33 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 10 Aug 2023 11:03:04 +02:00 driver core: cpu: Unify redundant silly stubs Make them all a weak function, aliasing to a single function which issues the "Not affected" string. No functional changes. Suggested-by: Linus Torvalds Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Greg Kroah-Hartman Reviewed-by: Nikolay Borisov Link: https://lore.kernel.org/r/20230809102700.29449-3-bp@alien8.de --- drivers/base/cpu.c | 87 +++++++++------------------------------------ 1 file changed, 19 insertions(+), 68 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 52df435..054c81b 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -509,79 +509,30 @@ static void __init cpu_dev_register_generic(void) } #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES - -ssize_t __weak cpu_show_meltdown(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_spectre_v1(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_spectre_v2(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_spec_store_bypass(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_l1tf(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_mds(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_tsx_async_abort(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_itlb_multihit(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_srbds(struct device *dev, +ssize_t cpu_show_not_affected(struct device *dev, struct device_attribute *attr, char *buf) { return sysfs_emit(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"); -} - -ssize_t __weak cpu_show_retbleed(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} - -ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "Not affected\n"); -} +#define CPU_SHOW_VULN_FALLBACK(func) \ + ssize_t cpu_show_##func(struct device *, \ + struct device_attribute *, char *) \ + __attribute__((weak, alias("cpu_show_not_affected"))) + +CPU_SHOW_VULN_FALLBACK(meltdown); +CPU_SHOW_VULN_FALLBACK(spectre_v1); +CPU_SHOW_VULN_FALLBACK(spectre_v2); +CPU_SHOW_VULN_FALLBACK(spec_store_bypass); +CPU_SHOW_VULN_FALLBACK(l1tf); +CPU_SHOW_VULN_FALLBACK(mds); +CPU_SHOW_VULN_FALLBACK(tsx_async_abort); +CPU_SHOW_VULN_FALLBACK(itlb_multihit); +CPU_SHOW_VULN_FALLBACK(srbds); +CPU_SHOW_VULN_FALLBACK(mmio_stale_data); +CPU_SHOW_VULN_FALLBACK(retbleed); +CPU_SHOW_VULN_FALLBACK(spec_rstack_overflow); +CPU_SHOW_VULN_FALLBACK(gather_data_sampling); ssize_t __weak cpu_show_gds(struct device *dev, struct device_attribute *attr, char *buf)