Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp658174pxm; Wed, 2 Mar 2022 06:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBo7unU36+GRdDx9vFkrU0+STHtKnWI+K8+MkZFCULfFlSUauhILzUErrWFUFKDXr1o7Dl X-Received: by 2002:aa7:c446:0:b0:410:9a8e:9b85 with SMTP id n6-20020aa7c446000000b004109a8e9b85mr29083705edr.319.1646229983111; Wed, 02 Mar 2022 06:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646229983; cv=none; d=google.com; s=arc-20160816; b=LfLWAtu1o2ca+7VYmPgkCaKOXdy7SeJwPo30vrSKwBNxZ3t/9O4bcL3cWy292PkUhN RpW6aoknbQ4+h8fNB3O5OhJFhoOxHFEF1U9/cHD4542TVuDFMKcuHQPyPitBvLeyzStc 2KI5oCIJzHHTSq4iZ+wb/0SwVpwG6/9lVxqf87YZsLt2G6vtvLUAaStYi9ORhEzXd6fJ 6j09sMucAAoMUtM2SWJc59LVX9h4atFXVu2S6/WqLkKWW0FCnedDe/+8EX4+80yZb+/F /JoR4ha1h8Mj2SmFxe1MmosMrqqde1wBru3ls39qFc7sAbmPUYvxeRpulUIdqElNEoH3 2X1A== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ct8ODXDzLbCLONPoG2yj1wc8E2nvavpR37Cs+FqU5ag=; b=0iYkd1zxqZ5g3AfzfLFPwT3Cjoxk7BVFlH4q46FSHwLX8HQ+2WdEPL41wRsCVu8LmU USPgnqlFGWRySrgzDPb2agToqfbolgZ98Hswm4L5bkwJNVsdRtDM8emU2bgb1qsdN/J/ LcJJy9rq7lJweYe3CwlTFYsAy1Lo/26ioAXD2h6HcjrVeOe0EkIYpvCn7lSlRmxTz5aM shvCPcp2X8KdCtkkLKlT998TranJt1QyrYLwIdlna41zhFyQA50GgO1/S1+Hq91SB+kx EKPjyQCh1I660jyR55QbeAznA3Nrhiuwdy4S4erxLng8vDqyfZmiYMMxSf4/zdRnF2N5 5trw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="R5wW1oi/"; 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=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb27-20020a1709077e9b00b006d229828f46si12227244ejc.884.2022.03.02.06.05.58; Wed, 02 Mar 2022 06:06:23 -0800 (PST) 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=@alien8.de header.s=dkim header.b="R5wW1oi/"; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237143AbiCBKa4 (ORCPT + 99 others); Wed, 2 Mar 2022 05:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbiCBKaz (ORCPT ); Wed, 2 Mar 2022 05:30:55 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3794A652F; Wed, 2 Mar 2022 02:30:12 -0800 (PST) Received: from nazgul.tnic (nat0.nue.suse.com [IPv6:2001:67c:2178:4000::1111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 59FEA1EC04A6; Wed, 2 Mar 2022 11:30:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1646217007; h=from:from: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=ct8ODXDzLbCLONPoG2yj1wc8E2nvavpR37Cs+FqU5ag=; b=R5wW1oi/AzU3yAzJD8+u+SGICwfzIW3pZSnuhZdsvtnbTpftmxa+uVF8mQ8eT0pLdGfj8c +6VkwRxF5qBRG/T9VQ84/mofm2SpgblhZm/CsNV09Fz7KFpXUNVKoncuQGRZYvVs17ne+i oIdl3iciSmVJqa9rQEbpGzf1J1Gc1+k= Date: Wed, 2 Mar 2022 11:30:12 +0100 From: Borislav Petkov To: Jithu Joseph Cc: hdegoede@redhat.com, markgross@kernel.org, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, corbet@lwn.net, gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, ashok.raj@intel.com, tony.luck@intel.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, ravi.v.shankar@intel.com Subject: Re: [RFC 01/10] x86/microcode/intel: expose collect_cpu_info_early() for IFS Message-ID: References: <20220301195457.21152-1-jithu.joseph@intel.com> <20220301195457.21152-2-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220301195457.21152-2-jithu.joseph@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Tue, Mar 01, 2022 at 11:54:48AM -0800, Jithu Joseph wrote: > @@ -58,6 +58,7 @@ static inline bool cpu_signatures_match(unsigned int s1, unsigned int p1, > /* ... or they intersect. */ > return p1 & p2; > } > +EXPORT_SYMBOL_GPL(cpu_signatures_match); > > /* > * Returns 1 if update has been found, 0 otherwise. > @@ -342,7 +343,7 @@ scan_microcode(void *data, size_t size, struct ucode_cpu_info *uci, bool save) > return patch; > } > > -static int collect_cpu_info_early(struct ucode_cpu_info *uci) > +int collect_cpu_info_early(struct ucode_cpu_info *uci) > { > unsigned int val[2]; > unsigned int family, model; > @@ -372,6 +373,7 @@ static int collect_cpu_info_early(struct ucode_cpu_info *uci) > > return 0; > } > +EXPORT_SYMBOL_GPL(collect_cpu_info_early); This is not how this is done - simply exporting a couple of random functions just because you need them: drivers/platform/x86/intel/ifs/load.c: In function ‘find_ifs_matching_signature’: drivers/platform/x86/intel/ifs/load.c:213:6: error: invalid use of void expression 213 | if (!cpu_signatures_match(uci->cpu_sig.sig, uci->cpu_sig.pf, shdr->sig, shdr->pf)) { | ^ make[5]: *** [scripts/Makefile.build:288: drivers/platform/x86/intel/ifs/load.o] Error 1 make[4]: *** [scripts/Makefile.build:550: drivers/platform/x86/intel/ifs] Error 2 make[3]: *** [scripts/Makefile.build:550: drivers/platform/x86/intel] Error 2 make[2]: *** [scripts/Makefile.build:550: drivers/platform/x86] Error 2 make[1]: *** [scripts/Makefile.build:550: drivers/platform] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1831: drivers] Error 2 Hell, even your function signatures don't match. And then, with that fixed it would build but then one would wonder a long time why that ifs thing doesn't work. Well: # CONFIG_MICROCODE is not set So the proper thing to do is to extract the generic functionality for comparing microcode patch signatures and for gathering the information collect_cpu_info_early() collects, into intel-generic functions, like I've done with intel_get_microcode_revision(), move that functionality to arch/x86/kernel/cpu/intel.c and then use it *both* in the microcode loader *and* your driver. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette