From nobody Mon Feb 9 20:11:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585822801; cv=none; d=zohomail.com; s=zohoarc; b=l68WYEtPmQ9ZKGXOpj2OuCbktuf7YS+ISf/DyQ3HvBrPhf1yZEdCsJceDUiTSB8G+Ot+DRcmKoNzlcQBeUjbXrm9ExtPZ6tzlv+6LeBEgzdo89+zcBNekWkaZ92g1YNnvSWF4qtl0k2zkwju0Rs/BnUreDpyCY6c5JrU74bFQPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585822801; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5SZNEVWz8GODJp8DQ1xr64JVMPP1YSnVtru72IoQG/U=; b=GB0V68lxulK9tHoXE1NnbxKA+4wRVYEZztU+7/Eas9j98utUKMuBCwUJuV9rfuvPy063M5KtvQWVoORE8omKn+5Zoc/7PU+vzaj+/+NuW81AEnLetOMF54eMF4+PTn/GbFwln6Plv19cvuIDd2afe/pX/+t2lPFApWLJ6hBdYsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1585822801959869.5391034519156; Thu, 2 Apr 2020 03:20:01 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jJwwU-0000px-LU; Thu, 02 Apr 2020 10:19:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jJwwS-0000pc-Vn for xen-devel@lists.xenproject.org; Thu, 02 Apr 2020 10:19:21 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6a0cec34-74cb-11ea-9e09-bc764e2007e4; Thu, 02 Apr 2020 10:19:20 +0000 (UTC) X-Inumbo-ID: 6a0cec34-74cb-11ea-9e09-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585822761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eZcKbBNzadTU2s5TsuGgFszMTPPeWk2mohwFyrTvSJM=; b=GtZaplkanE0grmFBn+4xj8xzuYu9ogeyuiEQWTzOhGumB+EDeG6D4MZp N4466XoCzuIgTroJUQmZOAwgLjJKJKKu0DHiHBroRS1TfaL7TiMHvpofk SU+jlufOls2JYcExQZ6p1AcqYL+2NkBZijbBqkBfO3d70IViOXf3fl02y 4=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: mQ5ta3syU40qCuRiz25H7IFZHcb5LaPTsLyu+OecTg5uFvaosagAGd3/k9ggn2tYW8SZcAqiXm gzXSFg7f4/7NABosLqKGIVLBZbOxWWN4kuScVVVKwFszZymiE4btkFSZ+MOj3rcGYibhLI7PBm mvEeuEAF9ilrFMhh1zvmUOxFNA5E028/P7aAuyoU2NM10l03UfNbgtvqtgvERVFaxBUklPMzZe pYDhgJgdIiqEBnG0RHgmGFtGZu4EYTHQaNCcXTcxIPEySsuDichfhSfmnrTFWbGnLkU5qdWftF TiE= X-SBRS: 2.7 X-MesageID: 15041306 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,335,1580792400"; d="scan'208";a="15041306" From: Andrew Cooper To: Xen-devel Subject: [PATCH 5/5] x86/ucode: Simplify the ops->collect_cpu_info() API Date: Thu, 2 Apr 2020 11:19:02 +0100 Message-ID: <20200402101902.28234-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200402101902.28234-1-andrew.cooper3@citrix.com> References: <20200402101902.28234-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) All callers pass &this_cpu(cpu_sig) for the cpu_sig parameter, and all implementations unconditionally return 0. Simplify it to be void. Drop the long-stale comment on the AMD side, whose counterpart in start_update() used to be "collect_cpu_info() doesn't fail so we're fine". Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 7 +++---- xen/arch/x86/cpu/microcode/core.c | 14 ++++++-------- xen/arch/x86/cpu/microcode/intel.c | 5 ++--- xen/arch/x86/cpu/microcode/private.h | 7 +++++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index e23bdef6f2..13bf9f4dee 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -90,9 +90,10 @@ static struct { uint16_t id; } equiv __read_mostly; =20 -/* See comment in start_update() for cases when this routine fails */ -static int collect_cpu_info(struct cpu_signature *csig) +static void collect_cpu_info(void) { + struct cpu_signature *csig =3D &this_cpu(cpu_sig); + memset(csig, 0, sizeof(*csig)); =20 csig->sig =3D cpuid_eax(1); @@ -100,8 +101,6 @@ static int collect_cpu_info(struct cpu_signature *csig) =20 pr_debug("microcode: CPU%d collect_cpu_info: patch_id=3D%#x\n", smp_processor_id(), csig->rev); - - return 0; } =20 static bool_t verify_patch_size(uint32_t patch_size) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 53e447ea9a..a220f908b8 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -237,10 +237,9 @@ static const struct microcode_patch *nmi_patch =3D ZER= O_BLOCK_PTR; */ static struct microcode_patch *parse_blob(const char *buf, size_t len) { - if ( likely(!microcode_ops->collect_cpu_info(&this_cpu(cpu_sig))) ) - return microcode_ops->cpu_request_microcode(buf, len); + microcode_ops->collect_cpu_info(); =20 - return NULL; + return microcode_ops->cpu_request_microcode(buf, len); } =20 static void microcode_free_patch(struct microcode_patch *patch) @@ -306,10 +305,9 @@ static bool wait_cpu_callout(unsigned int nr) */ static int microcode_update_cpu(const struct microcode_patch *patch) { - int err =3D microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + int err; =20 - if ( unlikely(err) ) - return err; + microcode_ops->collect_cpu_info(); =20 spin_lock(µcode_mutex); if ( patch ) @@ -737,7 +735,7 @@ int microcode_update_one(bool start_update) if ( !microcode_ops ) return -EOPNOTSUPP; =20 - microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + microcode_ops->collect_cpu_info(); =20 if ( start_update && microcode_ops->start_update ) { @@ -819,7 +817,7 @@ int __init early_microcode_init(void) return -ENODEV; } =20 - microcode_ops->collect_cpu_info(&this_cpu(cpu_sig)); + microcode_ops->collect_cpu_info(); =20 if ( ucode_mod.mod_end || ucode_blob.size ) rc =3D early_microcode_update_cpu(); diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 29745ed55f..a9f4d6e829 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -115,8 +115,9 @@ static bool signature_matches(const struct cpu_signatur= e *cpu_sig, return cpu_sig->pf & ucode_pf; } =20 -static int collect_cpu_info(struct cpu_signature *csig) +static void collect_cpu_info(void) { + struct cpu_signature *csig =3D &this_cpu(cpu_sig); uint64_t msr_content; =20 memset(csig, 0, sizeof(*csig)); @@ -133,8 +134,6 @@ static int collect_cpu_info(struct cpu_signature *csig) csig->rev =3D (uint32_t)(msr_content >> 32); pr_debug("microcode: collect_cpu_info : sig=3D%#x, pf=3D%#x, rev=3D%#x= \n", csig->sig, csig->pf, csig->rev); - - return 0; } =20 /* diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index 878f8d805f..dc5c7a81ae 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -33,8 +33,11 @@ struct microcode_ops { struct microcode_patch *(*cpu_request_microcode)(const void *buf, size_t size); =20 - /* Obtain microcode-relevant details for the current CPU. */ - int (*collect_cpu_info)(struct cpu_signature *csig); + /* + * Obtain microcode-relevant details for the current CPU. Results in + * per_cpu(cpu_sig). + */ + void (*collect_cpu_info)(void); =20 /* * Attempt to load the provided patch into the CPU. Returns an error = if --=20 2.11.0