From patchwork Tue Jul 25 08:26:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 125446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2343893vqg; Tue, 25 Jul 2023 02:25:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHphvUhiOH35bcdUyZBM/UzTy2LIBxBpN+7q+Eqv+3jAMdffZncmheVM1rlt4NTc6jF+I74 X-Received: by 2002:a05:6402:3d6:b0:522:3ce6:4473 with SMTP id t22-20020a05640203d600b005223ce64473mr2820082edw.16.1690277142842; Tue, 25 Jul 2023 02:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690277142; cv=none; d=google.com; s=arc-20160816; b=TIf1xgG165fweexkolaww3hRx5TqVffiXOf4mqNAOUdKWth+Su38UYBOxEH44knj3E DpjKhKO7KpmFMUYLUUwvVAMwbnNIDB9fxI/0ssMaZaIoY895PoeKN6dvdQ/28n2+iP/1 xZAWcK9IeqrN1soxtXPgBtQoQOGcKF3lweSB54w0rjYMcSwQpM7ucrrAPpNEqbyeLG2v Ou2pAiw1DRcHj83EUrky3g6s1pyVdljx8/1QrE/vZeDzD2fZNreDvdG5fVdrTBSrCH8v 0lRKoCJJeDOTEFQjEp5Zkiu3zMwP4OfpCe5JC9ZYF/qjmXW2fl1NLHPRrhkopWVKSMbd E+3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=0nGXMIaN6A1Od3buRim0DdHPev5YEgdB8kA7hWmb2UA=; fh=4LyD0rhHB2PSVj7kiKlZimNOsjQF4Fe+iCCejOU7ml8=; b=Qoj/lFCkIyoD5trr3TfyYLn2omIVhQEraPr5GvPuTynnPDBZItDzM6jMj+431ObZrX 34anUcHNsgrZDVU5SP96S8Dgq0mDpjylvmpwItJFlNkJE7RZhhSO/fl6+VEW3ky/u5wE Qn3sDgBIHwvji+1Z2rjgR0LM9nCxP29BMNYzWFltPjb+P4VqfTiXzCgjyfSPInTbflHx fDVaBfKUtW8GPdQqpLSJ4BR9/IH2HU5NVLsmvczQS1oo2p2035ScbTAJnFXkAoJPpbaZ KC6mUtrpACEmWTTEe9Nc+LNjvZ7Nq1QTsDnz47iEyHxqYEMRnACiw77V2inzMzc+mjAF lpBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rQOJ8VWA; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a05640206ce00b005222b644054si3071029edy.200.2023.07.25.02.25.18; Tue, 25 Jul 2023 02:25:42 -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=@kernel.org header.s=k20201202 header.b=rQOJ8VWA; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232860AbjGYI1a (ORCPT + 99 others); Tue, 25 Jul 2023 04:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbjGYI1P (ORCPT ); Tue, 25 Jul 2023 04:27:15 -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 711D110F4 for ; Tue, 25 Jul 2023 01:26:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DE6A614BF for ; Tue, 25 Jul 2023 08:26:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 197F5C433C8; Tue, 25 Jul 2023 08:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690273604; bh=OGBpT5Jt+TmmkL82pizZ3aBV1IMH5vp0zj/wyWC2G3U=; h=From:To:Cc:Subject:Date:From; b=rQOJ8VWAnuPVoKpTs12J5i9WSPPfURp6VB/BAT8Z5Y04R6DDCQXM4KTVL2zuqZ2iv 3hwMtLJpNHDxSZsgVBPLMFvucAziXEvfUsHyUFv76S/D6bSf20jCuf3efJEQ6Kj5xc E9cxNIn3W2nP+pCm93lWslxX1QQ01bMiA7CRpimPTQvnSQCsJAFszDHONjZPhol4CD 1E8wLD3zcfy55HgOSg0CbjrW0p5Yhon8gs8AY/1FJSaiwhMfpmz148qwYTozzb6xRO jd2ttx5rGdHoiv9j6XRKGjafC8mT0Upwh336792vH8sDO4N+XL0z6OxAUFamSmME2f FRXYVQKrX8FXQ== From: Arnd Bergmann To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: Arnd Bergmann , "H. Peter Anvin" , Kees Cook , Kim Phillips , Alexey Kardashevskiy , linux-kernel@vger.kernel.org Subject: [PATCH] x86: Fix amd_check_microcode() declaration Date: Tue, 25 Jul 2023 10:26:13 +0200 Message-Id: <20230725082638.956675-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772384045266050702 X-GMAIL-MSGID: 1772384045266050702 From: Arnd Bergmann The newly added amd_check_microcode() function has two conflicting definitions if CONFIG_CPU_SUP_AMD is enabled and CONFIG_MICROCODE_AMD is disabled. Since the header with the stub definition is not included in cpu/amd.c, this only causes a -Wmissing-prototype warning with W=1 arch/x86/kernel/cpu/amd.c:1289:6: error: no previous prototype for 'amd_check_microcode' [-Werror=missing-prototypes] Adding the missing #include shows the other problem: arch/x86/kernel/cpu/amd.c:1290:6: error: redefinition of 'amd_check_microcode' arch/x86/include/asm/microcode_amd.h:58:20: note: previous definition of 'amd_check_microcode' with type 'void(void)' Change the stub function to use the matching #ifdef check for the amd cpu support instead of the microcode and include the header to avoid both and make it behave consistently. Fixes: 522b1d69219d8 ("x86/cpu/amd: Add a Zenbleed fix") Signed-off-by: Arnd Bergmann --- arch/x86/include/asm/microcode_amd.h | 7 ++++++- arch/x86/kernel/cpu/amd.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h index 9675c621c1ca4..6a860d40b0411 100644 --- a/arch/x86/include/asm/microcode_amd.h +++ b/arch/x86/include/asm/microcode_amd.h @@ -48,13 +48,18 @@ extern void __init load_ucode_amd_bsp(unsigned int family); extern void load_ucode_amd_ap(unsigned int family); extern int __init save_microcode_in_initrd_amd(unsigned int family); void reload_ucode_amd(unsigned int cpu); -extern void amd_check_microcode(void); #else static inline void __init load_ucode_amd_bsp(unsigned int family) {} static inline void load_ucode_amd_ap(unsigned int family) {} static inline int __init save_microcode_in_initrd_amd(unsigned int family) { return -EINVAL; } static inline void reload_ucode_amd(unsigned int cpu) {} +#endif + +#ifdef CONFIG_CPU_SUP_AMD +extern void amd_check_microcode(void); +#else static inline void amd_check_microcode(void) {} #endif + #endif /* _ASM_X86_MICROCODE_AMD_H */ diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 26ad7ca423e7c..24596e3c106b7 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include