[PATCH 2/3] x86/ucode: Drop structurally unreachable ASSERT()s

Andrew Cooper posted 3 patches 1 day, 3 hours ago
[PATCH 2/3] x86/ucode: Drop structurally unreachable ASSERT()s
Posted by Andrew Cooper 1 day, 3 hours ago
It's impossible for wait_for_state() to return false when looking for
LOADING_EXIT, so much so that the optimiser can drop the ASSERT()s.

No functional change.

Fixes: 5ed12565aa32 ("microcode: rendezvous CPUs in NMI handler and load ucode")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/cpu/microcode/core.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index ecee400f28a6..7aaf62839f56 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -320,12 +320,10 @@ static int secondary_thread_fn(void)
     self_nmi();
 
     /*
-     * Wait for ucode loading is done in case that the NMI does not arrive
-     * synchronously, which may lead to a not-yet-updated CPU signature is
-     * copied below.
+     * NMIs may not be delivered synchronously.  Wait for the primary threads
+     * to be done.
      */
-    if ( unlikely(!wait_for_state(LOADING_EXIT)) )
-        ASSERT_UNREACHABLE();
+    wait_for_state(LOADING_EXIT);
 
     /* Copy update revision from the primary thread. */
     this_cpu(cpu_sig).rev =
@@ -345,12 +343,10 @@ static int primary_thread_fn(const struct microcode_patch *patch,
         self_nmi();
 
         /*
-         * Wait for ucode loading is done in case that the NMI does not arrive
-         * synchronously, which may lead to a not-yet-updated error is returned
-         * below.
+         * NMIs may not be delivered synchronously.  Wait for the primary
+         * threads to be done.
          */
-        if ( unlikely(!wait_for_state(LOADING_EXIT)) )
-            ASSERT_UNREACHABLE();
+        wait_for_state(LOADING_EXIT);
 
         return this_cpu(loading_err);
     }
-- 
2.39.5


Re: [PATCH 2/3] x86/ucode: Drop structurally unreachable ASSERT()s
Posted by Jan Beulich 18 hours ago
On 17.11.2025 23:21, Andrew Cooper wrote:
> It's impossible for wait_for_state() to return false when looking for
> LOADING_EXIT, so much so that the optimiser can drop the ASSERT()s.
> 
> No functional change.
> 
> Fixes: 5ed12565aa32 ("microcode: rendezvous CPUs in NMI handler and load ucode")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Besides helping code clarity, mainly a Misra fix as it looks (unreachable
code).

Jan