Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5485063rwb; Wed, 9 Aug 2023 05:07:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXDfNoE/EqdFKjKWnKAk2i13GUwHx5UcyjNnNXsXsBFcLyBoZKShemcVUZ2FgM76NTzrj1 X-Received: by 2002:a05:6a00:189e:b0:686:b732:8792 with SMTP id x30-20020a056a00189e00b00686b7328792mr16993514pfh.8.1691582835314; Wed, 09 Aug 2023 05:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582835; cv=none; d=google.com; s=arc-20160816; b=AIqHckLbyeHBIxX502boBAU+fy5dqyYRfGO+mouUjQXyxA60Tmy4SEO+L70L06n00q /jneeFfkOAP2ePxDADeOPbVZqratZ2kVYIfyR/+NuH13tPjPFvd7DJDQIuZJwQsse8fy HVJE0JwhLdy+Mhlq3btoWV4vBjBs/WzSEGNOTKUN9IGzmisACg18gMLfyv0ycAt4SaoF YM9jJiFTgElhHpF1oWAKVqO9LU9xPb5vfPWK/uqEsEnX3Yg3dV/ZCgFf75XJUvw1DAyl 6/x0EJMibRg2W1MYTBM939GDQUlldjU8tSJGQ3e0D2DhQyam6HV0l/qDYTJR4aR3KvRC euOw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kq4EvkdbrNMR0g47WvEeuhpfyD9qSzHU+7VYQ+POwmw=; fh=XKtQyXaCQxzsaabDUqWwb5UUdzQvW23zJZqs2rj4yew=; b=QPgNykhiVYypzJJyMT5Kk8eBwaQE7GIkdtuOCW/9efKh9dC2QinARcuUWX4YHG3pFN 92lf8oRlBHctLsaRKS52AX/WNbMS0aSe4a1GiyDsBcaNDT/PxI+L3eVHs4cL7mg+ysf/ fuGEsSAImxBL05p2PjQP4aPB3ljPsQR8LwOMg2Fv9qYTb/Nk2V92r56arpNFz5EXkArh 6hoRlmx+8ZphGtjU7u1LTf0vDmrCrDaT5vULktIt9wbyfq4VxvEEgMnp48/zxUV9mdhh Ln6dQlEypbOpXLvrwuW9xH+VKcXiBjYacl6x+AcBvpcfvjeTXs0uzS3P/9GJ9jOZ6AXH gQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=SGka17EZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w67-20020a636246000000b00563f49e7ba8si9072032pgb.831.2023.08.09.05.07.02; Wed, 09 Aug 2023 05:07:15 -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=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=SGka17EZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232179AbjHIK1o (ORCPT + 99 others); Wed, 9 Aug 2023 06:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjHIK1j (ORCPT ); Wed, 9 Aug 2023 06:27:39 -0400 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB1C2112 for ; Wed, 9 Aug 2023 03:27:38 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id A5FFA40E01A2; Wed, 9 Aug 2023 10:27:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=fail (4096-bit key) reason="fail (body has been altered)" header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CMOzuCbjzq-X; Wed, 9 Aug 2023 10:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1691576854; bh=Kqk9iB23zva22rrtFW2VbzZ/5CKBSXXVyARTF51x9QA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SGka17EZMGm4JXxnMyDhLYGVtgljDnAdoSMNtZ2lOkPViuraS2B0tGP87U1A5YOU6 pLU5TwFMdeQHwELL4ZBX6r6zyp4O3mHl7b5Pwse17QGn9Ggdd2mrstQBqEHGRcPm6P 5TDN/bJpeO0PoU7qOLuD8jA8+XJHxyaVg8r2FeJKFrfsOR8eHQZY4dJwAtFInMxC2E hc9BZlAp4lIOJuN61fgp9Yfc/Lfu7oB+FhF2cP9VF/0uPZY9+afMdBqzyPDZMd9ZQU NdtOFo8/44V08gFZt9Yx2WGA8dNnjDnEF9AdSUqtG5doXaa7SVkcFgkcg0+yfpDTGi 5nhpi77l4y6muTjA/MECzXAGAvoONSr2c+ukmItFPLtSaJa/iiV5Z4OexUI/3Pxih3 WDmES3fA80yPoza+Osx1I58FdbJ+2wKT36Z3PLVWNVHUxAx2vqoynTdirOKug5nq5L I81VgWACQAwOhIc630PxOq2dmuGhIobCpozVlP6L+Df8HbAfkb+F3LRFd2gz6Ie8uu 1MuNcOk1qYv1k4LSF8+iFeSfeV3C03p1BjMQxE/6VaaXP1wkiwV5EkAiEGOAJq60qY 2JlwyTwmu8pt1VhxvwYeHnplKUecCGmNPFa0kA93Jk5S411atMzYOdSXb0lST1+C8G BxOydA0/12OUtG7QeIT2vuCQ= Received: from zn.tnic (pd9530d32.dip0.t-ipconnect.de [217.83.13.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6874140E0140; Wed, 9 Aug 2023 10:27:30 +0000 (UTC) From: Borislav Petkov To: X86 ML Cc: Greg Kroah-Hartman , LKML , Linus Torvalds Subject: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs Date: Wed, 9 Aug 2023 12:26:59 +0200 Message-ID: <20230809102700.29449-3-bp@alien8.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809102700.29449-1-bp@alien8.de> References: <20230809102700.29449-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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: "Borislav Petkov (AMD)" 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) --- drivers/base/cpu.c | 86 ++++++++++------------------------------------ 1 file changed, 18 insertions(+), 68 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 52df435eecf8..971771347aa6 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -509,79 +509,29 @@ static void __init cpu_dev_register_generic(void) } =20 #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"); } =20 -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_VULN_FALLBACK(func) \ + ssize_t cpu_show_##func(struct device *, \ + struct device_attribute *, char *) \ + __attribute__((weak, alias("cpu_show_not_affected"))) + +CPU_VULN_FALLBACK(meltdown); +CPU_VULN_FALLBACK(spectre_v1); +CPU_VULN_FALLBACK(spectre_v2); +CPU_VULN_FALLBACK(spec_store_bypass); +CPU_VULN_FALLBACK(l1tf); +CPU_VULN_FALLBACK(mds); +CPU_VULN_FALLBACK(tsx_async_abort); +CPU_VULN_FALLBACK(itlb_multihit); +CPU_VULN_FALLBACK(srbds); +CPU_VULN_FALLBACK(mmio_stale_data); +CPU_VULN_FALLBACK(retbleed); +CPU_VULN_FALLBACK(spec_rstack_overflow); =20 ssize_t __weak cpu_show_gds(struct device *dev, struct device_attribute *attr, char *buf) --=20 2.41.0