From nobody Thu May 2 10:45:46 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=1679694325; cv=none; d=zohomail.com; s=zohoarc; b=l7mzFckpczy2hhrdvL0hRr8ACQuA7UTeK4ScR6dd/GmWJWE6AljGBNwD1UcCZe1j3IO5G121RgH87KepRUZfCv/7/PF2bICai8DkuAV5tbt5qvWnun15VVQf+mv+sikxVldUT9341dBeAQPYXrczmjxsoFMJTDED7Or8bHk8Isc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679694325; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tPVBAoeezqU2hKEBkm8v+BSl+jiQQHQExrLohhfEDAQ=; b=TsQfd+h2T6f3VF0s57d6O6Uz0E1n225LPE6o5p7XJG/gIhKTHqe6YYC6Y0cYBZhVdHbtWwIYKaG/LRnCzfuHqrfHD7YuiTVXFUZ8ZcqkhMAQp5nj0S3mIG1zRtXqPP00DdOTw/31JXa3MQzbCLs0mppOLD54KAyZ11by07zmbrI= 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 167969432592913.96090689066898; Fri, 24 Mar 2023 14:45:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.514462.796720 (Exim 4.92) (envelope-from ) id 1pfpDS-0001mm-TF; Fri, 24 Mar 2023 21:44:54 +0000 Received: by outflank-mailman (output) from mailman id 514462.796720; Fri, 24 Mar 2023 21:44:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pfpDS-0001mf-P6; Fri, 24 Mar 2023 21:44:54 +0000 Received: by outflank-mailman (input) for mailman id 514462; Fri, 24 Mar 2023 21:44:53 +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 1pfpDR-0001mX-Co for xen-devel@lists.xenproject.org; Fri, 24 Mar 2023 21:44:53 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1754ef46-ca8d-11ed-b464-930f4c7d94ae; Fri, 24 Mar 2023 22:44:47 +0100 (CET) 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: 1754ef46-ca8d-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1679694287; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hwqhceVCgJAHDmKYPj//gEgTAp3CMZ020MxdnHTp51Y=; b=XYqFRDstAgEU+ve7q3VUK/hUMkvqQ4qYbbIRnPNJVvMrgQoiw1HevLY/ yPOexod4f+xXPsZgLxC0eHazmjU4BXB1ZVsKwae+igLinicUXwCiOKS2W TZVIOWbdBgRffEfgCNMhLP2tviL6V9zI9u91DnrpiNnnFph1L5XO1GWiF 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 102189981 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:7ZVrhq/KfH1qMY4GJjuTDrUD/H6TJUtcMsCJ2f8bNWPcYEJGY0x3m mtLC2nQaKqDZTT8eY0nOdm19k5U7MDcmtVqT1E6pHg8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmPqoX5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklL2 a1BCAopZSy8gvm44qiKeMV0huAKeZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGOkcUUrsUIMtWcOOAr3/zaTBH7nmSorI6+TP7xw1tyrn9dtHSf7RmQO0MxhzB9 jOXrz2R7hcyDv2DyT+50i2QherrvHriQtMVRZLn6as/6LGU7jNKU0BHPbehmtGph0j7V99BJ kg8/is1sbN05EGtVsP6XRCzvDiDpBF0c/h6HvA+6QqN4rHJ+AvfDW8BJhZebPQ2uclwQiYlv mJlhPuwW2Yp6ufMDyvAqPHN92ja1TUpwXEqYANVFCs/x9Lfn4QogDDVf+RPCK6Rp4igcd3v+ AxmvBTSlp1K05Faifvmpwuf696/jsOXF1Bov207Skrgt1okP9D9OuRE/HCBtZ59wJClok5tV ZTus+yX96gwAJ6Ej0Rhq81dTejyt55p3NAx6GOD/qXNFBz3oRZPhagKvFlDyL5Ba67ogwPBb k7Joh9275ROJnasZqIfS9vvVJV0nfO4TIW+D628gj9yjn9ZKme6ENxGPxbMjwgBbmB1+U3AB XtrWZn1VitLYUiW5DG3W/0cwdcW+8zK/kuKHcqT503+gdKjiIu9Fe9t3K2mMrpos8tpYWz9r 75iCid940oBC7KkMnGOq+b+7zkidBAGOHw/kOQPHsbrH+asMD1xYxMN6dvNo7BYopk= IronPort-HdrOrdr: A9a23:j5ehD64e89Enr83QPwPXwA/XdLJyesId70hD6qhwISYlFPBw9v rPoB1/73TJYVkqOU3I9erwXZVoIkmsjKKdg7NhRYtKNTOO0ATHEGgL1/qY/9SKIVybygcy79 YGT4FOTPDLIBxdq+2S2mWF+tAbquWvweSTqd2b5VFLYiFFV5pJ0ideLUKgPnAefngkObMJUJ Wd48ZcpymtYx0sA/iTDGUeQu7Gq8bqufvdEHw7OyI= X-IronPort-AV: E=Sophos;i="5.98,288,1673931600"; d="scan'208";a="102189981" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Sergey Dyasli Subject: [PATCH] x86/ucode: Fix error paths control_thread_fn() Date: Fri, 24 Mar 2023 21:44:30 +0000 Message-ID: <20230324214430.3277862-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 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: 1679694327871100001 These two early exits skipped re-enabling the watchdog, and restoring the N= MI callback. Always execute the tail of the function on the way out. Fixes: 8dd4dfa92d62 ("x86/microcode: Synchronize late microcode loading") Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Sergey Dyasli --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Sergey Dyasli Also, added in the same patch is: * Note that RDTSC (in wait_for_condition()) is safe for threads to * execute while waiting for completion of loading an update. which is absolutely not true in the slightest. RDTSC is all microcode, and Intel's guidance on the matter right now is that LFENCE is about the only s= afe instruction to execute in a wait loop. Even PAUSE is explcitily prohibited= ... --- xen/arch/x86/cpu/microcode/core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index cfa2d5053a52..61cd36d601d6 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -492,10 +492,7 @@ static int control_thread_fn(const struct microcode_pa= tch *patch) ret =3D wait_for_condition(wait_cpu_callin, num_online_cpus(), MICROCODE_CALLIN_TIMEOUT_US); if ( ret ) - { - set_state(LOADING_EXIT); - return ret; - } + goto out; =20 /* Control thread loads ucode first while others are in NMI handler. */ ret =3D alternative_call(ucode_ops.apply_microcode, patch); @@ -507,8 +504,7 @@ static int control_thread_fn(const struct microcode_pat= ch *patch) { printk(XENLOG_ERR "Late loading aborted: CPU%u failed to update ucode\n", cpu= ); - set_state(LOADING_EXIT); - return ret; + goto out; } =20 /* Let primary threads load the given ucode update */ @@ -539,6 +535,7 @@ static int control_thread_fn(const struct microcode_pat= ch *patch) } } =20 + out: /* Mark loading is done to unblock other threads */ set_state(LOADING_EXIT); =20 --=20 2.30.2