From nobody Fri Dec 27 02:18:51 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=1729776163; cv=none; d=zohomail.com; s=zohoarc; b=ZnEC0HVnQpMdMkRTGPGOR1HRUQQkqS6Fh9WJTt4yB9XckZ/AWmLMh80ZROpVYqtsSQrq47Ach6c7wYZzTPZUcGj96gRBseVxdpb1N7TRR3RKXi5GuN3wtGPVkz5LOsgRJA0DMPdsBKyQyVeH8gQeLOejjkGj7MFKW/JhS821Gww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729776163; h=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=Df5ZhRz35AbRcfDDCuCuW3JIPnNenLDg73Ag7Qq+uQc=; b=IAWDoj23IfQ865kEitKAOTLSbM+5K5Mv2ykB6lhi1ck3vzWpgBUSRGJJ/Bnrq4SL3GYmvDoDbn5vvBBP+UdH4S/hO71vHiVd0F/htt5jp1tkVH+VItAXGOT18qHXmtlOL/JDLHLL5OUYWr4qjgr/KyQnhjee/JWRW4qx1i7dAS4= 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 1729776163638955.7745038458586; Thu, 24 Oct 2024 06:22:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.825239.1239456 (Exim 4.92) (envelope-from ) id 1t3xnA-0005IA-2p; Thu, 24 Oct 2024 13:22:20 +0000 Received: by outflank-mailman (output) from mailman id 825239.1239456; Thu, 24 Oct 2024 13:22:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3xn9-0005Hz-Vs; Thu, 24 Oct 2024 13:22:19 +0000 Received: by outflank-mailman (input) for mailman id 825239; Thu, 24 Oct 2024 13:22:18 +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 1t3xn8-0004K5-8i for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 13:22:18 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fd91717d-920a-11ef-a0bf-8be0dac302b0; Thu, 24 Oct 2024 15:22:17 +0200 (CEST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5c948c41edeso1032331a12.1 for ; Thu, 24 Oct 2024 06:22:17 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 06:22:14 -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: fd91717d-920a-11ef-a0bf-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729776136; x=1730380936; 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=Df5ZhRz35AbRcfDDCuCuW3JIPnNenLDg73Ag7Qq+uQc=; b=OBeX4gqY7QspMNt5M42vV28J4pvcj6MR52E3TeXyZUTNShUxo4b7lMBvlJvCkb3jvT wOtrudYRifqjYnH7pcYb6LedYkjoud/ijKiC+cKywtzs2+4SlDJFSjUtj2TyQMkOHLuh s0EWG8HLWsE/ZQtBkwVsmEyvXPvyi5lJLVs2I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729776136; x=1730380936; 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=Df5ZhRz35AbRcfDDCuCuW3JIPnNenLDg73Ag7Qq+uQc=; b=ms56cUH04Fq9FY7W+HG6FL4xdDowi9HNiteoj2e5G064lL5caT1HB5In+9o2WjxpZW iSl+lCBJUK61Mcn6Ax5ffSKQngM/hlhM9oTEK4xh9yGlFe9rVH4EuSa6voFOktTaDE3F RtdP+nGEFlLP6/1rdHAS/yn4CG+dN4ddGL+YnmwRVGG6dR1jylxMGVHnkcJjfYf4lZlM M527m+OOsFYwFNCGHBVctwZrZ8tHvGjAbxnGKVhQag9tC4Z36erobfFqdDfMdg7sOVJ+ 8jdc5Eokym/4yKbeUp6RUVXLj01WN58n6oV/USONoRlY2JV44D5uENAN2jY1i5WuLBxE KrBQ== X-Gm-Message-State: AOJu0YxG5ppIQ6DZBbCvCtGUQZe6Ne/c1oXef1ffVoYOeYhA1bLG4dAB mf9ajC0giO5pmDosXf6rZJN41KbvxTz2oJUs/bUoAXNNOyP5ccf5Lely2qx+OLRQaYZj4jN+8XG 8 X-Google-Smtp-Source: AGHT+IHTUnP+Aq6o8B4fU0w9na2iXanTiNixUKKg99rw6/LW1fGByVVfMqw13Yi4nOF6XBc/BuDTgw== X-Received: by 2002:a17:906:7309:b0:a99:dde6:9f42 with SMTP id a640c23a62f3a-a9abf96ce04mr630900766b.47.1729776135978; Thu, 24 Oct 2024 06:22:15 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper Subject: [PATCH 4/5] x86/ucode: Rename the apply_microcode() hook to load() Date: Thu, 24 Oct 2024 14:22:04 +0100 Message-Id: <20241024132205.987042-5-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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1729776164502116600 Content-Type: text/plain; charset="utf-8" The microcode suffix is redundant, and "microcode loading" is the more comm= on term Reviewed-by: Jason Andryuk --- xen/arch/x86/cpu/microcode/amd.c | 6 +++--- xen/arch/x86/cpu/microcode/core.c | 27 ++++++++++++++++----------- xen/arch/x86/cpu/microcode/intel.c | 8 ++++---- xen/arch/x86/cpu/microcode/private.h | 7 +++---- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 3f147c10ca67..1845f51ba330 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -214,8 +214,8 @@ static enum microcode_match_result cf_check compare_pat= ch( return compare_header(new, old); } =20 -static int cf_check apply_microcode(const struct microcode_patch *patch, - unsigned int flags) +static int cf_check amd_ucode_load(const struct microcode_patch *patch, + unsigned int flags) { int hw_err; unsigned int cpu =3D smp_processor_id(); @@ -446,7 +446,7 @@ static struct microcode_patch *cf_check amd_ucode_parse( static const struct microcode_ops __initconst_cf_clobber amd_ucode_ops =3D= { .parse =3D amd_ucode_parse, .collect_cpu_info =3D collect_cpu_info, - .apply_microcode =3D apply_microcode, + .load =3D amd_ucode_load, .compare_patch =3D compare_patch, }; =20 diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 29655a44ae62..f320ea87c1dc 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -229,6 +229,12 @@ static const struct microcode_patch *ucode_parse(const= char *buf, size_t len) return alternative_call(ucode_ops.parse, buf, len, false); } =20 +/* Load a ucode blob. Returns -errno. */ +static int ucode_load(const struct microcode_patch *patch, unsigned int fl= ags) +{ + return alternative_call(ucode_ops.load, patch, flags); +} + static DEFINE_SPINLOCK(microcode_mutex); =20 DEFINE_PER_CPU(struct cpu_signature, cpu_sig); @@ -333,11 +339,10 @@ static int microcode_update_cpu(const struct microcod= e_patch *patch, =20 spin_lock(µcode_mutex); if ( patch ) - err =3D alternative_call(ucode_ops.apply_microcode, patch, flags); + err =3D ucode_load(patch, flags); else if ( microcode_cache ) { - err =3D alternative_call(ucode_ops.apply_microcode, microcode_cach= e, - flags); + err =3D ucode_load(microcode_cache, flags); if ( err =3D=3D -EIO ) { microcode_free_patch(microcode_cache); @@ -388,7 +393,7 @@ static int primary_thread_work(const struct microcode_p= atch *patch, if ( !wait_for_state(LOADING_ENTER) ) return -EBUSY; =20 - ret =3D alternative_call(ucode_ops.apply_microcode, patch, flags); + ret =3D ucode_load(patch, flags); if ( !ret ) atomic_inc(&cpu_updated); atomic_inc(&cpu_out); @@ -502,7 +507,7 @@ static int control_thread_fn(const struct microcode_pat= ch *patch, goto out; =20 /* Control thread loads ucode first while others are in NMI handler. */ - ret =3D alternative_call(ucode_ops.apply_microcode, patch, flags); + ret =3D ucode_load(patch, flags); if ( !ret ) atomic_inc(&cpu_updated); atomic_inc(&cpu_out); @@ -731,7 +736,7 @@ int ucode_update_hcall(XEN_GUEST_HANDLE(const_void) buf, if ( flags & ~XENPF_UCODE_FORCE ) return -EINVAL; =20 - if ( !ucode_ops.apply_microcode ) + if ( !ucode_ops.load ) return -EINVAL; =20 buffer =3D xmalloc_flex_struct(struct ucode_buf, buffer, len); @@ -783,7 +788,7 @@ int microcode_update_one(void) if ( ucode_ops.collect_cpu_info ) alternative_vcall(ucode_ops.collect_cpu_info); =20 - if ( !ucode_ops.apply_microcode ) + if ( !ucode_ops.load ) return -EOPNOTSUPP; =20 return microcode_update_cpu(NULL, 0); @@ -821,7 +826,7 @@ int __init microcode_init_cache(struct boot_info *bi) { int rc =3D 0; =20 - if ( !ucode_ops.apply_microcode ) + if ( !ucode_ops.load ) return -ENODEV; =20 if ( ucode_scan ) @@ -907,11 +912,11 @@ int __init early_microcode_init(struct boot_info *bi) * * Take the hint in either case and ignore the microcode interface. */ - if ( !ucode_ops.apply_microcode || this_cpu(cpu_sig).rev =3D=3D ~0 ) + if ( !ucode_ops.load || this_cpu(cpu_sig).rev =3D=3D ~0 ) { printk(XENLOG_INFO "Microcode loading disabled due to: %s\n", - ucode_ops.apply_microcode ? "rev =3D ~0" : "HW toggle"); - ucode_ops.apply_microcode =3D NULL; + ucode_ops.load ? "rev =3D ~0" : "HW toggle"); + ucode_ops.load =3D NULL; return -ENODEV; } =20 diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 3d3f7e57db80..5e6863fd8c9f 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -287,8 +287,8 @@ static enum microcode_match_result cf_check compare_pat= ch( return compare_revisions(old->rev, new->rev); } =20 -static int cf_check apply_microcode(const struct microcode_patch *patch, - unsigned int flags) +static int cf_check intel_ucode_load(const struct microcode_patch *patch, + unsigned int flags) { uint64_t msr_content; unsigned int cpu =3D smp_processor_id(); @@ -408,7 +408,7 @@ static bool __init can_load_microcode(void) static const struct microcode_ops __initconst_cf_clobber intel_ucode_ops = =3D { .parse =3D intel_ucode_parse, .collect_cpu_info =3D collect_cpu_info, - .apply_microcode =3D apply_microcode, + .load =3D intel_ucode_load, .compare_patch =3D compare_patch, }; =20 @@ -417,5 +417,5 @@ void __init ucode_probe_intel(struct microcode_ops *ops) *ops =3D intel_ucode_ops; =20 if ( !can_load_microcode() ) - ops->apply_microcode =3D NULL; + ops->load =3D NULL; } diff --git a/xen/arch/x86/cpu/microcode/private.h b/xen/arch/x86/cpu/microc= ode/private.h index e30acee1536b..9611efaa979c 100644 --- a/xen/arch/x86/cpu/microcode/private.h +++ b/xen/arch/x86/cpu/microcode/private.h @@ -50,8 +50,7 @@ struct microcode_ops { * Attempt to load the provided patch into the CPU. Returns an error = if * anything didn't go as expected. */ - int (*apply_microcode)(const struct microcode_patch *patch, - unsigned int flags); + int (*load)(const struct microcode_patch *patch, unsigned int flags); =20 /* * Given two patches, are they both applicable to the current CPU, and= is @@ -68,8 +67,8 @@ struct microcode_ops { * - Loading available * * These are encoded by (not) filling in ops->collect_cpu_info (i.e. no - * support available) and (not) ops->apply_microcode (i.e. read only). - * Otherwise, all hooks must be filled in. + * support available) and (not) ops->load (i.e. read only). Otherwise, all + * hooks must be filled in. */ #ifdef CONFIG_AMD void ucode_probe_amd(struct microcode_ops *ops); --=20 2.39.5