From nobody Fri Nov 22 02:23:48 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=1730107180; cv=none; d=zohomail.com; s=zohoarc; b=OogWs9AiKU7YmF/mNwUoQE/9efIzUQpRw0WPuppJ3qsTh3+PTd6VwzCypQz6+qDAs9IaJ1UJjbIdfhhAnDlZS9ldctx1Bi8FsQTQQUDoJ4b1CwuLj47XZY+BoDOkQFnWb30YUQeKZOb9T5WUU1jIIDaQZkUmZC4SGInLpkaJdiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730107180; 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=N3hciQ8Ka+dHVzkGgN9t9G2Trm/MbifcubSrtXUCw+M=; b=gRcBYFMVxviCATB1AGoFRfOBF0NwuaGcP8AMmPAabIRLOTSnBr9c1p/iSh4Y+StSJVoaig51QtmHaAJrEaQnR0MI77zEzoe7G5rtyHWGmprkfz4klepEW05yLP1Us+r23+h5hvXKLgmjzmcaxfMRKSrMpHcfbERwvYWHStO+f1k= 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 1730107180382364.79176038389176; Mon, 28 Oct 2024 02:19:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.826303.1240581 (Exim 4.92) (envelope-from ) id 1t5LuB-0007uO-RD; Mon, 28 Oct 2024 09:19:19 +0000 Received: by outflank-mailman (output) from mailman id 826303.1240581; Mon, 28 Oct 2024 09:19:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5LuB-0007tF-Ko; Mon, 28 Oct 2024 09:19:19 +0000 Received: by outflank-mailman (input) for mailman id 826303; Mon, 28 Oct 2024 09:19:18 +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 1t5LuA-0005yk-C6 for xen-devel@lists.xenproject.org; Mon, 28 Oct 2024 09:19:18 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b3ffc1e0-950d-11ef-99a3-01e77a169b0f; Mon, 28 Oct 2024 10:19:16 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a9a16b310f5so631781666b.0 for ; Mon, 28 Oct 2024 02:19:16 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f05deb6sm355961566b.88.2024.10.28.02.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 02:19: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: b3ffc1e0-950d-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730107154; x=1730711954; 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=N3hciQ8Ka+dHVzkGgN9t9G2Trm/MbifcubSrtXUCw+M=; b=IXwUuC1xzv8NPdzys5H0aWul5/OF4Xv76JNr0xYLz/ufgtv8SREikhHlS6ztVUWaZc n9P+0WoGgN8Y6+fLzsbOZsj0VGKkSrfgbaq4udZUwIAAm/HKMCFWuUyUeT73cEEaFHIK LxMhfHYDjNPp1+6iai6n+VBFf/fp7u9vsiw5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730107154; x=1730711954; 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=N3hciQ8Ka+dHVzkGgN9t9G2Trm/MbifcubSrtXUCw+M=; b=gJDgzEDKgaOAEzc6kqNAe0z+VG4CpaXNYRaq+WMwtgh9PshtDJ/9CzhqIE6e6yQTiG WcwqpK+lSlwjUgod+4R23UUypRzXW0/yqGTZ+3gOBF/dK8UOrJaT0OZELgmheYp5HY/m FYwBBSxbWkztc3WIZmxy/CKXQuxspc6yxmVzaTUPYxSSPPSP6/DuAGAyPqNN0gAuvsLU RHlw0QUEWsKZHkuskdgqb3AlDY3Dxn1GovvprD03hg8o9rb3wMdiMd8sv4RdEEK+Dbo4 1qy5TrLAtR7dgy2w/F2/7qsm/Gfd5IUzoLroCfG2Q4ZLsrzy2m7eBPff5FQNwZbecKyJ +HuA== X-Gm-Message-State: AOJu0YxXvluYhcvfdjYydUZvqD+nJ8HsEXbSiAPcX37lJTTquGqNljpZ xn/5vsOjcz2dhBOSe1fLmG3RAAFyhUieN/7kfj/CtWtjjGhJ1nULyfoHh4n729Abtm4VkjaTviT Y X-Google-Smtp-Source: AGHT+IHDTU7KYy6C7gkSIvfD0SXzraoTh+peLzg0SM8iNtvWnEKHnonHgd6RuBE5i3u2p+RDyGorCQ== X-Received: by 2002:a17:907:7284:b0:a9a:6ab:c93b with SMTP id a640c23a62f3a-a9de62ec47fmr687812466b.62.1730107154586; Mon, 28 Oct 2024 02:19:14 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Daniel P . Smith" Subject: [PATCH 10/10] x86/ucode: Fold early_update_cache() into its single caller Date: Mon, 28 Oct 2024 09:18:56 +0000 Message-Id: <20241028091856.2151603-11-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241028091856.2151603-1-andrew.cooper3@citrix.com> References: <20241028091856.2151603-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: 1730107181343116600 The data pointer is known good, so the -ENOMEM path is unnecessary. Howeve= r, if we find no patch, something's wrong seeing as early_microcode_init() indicated it was happy. We are the entity initialising the cache, so we don't need the complexity of using microcode_update_cache(). Just assert the cache is empty, and popula= te it. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 47 +++++++++++++------------------ 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 591c13ad91fb..90a6f2bd87ae 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -707,33 +707,6 @@ int microcode_update_one(void) return microcode_update_cpu(NULL, 0); } =20 -static int __init early_update_cache(const void *data, size_t len) -{ - int rc =3D 0; - struct microcode_patch *patch; - - if ( !data ) - return -ENOMEM; - - patch =3D parse_blob(data, len); - if ( IS_ERR(patch) ) - { - printk(XENLOG_WARNING "Parsing microcode blob error %ld\n", - PTR_ERR(patch)); - return PTR_ERR(patch); - } - - if ( !patch ) - return -ENOENT; - - spin_lock(µcode_mutex); - rc =3D microcode_update_cache(patch); - spin_unlock(µcode_mutex); - ASSERT(rc); - - return rc; -} - /* * Set by early_microcode_load() to indicate where it found microcode, so * microcode_init_cache() can find it again and initalise the cache. opt_= scan @@ -744,6 +717,7 @@ static int __initdata early_mod_idx =3D -1; static int __init cf_check microcode_init_cache(void) { struct boot_info *bi =3D &xen_boot_info; + struct microcode_patch *patch; void *data; size_t size; int rc =3D 0; @@ -774,7 +748,24 @@ static int __init cf_check microcode_init_cache(void) size =3D cd.size; } =20 - rc =3D early_update_cache(data, size); + patch =3D parse_blob(data, size); + if ( IS_ERR(patch) ) + { + rc =3D PTR_ERR(patch); + printk(XENLOG_WARNING "Microcode: Parse error %d\n", rc); + return rc; + } + + if ( !patch ) + { + printk(XENLOG_WARNING "Microcode: No suitable patch found\n"); + return -ENOENT; + } + + spin_lock(µcode_mutex); + ASSERT(microcode_cache =3D=3D NULL); + microcode_cache =3D patch; + spin_unlock(µcode_mutex); =20 return rc; } --=20 2.39.5