From nobody Mon Nov 3 06:35:10 2025 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=1730982107; cv=none; d=zohomail.com; s=zohoarc; b=GxCICjfeQGBJ4Qa3VXLRNseU/jJO4zDEMkzlQAujfAaTL5qy5iLFqmuztUZGphqFFAhQCk8+JyJd7vDfyBt0oGOcSVY+HdItZ9+ziCL6PhaN2jBfNz10zfbJJz5pRSTxs631zcL7uicqcQHw85wc76fiYBYJ/qd2zXF4MiT8HlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730982107; 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=SDbTb7NjSJYn3X1Dh4L5KXZIiaqRtXYAT6o5D6+07ZU=; b=NF2qyuaPvlSsGeq2XA+sPe3XVtFOmeJ/MTaVFYjqlkxPQ62XH22+5ulZYLKhBFHn91JWfdl+LEoYWRwE96H3o9T06ofcjXF0xEyCJw5DgMCtzJsVvLLyg7A/eHxjiEzxFQq78E3gP42rcuMWWYaQ75ONyspvhfAjUu/4Yf9A/OA= 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 1730982107483321.69324867534783; Thu, 7 Nov 2024 04:21:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.831765.1247133 (Exim 4.92) (envelope-from ) id 1t91Vu-0003Uv-G6; Thu, 07 Nov 2024 12:21:26 +0000 Received: by outflank-mailman (output) from mailman id 831765.1247133; Thu, 07 Nov 2024 12:21:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t91Vu-0003Un-DG; Thu, 07 Nov 2024 12:21:26 +0000 Received: by outflank-mailman (input) for mailman id 831765; Thu, 07 Nov 2024 12:21:25 +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 1t91Vt-0003Uc-Ik for xen-devel@lists.xenproject.org; Thu, 07 Nov 2024 12:21:25 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cc80d798-9d02-11ef-a0c6-8be0dac302b0; Thu, 07 Nov 2024 13:21:21 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5cebcf96fabso1057163a12.3 for ; Thu, 07 Nov 2024 04:21:21 -0800 (PST) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf03b5c91esm727688a12.4.2024.11.07.04.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 04:21:20 -0800 (PST) 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: cc80d798-9d02-11ef-a0c6-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo1MmMiLCJoZWxvIjoibWFpbC1lZDEteDUyYy5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImNjODBkNzk4LTlkMDItMTFlZi1hMGM2LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwOTgyMDgxLjk3MjE4NSwic2VuZGVyIjoiYW5kcmV3LmNvb3BlckBjbG91ZC5jb20iLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730982081; x=1731586881; 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=SDbTb7NjSJYn3X1Dh4L5KXZIiaqRtXYAT6o5D6+07ZU=; b=agqa3JUTy2fl+mpj6JAbJDy6oCVvngy5hXNVD3oNvvYw0Dj5/T+RoEIu1onw6X2l0N XDMfXYgbItG/QgG2u5xA3M9d6bJuT4vbqioXzl/I0Cz0U4yCwUTkdkG/Dw2pE5fTIG2D QojCzhveo0ceeSc5D7TIKYOvaO4zH+Sdm8X7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730982081; x=1731586881; 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=SDbTb7NjSJYn3X1Dh4L5KXZIiaqRtXYAT6o5D6+07ZU=; b=KDlPEuO5NauW9d7pwGLfJ88OOreiFGrZtnVmNeZm4l83EPjOhZjULwAYuVaqw4Vi/Y dPuVM0CFzzJVUQMsX1TgKm/dmRrmbOlumLJlVrfB2w5d9WWxgxNFFD8U2+DgBQXteAET 9vN2GznH0AP3XropOmIWGrdFtJyAbJdigcrg+Oa7KjBHdunalf74mJIG7KjtOktz7r/R QQq/xIaqkixLzpBOpL1dx7va5bSoGVmo3U7LCy/ZNBMu/FMpMlpWyI1LdKXaC5PoBoTf XJD5H9IB6LeRz1piM13vJ73Qo5NDXFGYTVtjvEDhDNeix1hfhB3MyDhAkLOoN6apzjRF K6Iw== X-Gm-Message-State: AOJu0YwBIf1dX9Ai/7nKcHtrH8poN1I2+wIleBtXYQrPSp3BnvwmKmNk q1u5EsvG2Yi8VQL9jKGre0E/JfdRGj+JVJFj6utLxfP8fFMXxKovwB6wF3iIQ5Nrv9yGLh4oTFQ N X-Google-Smtp-Source: AGHT+IGpF/m3x2o12SaRg3fy6eGoryDpECSFOmUQ7NWXQw1gZ34JFuB/Ho2T7Tux41gXWEKqiTfODQ== X-Received: by 2002:a05:6402:5242:b0:5ce:f7c2:65fe with SMTP id 4fb4d7f45d1cf-5cf05a5976emr1020372a12.28.1730982080836; Thu, 07 Nov 2024 04:21:20 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 1/3] x86/ucode: Don't use microcode_update_cpu() in early_microcode_load() Date: Thu, 7 Nov 2024 12:21:15 +0000 Message-Id: <20241107122117.4073266-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241107122117.4073266-1-andrew.cooper3@citrix.com> References: <20241107122117.4073266-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: 1730982109931116600 There are two callers of microcode_update_cpu(), and because one passes NULL and one doesn't, there are effectively two disjoint pieces of logic wrapped= in a single function. early_microcode_load()'s use skips all the microcode_cache handling, and is just a simple patch application. This skips a redundant collect_cpu_info() call (performed in early_microcode_init(), marginally earlier), and avoids holding microcode_mutex when we're not interacting with microcode_cache at all. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 11cd878d1f2e..d9406ec3fd34 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -900,7 +900,7 @@ static int __init early_microcode_load(struct boot_info= *bi) */ early_mod_idx =3D idx; =20 - rc =3D microcode_update_cpu(patch, 0); + rc =3D ucode_ops.apply_microcode(patch, 0); =20 unmap: bootstrap_unmap(); --=20 2.39.5 From nobody Mon Nov 3 06:35:10 2025 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=1730982107; cv=none; d=zohomail.com; s=zohoarc; b=Knaeme80VkTAC5gifvRg8nX7CsMDe4z33PSu4COYx6jc7GymTF2PunykZucwIFSHoE5xYojOBePVmhxwewIwHGuxPMGsH+GBjpCy+v5gXY+bhGQZPQiDJGwiNC9X85krihDRro2uqtHa+o+jPXrbO+kvbbIYMIBfRYGb6fLny4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730982107; 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=VVZQOpTTpM2S/e3rLNR3YwvXv7wCxv2Z+w11Kz7Jc/g=; b=IkLW5TUGogFDL/DoGLAPdW8e9giO3IC31leG74guSnAgw0yq2yWFc2ZzbT9uxVWY116r11h1ifIz/w6vGfViP4iOX1xxSnYhLdUQ1RsfVZ9Vs76E2ID9v04LUMuTskq+Onn4FPiiyZT/waRNooBWxl3Tt/nzxlLFBfAspEM4p4o= 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 1730982107491716.8754334126567; Thu, 7 Nov 2024 04:21:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.831768.1247155 (Exim 4.92) (envelope-from ) id 1t91Vw-0003sB-CB; Thu, 07 Nov 2024 12:21:28 +0000 Received: by outflank-mailman (output) from mailman id 831768.1247155; Thu, 07 Nov 2024 12:21:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t91Vw-0003qf-3o; Thu, 07 Nov 2024 12:21:28 +0000 Received: by outflank-mailman (input) for mailman id 831768; Thu, 07 Nov 2024 12:21:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t91Vv-0003Uj-8q for xen-devel@lists.xenproject.org; Thu, 07 Nov 2024 12:21:27 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cd731a90-9d02-11ef-99a3-01e77a169b0f; Thu, 07 Nov 2024 13:21:23 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5ceccffadfdso1144762a12.2 for ; Thu, 07 Nov 2024 04:21:23 -0800 (PST) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf03b5c91esm727688a12.4.2024.11.07.04.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 04:21:21 -0800 (PST) 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: cd731a90-9d02-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo1MzAiLCJoZWxvIjoibWFpbC1lZDEteDUzMC5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImNkNzMxYTkwLTlkMDItMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwOTgyMDgzLjU4MjU3NCwic2VuZGVyIjoiYW5kcmV3LmNvb3BlckBjbG91ZC5jb20iLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730982082; x=1731586882; 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=VVZQOpTTpM2S/e3rLNR3YwvXv7wCxv2Z+w11Kz7Jc/g=; b=qolGz+oYeKF3B686Z2usJizG+p3SXjQ71i8I4nNSUiXWJwXJ6Ssx18Fw8xhtfolLgJ po4n1hzwotK1YZPlbsAKoF/zmWgWNhIUhIXEQGcMYtTuCIYExisNPmq9hyFR3agWyQuZ KPkGlxel/x264BqDTUii+1Fm3QpVbJfvIjDQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730982082; x=1731586882; 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=VVZQOpTTpM2S/e3rLNR3YwvXv7wCxv2Z+w11Kz7Jc/g=; b=FCHSz5lITD/FPObe2PqRxIKxqPlvrykEQ6+sKMKjNO4Qzen0v6DdKhXz6wH/LFFmHh kPTbDDo/k13irK8ayP2VNzgb64NAcMSp9pa58eKuzz4dL4aAXmhGR89ccj+d91bcyjQ6 +3N4peuFeBWsZBw9kXjamOWUMrnhP2ZdTV/WoEwO6vqPeUW5TuYPKxUe7rTFiyhlPlUN 7mqzJHtlgqfj9Y/+YqUa6gdocBMr0lQ6z8FRlHKhP2U6nxqoRbPCd+qGZvxX1a5bCue3 hiBsou28H5Zn+CZP3zdoX9EoaIrn9Q7DC2LtZWfIduiPa/bJBq7UuQb5ywu2tqMfxRO6 A0Pw== X-Gm-Message-State: AOJu0Yxv0NfWqd7+O3DLLuEV2O0JVX/zm+jLX2g6/nf34l/kNkKaE30m /vv7ndbeDqSrZsE3fDErwXYhKDxoFEEoWY87cPgHiTWxUYfVcJe2BKk6X6IKhim7evAe0tCAF0H A X-Google-Smtp-Source: AGHT+IGWMic17q7tsN1mJCztBO+K8U9AP6DY+ZFvHixitFldko5Xa+0H3e44iwcr5m94BjL2g1uPeA== X-Received: by 2002:a05:6402:5242:b0:5ce:f7c2:65fe with SMTP id 4fb4d7f45d1cf-5cf05a5976emr1020450a12.28.1730982082259; Thu, 07 Nov 2024 04:21:22 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 2/3] x86/ucode: Fold microcode_update_cpu() and fix error handling Date: Thu, 7 Nov 2024 12:21:16 +0000 Message-Id: <20241107122117.4073266-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241107122117.4073266-1-andrew.cooper3@citrix.com> References: <20241107122117.4073266-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: 1730982109938116600 Fold microcode_update_cpu() into its single remaining caller and simplify t= he logic by removing the patch !=3D NULL path with microcode_mutex held. Explain why we bother grabbing the microcode revision even if we can't load microcode. Furthermore, delete the -EIO path. An error updating microcode on AP boot = or S3 resume is certainly bad, but freeing the cache is about the worst possib= le action we can take in response; it prevents subsequent APs from taking an update they might have accepted. This avoids a double collect_cpu_info() call on each AP. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/core.c | 49 +++++++++---------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index d9406ec3fd34..fd4b08b45388 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -263,40 +263,6 @@ static bool cf_check wait_cpu_callout(unsigned int nr) return atomic_read(&cpu_out) >=3D nr; } =20 -/* - * Load a microcode update to current CPU. - * - * If no patch is provided, the cached patch will be loaded. Microcode upd= ate - * during APs bringup and CPU resuming falls into this case. - */ -static int microcode_update_cpu(const struct microcode_patch *patch, - unsigned int flags) -{ - int err; - - alternative_vcall(ucode_ops.collect_cpu_info); - - spin_lock(µcode_mutex); - if ( patch ) - err =3D alternative_call(ucode_ops.apply_microcode, patch, flags); - else if ( microcode_cache ) - { - err =3D alternative_call(ucode_ops.apply_microcode, microcode_cach= e, - flags); - if ( err =3D=3D -EIO ) - { - microcode_free_patch(microcode_cache); - microcode_cache =3D NULL; - } - } - else - /* No patch to update */ - err =3D -ENOENT; - spin_unlock(µcode_mutex); - - return err; -} - static bool wait_for_state(typeof(loading_state) state) { typeof(loading_state) cur_state; @@ -702,13 +668,26 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, /* Load a cached update to current cpu */ int microcode_update_one(void) { + int rc; + + /* + * This path is used for APs and S3 resume. Read the microcode revisi= on + * if possible, even if we can't load microcode. + */ if ( ucode_ops.collect_cpu_info ) alternative_vcall(ucode_ops.collect_cpu_info); =20 if ( !ucode_ops.apply_microcode ) return -EOPNOTSUPP; =20 - return microcode_update_cpu(NULL, 0); + spin_lock(µcode_mutex); + if ( microcode_cache ) + rc =3D alternative_call(ucode_ops.apply_microcode, microcode_cache= , 0); + else + rc =3D -ENOENT; + spin_unlock(µcode_mutex); + + return rc; } =20 /* --=20 2.39.5 From nobody Mon Nov 3 06:35:10 2025 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=1730982108; cv=none; d=zohomail.com; s=zohoarc; b=iz++czTwtskQBdsHCb46ndQUUEO6/U5+q7rZydy+mt1GRJ9NFXyalCYB+t4Qf1xz2OlKMlrjf7ZPeex171dnn+Qsc/xrOo/OlWjBMpIPZOLuZdC134gff+RBBOZiJs+YNculwk5h/5roKWipFAKjpAzhRqLLmSpnzYZEVe8aw9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730982108; 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=dhkaHQoFIRa55JOrJcaTnvyo182cpXRAkClX9uwWjpI=; b=IjsKYWLmr2BBLmHJm4nZuhlaUDmLI+60FYiCSIXBL3ITHa4znQypPnlAtcG/X0yNLtR8kwYp46CB+jbJfDDsOwMF8zLwNlyY8k5C9rtslD49LfhI5EfqqRoZPeACitmP9pS1N0nHuwRcNIuGDSCJwjA1N3n3v7XmqjjowB0S4QU= 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 1730982108225366.01240007416436; Thu, 7 Nov 2024 04:21:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.831766.1247143 (Exim 4.92) (envelope-from ) id 1t91Vv-0003jv-My; Thu, 07 Nov 2024 12:21:27 +0000 Received: by outflank-mailman (output) from mailman id 831766.1247143; Thu, 07 Nov 2024 12:21:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t91Vv-0003jo-JX; Thu, 07 Nov 2024 12:21:27 +0000 Received: by outflank-mailman (input) for mailman id 831766; Thu, 07 Nov 2024 12:21:26 +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 1t91Vu-0003Uc-8N for xen-devel@lists.xenproject.org; Thu, 07 Nov 2024 12:21:26 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cdc17699-9d02-11ef-a0c6-8be0dac302b0; Thu, 07 Nov 2024 13:21:24 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a9ee097a478so39568066b.2 for ; Thu, 07 Nov 2024 04:21:24 -0800 (PST) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf03b5c91esm727688a12.4.2024.11.07.04.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 04:21:22 -0800 (PST) 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: cdc17699-9d02-11ef-a0c6-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo2MmUiLCJoZWxvIjoibWFpbC1lajEteDYyZS5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImNkYzE3Njk5LTlkMDItMTFlZi1hMGM2LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwOTgyMDg0LjA4NzUzOSwic2VuZGVyIjoiYW5kcmV3LmNvb3BlckBjbG91ZC5jb20iLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730982083; x=1731586883; 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=dhkaHQoFIRa55JOrJcaTnvyo182cpXRAkClX9uwWjpI=; b=sO82k5t5Q6dEIqdNrAUES0PJxkdj5oCkKdoq+GZElFsTYIjdjyXjW+6ONieJ12Qcuh gFc7xGMRhhRh7dzqKC+z4wsj94V7xUlY/8hOkSfMhXMlBCq2Q/ygWST+1LRS5YXR1Qmh c1MmweaBw8GZRH94LOhcHkjy9PMFSlX8Bx9Rs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730982083; x=1731586883; 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=dhkaHQoFIRa55JOrJcaTnvyo182cpXRAkClX9uwWjpI=; b=pm4GiG+qeObyx5U0QNQ28ePF8BlR6D03pCta05ItCreKSikHPzejjzcPY+iQ2gZb2l F/SQ5aZPRb0u5KYLAUGJrPEtvHnx7fwZjaTFul/m9QDbDsWlcxmxlYVX5dAzrM4Edp2m PrvOiErm+Hh27Y/P/TZBtj527cGTXIbG+lq4nXVlsQU6HrD/DETwdWITLQ1wUC2szVZh 5KA4lfjpRrKuN+40a0Y+hi+O3ptWnkhnMS8S2VmHO63bZYMcLLNa9j+mZUaHqvuPgS/q RnpfQIpzvK+iIsDQaltI9ip6AAhfP7SMa0sFCkBLY+LqGRBK7jqbkbCzCJz8zYSCyM7V bTxQ== X-Gm-Message-State: AOJu0YxkCgBkyc3lXBb/5UjXE/D06Yr/SII6nY9nZsz+gQmWAIDVtAdm p49xaukRrSlTsm3DZR2PHiWDH9xKy49YJYqt8zHKsPNTZBjSCtVkgTkznhHQ8gkXC5nQ4XtpDqZ l X-Google-Smtp-Source: AGHT+IFYCiJbEL/d67ECmyal5RqaBxk7eAqjmISW2oKfrekMRSrrUF/GI3CDJgtpBs1SzNPvU+rF9Q== X-Received: by 2002:a05:6402:d05:b0:5c9:5745:de9a with SMTP id 4fb4d7f45d1cf-5ceb926152emr19520279a12.9.1730982082892; Thu, 07 Nov 2024 04:21:22 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 3/3] x86/ucode: Remove the collect_cpu_info() call from parse_blob() Date: Thu, 7 Nov 2024 12:21:17 +0000 Message-Id: <20241107122117.4073266-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241107122117.4073266-1-andrew.cooper3@citrix.com> References: <20241107122117.4073266-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: 1730982109934116600 With the tangle of logic starting to come under control, it is now plain to see that parse_blob()'s side effect of re-gathering the signature/revision = is pointless. The cpu_request_microcode() hooks need the signature only. The BSP gathers this in early_microcode_init(), the APs and S3 in microcode_update_cpu(). = For good measure, the apply_microcode() hooks also keep the revision correct as load attempts are made. This finally gets us down to a single call per CPU on boot / S3 resume, and= no calls during late-load hypercalls. No functional change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 Slightly RFC. Just before posting, I've realised that cpu_request_microcode() does actual= ly use the current CPU revision, and it's buggy, and it's the cause of `xen-uc= ode --force` not working as expected. I'm tempted to do another series cleaning that up in isolation, such that t= his patch becomes true in this form. --- xen/arch/x86/cpu/microcode/core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index fd4b08b45388..5897ec54032a 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -189,8 +189,6 @@ static struct patch_with_flags nmi_patch =3D */ static struct microcode_patch *parse_blob(const char *buf, size_t len) { - alternative_vcall(ucode_ops.collect_cpu_info); - return alternative_call(ucode_ops.cpu_request_microcode, buf, len, tru= e); } =20 --=20 2.39.5 From nobody Mon Nov 3 06:35:10 2025 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=1731067997; cv=none; d=zohomail.com; s=zohoarc; b=jgUBh2g/B1nWFOVj6V6grACVItaM0kTWa2F9PdM2ofd6Bc3DAW++LR6whkYyPdm+G00pORSntqqPosoh3y+WsW+vCIyILLaxVuCiBw4tIG0HLKpzlWHEccHFNC7fRibIQXK/QkdCEd2TfrxPzq6kbA/jR1/ufF8O4Vsl9siC0Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731067997; 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=KPl05uDpcIVvTaOJ217rmBk+BiHJABBBSah5zq7hgxc=; b=mNHMpeTzCUp1viUhixXmo8stNupycM++KNFKFGkGYcyir2t5vu+BY8RdAQJh+DkHMsDyWZU2sLC9vBy6dQnBcws/0in4HOJx/ZLayt4/PA8dwTY3pu9d0CiqsswSfqgXMwPG8u3CRbLIdg8iNAA9ek6EZ2gYoBeXZLVepoM2PUc= 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 1731067997644565.2980221211388; Fri, 8 Nov 2024 04:13:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.832528.1247813 (Exim 4.92) (envelope-from ) id 1t9NrA-0006Nj-Jr; Fri, 08 Nov 2024 12:12:52 +0000 Received: by outflank-mailman (output) from mailman id 832528.1247813; Fri, 08 Nov 2024 12:12:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t9NrA-0006Nc-Ft; Fri, 08 Nov 2024 12:12:52 +0000 Received: by outflank-mailman (input) for mailman id 832528; Fri, 08 Nov 2024 12:12:51 +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 1t9Nr9-0006NV-1l for xen-devel@lists.xenproject.org; Fri, 08 Nov 2024 12:12:51 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c33ca85f-9dca-11ef-a0c6-8be0dac302b0; Fri, 08 Nov 2024 13:12:45 +0100 (CET) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a9ed7d8c86cso363153966b.2 for ; Fri, 08 Nov 2024 04:12:45 -0800 (PST) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9ee0a4a988sm223954466b.59.2024.11.08.04.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 04:12:43 -0800 (PST) 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: c33ca85f-9dca-11ef-a0c6-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo2MzYiLCJoZWxvIjoibWFpbC1lajEteDYzNi5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImMzM2NhODVmLTlkY2EtMTFlZi1hMGM2LThiZTBkYWMzMDJiMCIsInRzIjoxNzMxMDY3OTY1Ljc5MTU1Nywic2VuZGVyIjoiYW5kcmV3LmNvb3BlckBjbG91ZC5jb20iLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1731067964; x=1731672764; 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=KPl05uDpcIVvTaOJ217rmBk+BiHJABBBSah5zq7hgxc=; b=A7qjLE6SQ96KJUb3LiKRSDXKg8NWJPwF99rUxlK7R4y8ky4nZj0AuGl/Xr0EY/G2k7 lm9NfaDc0doJspSP4atNE+NzbfKuKxd54V7vIwWsPj3tuKYtnnBsU9eMGysCthhAlfH1 BlioawicSgDGyS48GuW8klodhSrMs4q+7/ofc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731067964; x=1731672764; 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=KPl05uDpcIVvTaOJ217rmBk+BiHJABBBSah5zq7hgxc=; b=XzFHcoD0Mbh37p3upRy4ZY+95rxOzVvTuW0EW96AjU5GZcPepJLBulLCjVXDSdRJgT 3QJyIeUORF/gOZ6Y/wfiqBdGQZN4MpFM1g0V8S14yAMCYum8dC/5fxR7bMhnQZtRuGIY qfRJ+BBselCI3KSI7/5W1nOkfiN9YDFpNcdI0jWbxQGC2x9NlunXgr7IA4dzd+nNO7u3 yYl/b4LX0Kc+16b3miZtjnsjIrNEr//5QZoHMISqUSYXXBVsGcB2SEoSBCqOFKLG7VU/ cQkyihd/0o1Vds0Iyg7/jPi4pFJWQVL9HTKIXNDEHdT/9Au4M56N8PTMDlCcucu7ooZH fQjw== X-Gm-Message-State: AOJu0Yx5wxkXuO+mERVRIcpIrmMMjs7KkGRIAGUOTzAPZTtN8H33yvjU LgXrJQKUlmJkgL7sM9Glxl20EZYYibO2owLEs9pvRme6f4wibw/i16k8hYsJcNVPehsBybf4efW + X-Google-Smtp-Source: AGHT+IHX6d+y0TiDZ7gHyA8K7KonB6rhXBRUeR4cYlqIfXUzM8h/tZnjrWXc3aI4Z4KIgwpBsOu/QA== X-Received: by 2002:a17:907:6d0c:b0:a9e:447b:6f76 with SMTP id a640c23a62f3a-a9eeff38602mr232465866b.31.1731067964142; Fri, 08 Nov 2024 04:12:44 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 4/3] x86/ucode: Fix cache handling in microcode_update_helper() Date: Fri, 8 Nov 2024 12:12:41 +0000 Message-Id: <20241108121241.243945-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241107122117.4073266-1-andrew.cooper3@citrix.com> References: <20241107122117.4073266-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: 1731067999224116600 microcode_update_cache() now has a single caller, but inlining it shows how unnecessarily complicated the logic really is. Outside of error paths, there is always one microcode patch to free. Its either result of parse_blob(), or it's the old cached value. In order to fix this, have a local patch pointer (mostly to avoid the unnecessary verbosity of patch_with_flags.patch), and always free it at the end. The only error path needing care is the IS_ERR(patch) path, which is easy enough to handle. Also, widen the scope of result. We only need to call compare_patch() once, and the answer is still good later when updating the cache. In order to update the cache, simply SWAP() the patch and the cache pointers, allowing = the singular xfree() at the end to cover both cases. This also removes all callers microcode_free_patch() which fixes the need to cast away const to allow it to compile. No functional change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 This is in prepartion to totally overhaul compare_patch(). There's now onl= y a single caller. --- xen/arch/x86/cpu/microcode/core.c | 66 +++++++++++-------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 5897ec54032a..0cc5daa251e2 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -86,7 +86,7 @@ struct patch_with_flags { static bool ucode_in_nmi =3D true; =20 /* Protected by microcode_mutex */ -static const struct microcode_patch *microcode_cache; +static struct microcode_patch *microcode_cache; =20 /* * opt_mod_idx and opt_scan have subtle semantics. @@ -192,33 +192,6 @@ static struct microcode_patch *parse_blob(const char *= buf, size_t len) return alternative_call(ucode_ops.cpu_request_microcode, buf, len, tru= e); } =20 -static void microcode_free_patch(const struct microcode_patch *patch) -{ - xfree((struct microcode_patch *)patch); -} - -/* Return true if cache gets updated. Otherwise, return false */ -static bool microcode_update_cache(const struct microcode_patch *patch) -{ - ASSERT(spin_is_locked(µcode_mutex)); - - if ( !microcode_cache ) - microcode_cache =3D patch; - else if ( alternative_call(ucode_ops.compare_patch, - patch, microcode_cache) =3D=3D NEW_UCODE ) - { - microcode_free_patch(microcode_cache); - microcode_cache =3D patch; - } - else - { - microcode_free_patch(patch); - return false; - } - - return true; -} - /* Returns true if ucode should be loaded on a given cpu */ static bool is_cpu_primary(unsigned int cpu) { @@ -496,6 +469,8 @@ struct ucode_buf { =20 static long cf_check microcode_update_helper(void *data) { + struct microcode_patch *patch =3D NULL; + enum microcode_match_result result; int ret; struct ucode_buf *buffer =3D data; unsigned int cpu, updated; @@ -524,17 +499,20 @@ static long cf_check microcode_update_helper(void *da= ta) goto put; } =20 - patch_with_flags.patch =3D parse_blob(buffer->buffer, buffer->len); + patch =3D parse_blob(buffer->buffer, buffer->len); patch_with_flags.flags =3D buffer->flags; + xfree(buffer); - if ( IS_ERR(patch_with_flags.patch) ) + + if ( IS_ERR(patch) ) { - ret =3D PTR_ERR(patch_with_flags.patch); + ret =3D PTR_ERR(patch); + patch =3D NULL; printk(XENLOG_WARNING "Parsing microcode blob error %d\n", ret); goto put; } =20 - if ( !patch_with_flags.patch ) + if ( !patch ) { printk(XENLOG_WARNING "microcode: couldn't find any matching ucode= in " "the provided blob!\n"); @@ -549,10 +527,7 @@ static long cf_check microcode_update_helper(void *dat= a) spin_lock(µcode_mutex); if ( microcode_cache ) { - enum microcode_match_result result; - - result =3D alternative_call(ucode_ops.compare_patch, - patch_with_flags.patch, microcode_cache); + result =3D alternative_call(ucode_ops.compare_patch, patch, microc= ode_cache); =20 if ( result !=3D NEW_UCODE && !(ucode_force && (result =3D=3D OLD_UCODE || result =3D=3D SA= ME_UCODE)) ) @@ -561,12 +536,13 @@ static long cf_check microcode_update_helper(void *da= ta) printk(XENLOG_WARNING "microcode: couldn't find any newer%s revision in the p= rovided blob!\n", ucode_force ? " (or a valid)" : ""); - microcode_free_patch(patch_with_flags.patch); ret =3D -EEXIST; =20 goto put; } } + else + result =3D NEW_UCODE; spin_unlock(µcode_mutex); =20 cpumask_clear(&cpu_callin_map); @@ -593,14 +569,18 @@ static long cf_check microcode_update_helper(void *da= ta) * this requirement can be relaxed in the future. Right now, this is * conservative and good. */ + patch_with_flags.patch =3D patch; ret =3D stop_machine_run(do_microcode_update, &patch_with_flags, NR_CP= US); =20 updated =3D atomic_read(&cpu_updated); if ( updated > 0 ) { - spin_lock(µcode_mutex); - microcode_update_cache(patch_with_flags.patch); - spin_unlock(µcode_mutex); + if ( result =3D=3D NEW_UCODE ) + { + spin_lock(µcode_mutex); + SWAP(patch, microcode_cache); + spin_unlock(µcode_mutex); + } =20 /* * Refresh the raw CPU policy, in case the features have changed. @@ -615,8 +595,6 @@ static long cf_check microcode_update_helper(void *data) if ( ctxt_switch_masking ) alternative_vcall(ctxt_switch_masking, current); } - else - microcode_free_patch(patch_with_flags.patch); =20 if ( updated && updated !=3D nr_cores ) printk(XENLOG_ERR "ERROR: Updating microcode succeeded on %u cores= and failed\n" @@ -627,6 +605,10 @@ static long cf_check microcode_update_helper(void *dat= a) =20 put: put_cpu_maps(); + + /* The parsed blob or old cached value, whichever we're not keeping. */ + xfree(patch); + return ret; } =20 --=20 2.39.5