From patchwork Mon Oct 31 07:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 13129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2154623wru; Mon, 31 Oct 2022 00:05:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44FtWQ9BF1oYhlPlot93wyEFvGplFlxUFciSD5Y114lgpXrm8pw3+5GkfJNKQ1J3JAYeWH X-Received: by 2002:a17:907:948f:b0:7a7:6425:7d1b with SMTP id dm15-20020a170907948f00b007a764257d1bmr11755874ejc.165.1667199904228; Mon, 31 Oct 2022 00:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667199904; cv=none; d=google.com; s=arc-20160816; b=BB8KK180pUduAD6LBN7Gr3TkLGYJ7mRRYHa9Ant3WiMMAM9m3sSvvb8NaxMB7gdfKo HfPGFjvA1wvZH6v5OhJ+Xxy9B4dY27sbyrEmmEnybe+7hEZUqbfLJuCrkafOPQojwlC7 395F1ZlRkh9Whvz14P52gCuuam1RmUZOUQRsfU2WtyIjTtqe+WbjPIbRSRk8onnqSPSn X0lDtqqO/q3gIAzZ+IQHISBW6ugy2RjeaSwbR84Rj+qcmJI32iTK592igsMGfw4Z+i6O Qx5vIzlsNY3KzXO8bWdaacFebsROS4PjELYXJ7NA2ioOHhHWjXwkHhOTdUGmDT51q4vW yuGw== 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=jdQUPUCENzO2lCNvKI1mwtyqvnY2gsk46zMypXbBqA4=; b=guVRVQeEHg7fjpbZj+zLCVpJw6mfpAI67Nhf06rjZTYBcZF8vtmRu/aC64OCTbUmdc FOvz/Al+2KQDm5yb5Mhh2tW6r+4hRFnIbNOlMGq5c/BV+cEXXIWW7tlgpdh9usjBUT2/ vM03HrMcSwwp3Oxla/fFzhoL3aYQs3lDKlZM1eIr7ggC6eQNbj72wVOwAhtU5yHn/n9b B7rXS4uhrbXx5xmvIOtI1nTLXVnm/SR0cA6QPaNV3jY2ufzg+5asrQsLihaHRdZa+ev1 Y6ZWN3fF5zRXblw3/8cs/v2QqyXdafuDYipUwnjDwXM0n5Q+VCg4a0r6cKzzde2BFRd0 TZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z17BXq4t; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb34-20020a1709077ea200b0078dc3cb8b48si7282714ejc.625.2022.10.31.00.04.39; Mon, 31 Oct 2022 00:05:04 -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=z17BXq4t; 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 S229785AbiJaHDh (ORCPT + 99 others); Mon, 31 Oct 2022 03:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbiJaHDe (ORCPT ); Mon, 31 Oct 2022 03:03:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 156392C0; Mon, 31 Oct 2022 00:03:34 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A74D760FF5; Mon, 31 Oct 2022 07:03:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7EE0C433D6; Mon, 31 Oct 2022 07:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667199813; bh=PVt5hY1gSSLjJUQ2tcPRxGC1hcYodD3U62WliJHhyQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z17BXq4t8/gH50FXC0uO6jmUQ9zHcmumRCmABPSGBpdJ3GeDC8AEKSMgQlCS0i7KM BaooUdKOQaZ70XCPRMz/9v7Nib/Vw02JYSfWlb3UGDUZVtcWWaJsalkrh8YzoA9n7n 9fg6GALfZurGw02Uz0Xj2I/+GYXu8a/HA70mHFmE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Gleixner , Andi Kleen , Kan Liang , "Peter Zijlstra (Intel)" , Borislav Petkov , Linus Torvalds , linux-kernel@vger.kernel.org, Ingo Molnar Subject: [PATCH 4.14 03/34] x86/cpufeature: Fix various quality problems in the header Date: Mon, 31 Oct 2022 08:02:36 +0100 Message-Id: <20221031070140.193632481@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221031070140.108124105@linuxfoundation.org> References: <20221031070140.108124105@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-8.2 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 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748185806804836795?= X-GMAIL-MSGID: =?utf-8?q?1748185806804836795?= From: Ingo Molnar commit 266d63a7d9d48c6d5dee486378ec0e8c86c4d74a upstream Thomas noticed that the new arch/x86/include/asm/cpu_device_id.h header is a train-wreck that didn't incorporate review feedback like not using __u8 in kernel-only headers. While at it also fix all the *other* problems this header has: - Use canonical names for the header guards. It's inexplicable why a non-standard guard was used. - Don't define the header guard to 1. Plus annotate the closing #endif as done absolutely every other header. Again, an inexplicable source of noise. - Move the kernel API calls provided by this header next to each other, there's absolutely no reason to have them spread apart in the header. - Align the INTEL_CPU_DESC() macro initializations vertically, this is easier to read and it's also the canonical style. - Actually name the macro arguments properly: instead of 'mod, step, rev', spell out 'model, stepping, revision' - it's not like we have a lack of characters in this header. - Actually make arguments macro-safe - again it's inexplicable why it wasn't done properly to begin with. Quite amazing how many problems a 41 lines header can contain. This kind of code quality is unacceptable, and it slipped through the review net of 2 developers and 2 maintainers, including myself, until Thomas noticed it. :-/ Reported-by: Thomas Gleixner Cc: Andi Kleen Cc: Kan Liang Cc: Peter Zijlstra (Intel) Cc: Borislav Petkov Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/cpu_device_id.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) --- a/arch/x86/include/asm/cpu_device_id.h +++ b/arch/x86/include/asm/cpu_device_id.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _CPU_DEVICE_ID -#define _CPU_DEVICE_ID 1 +#ifndef _ASM_X86_CPU_DEVICE_ID +#define _ASM_X86_CPU_DEVICE_ID /* * Declare drivers belonging to specific x86 CPUs @@ -9,8 +9,6 @@ #include -extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match); - /* * Match specific microcode revisions. * @@ -22,21 +20,22 @@ extern const struct x86_cpu_id *x86_matc */ struct x86_cpu_desc { - __u8 x86_family; - __u8 x86_vendor; - __u8 x86_model; - __u8 x86_stepping; - __u32 x86_microcode_rev; + u8 x86_family; + u8 x86_vendor; + u8 x86_model; + u8 x86_stepping; + u32 x86_microcode_rev; }; -#define INTEL_CPU_DESC(mod, step, rev) { \ - .x86_family = 6, \ - .x86_vendor = X86_VENDOR_INTEL, \ - .x86_model = mod, \ - .x86_stepping = step, \ - .x86_microcode_rev = rev, \ +#define INTEL_CPU_DESC(model, stepping, revision) { \ + .x86_family = 6, \ + .x86_vendor = X86_VENDOR_INTEL, \ + .x86_model = (model), \ + .x86_stepping = (stepping), \ + .x86_microcode_rev = (revision), \ } +extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match); extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table); -#endif +#endif /* _ASM_X86_CPU_DEVICE_ID */