From patchwork Tue Jan 3 18:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 38575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4747763wrt; Tue, 3 Jan 2023 10:03:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXulvoap9m38KjCUtvQpJ30De0kGtmI+4lNC/AbaPOj3xCyOsJTSHlFM2Cy09kqRBJ1QSgid X-Received: by 2002:a17:906:49cd:b0:7c0:f684:9092 with SMTP id w13-20020a17090649cd00b007c0f6849092mr38214539ejv.37.1672769028420; Tue, 03 Jan 2023 10:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769028; cv=none; d=google.com; s=arc-20160816; b=jwmlVd8WBanehzaAH7/02h3MKtkKwukW3eLNNA3qt4RqJIlPL4kOLaF9npNAAG8iq5 lhWSbJS/xCi5H5WiSYfjevZULogLR5bGwHHZ0zjLlPTFJjLokTdz701OwRn9DIq+RlEt eSemae86s+GI0hY2dEQdW+PnivbB3j70dWSGe/GbxE63ZcYCPxZ4HmeudutnIlIBeMzy Jov7IBHEhusWR6+eqsYROBGqmvNlbcr3x3D1Qs2cAKMZ5cj3Yj7ySinHbaDM2uuf4tfI tKzld2Akwsf8BK6Ftu1VZJ79i5kIRKBwstHRDpwpGM1icoeg7MKvqoUO2Zv1SqiFGDG3 4EHA== 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=Wj9SnnoW3+QUsrElLaCSEx+KtaocMDLeXkG5A6cBpZI=; b=Ja+wAeq887yaWsGJpnJ7rF8aKpeEOaW2KpudUO3j7tpyQIyXnWV+oEz1gIiKdJZW9s yYMzM4tiG0r6T1zujojKjqfaTN+Uti05Auu80PZIZnuANMgQ2SRpGbCOAV0rSVp4RwBH K8b2hVlpJAI1JlsFbqNxUXkSZsZj8aD/BQqQ6dGXCRw3L/v8k7dG9KaCXmB8NIJN4/EI rSiTFilZPis2Fntl8zbUQETGw3lkO9BQHsoiTohTB3q/EbGE3AWVUoSkWtVCyNUz0Ja3 f5CjO6HPJsycObULCch3KZaIWLlcCGr+DULZ3M5/ThfoATc49n4KKqIhvwKBAD6hN8Nn V8xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XHA/9oB6"; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr18-20020a170906d55200b0078d805901b1si28081661ejc.489.2023.01.03.10.03.25; Tue, 03 Jan 2023 10:03:48 -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=@intel.com header.s=Intel header.b="XHA/9oB6"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238626AbjACSCm (ORCPT + 99 others); Tue, 3 Jan 2023 13:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238552AbjACSC2 (ORCPT ); Tue, 3 Jan 2023 13:02:28 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A9511A27 for ; Tue, 3 Jan 2023 10:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672768945; x=1704304945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lzIse4ZWwsUKwU2q15GNya0zg7eYgzn0naky1H7IqGc=; b=XHA/9oB618gKmvBx60b4494Zj9KfRJbKcHAhn3oH8gfivSDYrSvFGxzl 2CMa3U72aH7Pp1yn6HxLMQ9HpeCMufrP6yXD7CkmfYJP56RbkzAE71FVr H2Olc6eeIRRqWe3WcMKvB0AB+rCjquibgYOejI/Y9tdWIYdW7MVcc00l/ pv/Uh4jE4DBE+1xxxCrfui8XyIVt0Z7aB3lV6lk3bkTLdo5qNM1QJc0o0 oOIjdBISWsJ4BglBP85rkNm6MKoGg0UiIlJGwSAnQqAAFqe61IFcDRwWp zXx08o58neZwHEURNQbm8pvhyTh6soHTP3EQloF4OOPj9bMx8gFpr5wHP g==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="384010652" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="384010652" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 10:02:22 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="654876888" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654876888" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 10:02:24 -0800 From: Ashok Raj To: Borislav Petkov , Thomas Gleixner Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , Alison Schofield , Reinette Chatre , Tom Lendacky Subject: [PATCH v3 4/6] x86/microcode/intel: Use a plain revision argument for print_ucode_rev() Date: Tue, 3 Jan 2023 10:02:10 -0800 Message-Id: <20230103180212.333496-5-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230103180212.333496-1-ashok.raj@intel.com> References: <20230103180212.333496-1-ashok.raj@intel.com> 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_NONE 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?1754025456418654428?= X-GMAIL-MSGID: =?utf-8?q?1754025456418654428?= print_ucode_rev() takes a struct ucode_cpu_info argument. The sole purpose of it is to print the microcode revision. The only available ucode_cpu_info always describes the currently loaded microcode revision. After a microcode update is successful, this is the new revision, or on failure it is the original revision. Subsequent changes need to print both the original and new revision, but the original version will be cached in a plain integer, which makes the code inconsistent. Replace the struct ucode_cpu_info argument with a plain integer which contains the revision number and adjust the call sites accordingly. No functional change. Signed-off-by: Ashok Raj Reviewed-by: Thomas Gleixner Cc: LKML Cc: x86 Cc: Tony Luck Cc: Dave Hansen Cc: Alison Schofield Cc: Reinette Chatre Cc: Thomas Gleixner Cc: Tom Lendacky --- Changes since earlier post. Thomas: - Updated commit log as suggested - Remove the line break after static void before print_ucode_info --- arch/x86/kernel/cpu/microcode/intel.c | 31 ++++++++------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 6bebc46ad8b1..1d709b72cfd0 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -310,13 +310,10 @@ static bool load_builtin_intel_microcode(struct cpio_data *cp) /* * Print ucode update info. */ -static void -print_ucode_info(struct ucode_cpu_info *uci, unsigned int date) +static void print_ucode_info(unsigned int new_rev, unsigned int date) { pr_info_once("microcode updated early to revision 0x%x, date = %04x-%02x-%02x\n", - uci->cpu_sig.rev, - date & 0xffff, - date >> 24, + new_rev, date & 0xffff, date >> 24, (date >> 16) & 0xff); } @@ -334,7 +331,7 @@ void show_ucode_info_early(void) if (delay_ucode_info) { intel_cpu_collect_info(&uci); - print_ucode_info(&uci, current_mc_date); + print_ucode_info(uci.cpu_sig.rev. current_mc_date); delay_ucode_info = 0; } } @@ -343,33 +340,23 @@ void show_ucode_info_early(void) * At this point, we can not call printk() yet. Delay printing microcode info in * show_ucode_info_early() until printk() works. */ -static void print_ucode(struct ucode_cpu_info *uci) +static void print_ucode(int new_rev, int date) { struct microcode_intel *mc; int *delay_ucode_info_p; int *current_mc_date_p; - mc = uci->mc; - if (!mc) - return; - delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info); current_mc_date_p = (int *)__pa_nodebug(¤t_mc_date); *delay_ucode_info_p = 1; - *current_mc_date_p = mc->hdr.date; + *current_mc_date_p = date; } #else -static inline void print_ucode(struct ucode_cpu_info *uci) +static inline void print_ucode(int new_rev, int date) { - struct microcode_intel *mc; - - mc = uci->mc; - if (!mc) - return; - - print_ucode_info(uci, mc->hdr.date); + print_ucode_info(new_rev, date); } #endif @@ -409,9 +396,9 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) uci->cpu_sig.rev = rev; if (early) - print_ucode(uci); + print_ucode(uci->cpu_sig.rev, mc->hdr.date); else - print_ucode_info(uci, mc->hdr.date); + print_ucode_info(uci->cpu_sig.rev, mc->hdr.date); return 0; }