From nobody Fri Dec 27 13:34:53 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1729776165; cv=none; d=zohomail.com; s=zohoarc; b=G8O2W7L20vEbq4SGXw6FP++ESusKpMRZeNFa7DYaAysqjK8kCqrSjUqyFZEv8IczZNV8mL5+JY1N949bTSYL8DOO1lFXtW3XRchXzkzbtdPkwsFG2OG0Avql0dAIorbnGdLQvjsQ9HRnGMuPVLEeZCNAnUa9tmoEvXfDKhdzWGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729776165; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XEK8lPkq2pM0BIHJkdhJ3DO8laaRlVDZkwJP1Ftbg9E=; b=TEpmyqUHmq+KGLNJAIDlylk4mlDa8kLJL5h4Gxecl9wh6fugeJWprwRSVLotn6qKbKvLCuNO+S6FkMvgk4AGuQWts1LyyXnN2PgIzr26fm+ALys7nnmB3UxhNevqRK/nqIfnrt6gY24OFhrFMbMREhjc/sDAOOs/G9LlUcqdQro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17297761657311014.5208961547231; Thu, 24 Oct 2024 06:22:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.825237.1239435 (Exim 4.92) (envelope-from ) id 1t3xn7-0004ml-BT; Thu, 24 Oct 2024 13:22:17 +0000 Received: by outflank-mailman (output) from mailman id 825237.1239435; Thu, 24 Oct 2024 13:22:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3xn7-0004me-8n; Thu, 24 Oct 2024 13:22:17 +0000 Received: by outflank-mailman (input) for mailman id 825237; Thu, 24 Oct 2024 13:22:16 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3xn6-0004K5-1y for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 13:22:16 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fc598d78-920a-11ef-a0bf-8be0dac302b0; Thu, 24 Oct 2024 15:22:15 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a9a26a5d6bfso116892066b.1 for ; Thu, 24 Oct 2024 06:22:15 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912ee592sm618574766b.79.2024.10.24.06.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 06:22:13 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc598d78-920a-11ef-a0bf-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729776134; x=1730380934; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XEK8lPkq2pM0BIHJkdhJ3DO8laaRlVDZkwJP1Ftbg9E=; b=o4KPqv5Fn5t/pYZmo/MWrtbkcsoifJMy2fPde2f3O7me/TsYV13iIXcmkn4ALS8NZD kE3nkla79mkqGTwffRSoE0CJcAdCuL9LB9AYWPWl9k+FPaZEW7gdxBPTyKJ7zu/HHGSs dS+9mo9JOEGKf+QrP0ZOMXeCDGbZTfY7+a6FI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729776134; x=1730380934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XEK8lPkq2pM0BIHJkdhJ3DO8laaRlVDZkwJP1Ftbg9E=; b=Y5efT7blj0P3Ig9iPLvNKyNvEJYQUMNONdIepv5Z5d8fhgWhIWCuQJ7Ne2h4NveRGf Bmu3QFVJ+4efqq9ynUv7V6VY31735ItGpYuvLa8/zhhDXMOSHwLwLtSHWoHWnuP4wtoE 8ZEb+B+HUDlYN0yowTeHGNIOfKbE36YJZY5F/CIiu21I4iXVU8jF3Fyqdp5Jcbs9JtY7 IeYU+b+yzthiPu7E8gCHcwcqhD2jM97+bnXt8l3pC2YTtwFuq3NEVANxk4ALnet/D95r 9ebc6VTafLuipXODByTuyGYFJynYMyEaN2uFUt7uNHUIJmMDopPLcQKoRJvCZ6xSSDyh LerA== X-Gm-Message-State: AOJu0YxicycdizUkyPO09hSpOC0OoudTfXGEmgBmkc1SjgKR6zqWlBQK 11lBChRXb547nRvx91GQlJdrVMYhUXdE6ownFzZpsJ1FmHBV8ZaG1cHHbeF32TqZc6cgzZzQjlj u X-Google-Smtp-Source: AGHT+IFGHdvyoTwoaTjUB6lqWKhS3LAmydk5HgOI4qdq1YnBqpDv7EOvvHeclwZXEUaaSPgOAUHlIw== X-Received: by 2002:a17:907:3fa6:b0:a99:c0be:a8ac with SMTP id a640c23a62f3a-a9abf8b233amr554772866b.37.1729776134279; Thu, 24 Oct 2024 06:22:14 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 3/5] x86/ucode: Rename the cpu_request_microcode() hook to parse() Date: Thu, 24 Oct 2024 14:22:03 +0100 Message-Id: <20241024132205.987042-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024132205.987042-1-andrew.cooper3@citrix.com> References: <20241024132205.987042-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1729776166410116600 cpu_request_microcode() was never a good name, and the microcode suffix is redundant. Rename it to simply parse(). Introduce ucode_parse() and ucode_parse_dup() wrappers around the parse() hook, also abstracting away the make_copy parameter and associated const-correctness. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jason Andryuk --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 4 ++-- xen/arch/x86/cpu/microcode/core.c | 22 ++++++++++++++++------ xen/arch/x86/cpu/microcode/intel.c | 4 ++-- xen/arch/x86/cpu/microcode/private.h | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 0fe869eff119..3f147c10ca67 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -311,7 +311,7 @@ static int scan_equiv_cpu_table(const struct container_= equiv_table *et) return -ESRCH; } =20 -static struct microcode_patch *cf_check cpu_request_microcode( +static struct microcode_patch *cf_check amd_ucode_parse( const void *buf, size_t size, bool make_copy) { const struct microcode_patch *saved =3D NULL; @@ -444,7 +444,7 @@ static struct microcode_patch *cf_check cpu_request_mic= rocode( } =20 static const struct microcode_ops __initconst_cf_clobber amd_ucode_ops =3D= { - .cpu_request_microcode =3D cpu_request_microcode, + .parse =3D amd_ucode_parse, .collect_cpu_info =3D collect_cpu_info, .apply_microcode =3D apply_microcode, .compare_patch =3D compare_patch, diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index cad38d859eee..29655a44ae62 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -217,6 +217,18 @@ static void __init microcode_grab_module(struct boot_i= nfo *bi) =20 static struct microcode_ops __ro_after_init ucode_ops; =20 +/* Parse a ucode blob. Returns a pointer to a heap-allocated copy, or PTR= _ERR. */ +static struct microcode_patch *ucode_parse_dup(const char *buf, size_t len) +{ + return alternative_call(ucode_ops.parse, buf, len, true); +} + +/* Parse a ucode blob. Returns a pointer into @buf, or PTR_ERR. */ +static const struct microcode_patch *ucode_parse(const char *buf, size_t l= en) +{ + return alternative_call(ucode_ops.parse, buf, len, false); +} + static DEFINE_SPINLOCK(microcode_mutex); =20 DEFINE_PER_CPU(struct cpu_signature, cpu_sig); @@ -604,9 +616,7 @@ static long cf_check ucode_update_hcall_cont(void *data) } =20 alternative_vcall(ucode_ops.collect_cpu_info); - patch_with_flags.patch =3D alternative_call(ucode_ops.cpu_request_micr= ocode, - (const void *)buffer->buffer, - buffer->len, true); + patch_with_flags.patch =3D ucode_parse_dup(buffer->buffer, buffer->len= ); patch_with_flags.flags =3D buffer->flags; xfree(buffer); if ( IS_ERR(patch_with_flags.patch) ) @@ -788,7 +798,7 @@ static int __init early_update_cache(const void *data, = size_t len) return -ENOMEM; =20 alternative_vcall(ucode_ops.collect_cpu_info); - patch =3D alternative_call(ucode_ops.cpu_request_microcode, data, len,= true); + patch =3D ucode_parse_dup(data, len); if ( IS_ERR(patch) ) { printk(XENLOG_WARNING "Parsing microcode blob error %ld\n", @@ -832,7 +842,7 @@ static int __init early_microcode_update_cpu(void) { const void *data =3D NULL; size_t len; - struct microcode_patch *patch; + const struct microcode_patch *patch; =20 if ( ucode_blob.size ) { @@ -848,7 +858,7 @@ static int __init early_microcode_update_cpu(void) if ( !data ) return -ENOMEM; =20 - patch =3D ucode_ops.cpu_request_microcode(data, len, false); + patch =3D ucode_parse(data, len); if ( IS_ERR(patch) ) { printk(XENLOG_WARNING "Parsing microcode blob error %ld\n", diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index bad51f64724a..3d3f7e57db80 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -334,7 +334,7 @@ static int cf_check apply_microcode(const struct microc= ode_patch *patch, return 0; } =20 -static struct microcode_patch *cf_check cpu_request_microcode( +static struct microcode_patch *cf_check intel_ucode_parse( const void *buf, size_t size, bool make_copy) { int error =3D 0; @@ -406,7 +406,7 @@ static bool __init can_load_microcode(void) } =20 static const struct microcode_ops __initconst_cf_clobber intel_ucode_ops = =3D { - .cpu_request_microcode =3D cpu_request_microcode, + .parse =3D intel_ucode_parse, .collect_cpu_info =3D collect_cpu_info, .apply_microcode =3D apply_microcode, .compare_patch =3D compare_patch, diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index c72f060ac394..e30acee1536b 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -37,7 +37,7 @@ struct microcode_ops { * If one is not found, (nothing matches the current CPU), return NULL. * Also may return ERR_PTR(-err), e.g. bad container, out of memory. */ - struct microcode_patch *(*cpu_request_microcode)( + struct microcode_patch *(*parse)( const void *buf, size_t size, bool make_copy); =20 /* --=20 2.39.5