Skip to contentSkip to conversation

x86/ucode: Distinguish "ucode already up to date"

PATCH In review Andrew Cooper 2 participants 2 messages May 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ucode: Distinguish "ucode already up to date"

Right now, Xen returns -ENOENT for both "the provided blob isn't correct for this CPU", and "the blob isn't newer than what's loaded".

This in turn causes xen-ucode to exit with an error, when "nothing to do" is more commonly a success condition.

Handle EEXIST specially and exit cleanly.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 tools/misc/xen-ucode.c            | 5 ++++-
 xen/arch/x86/cpu/microcode/core.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
tools/misc/xen-ucode.c +4 -1
index c6ae6498d659..390969db3d1c 100644
@@ -125,8 +125,11 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    errno = 0;
     ret = xc_microcode_update(xch, buf, len);
-    if ( ret )
+    if ( ret == -1 && errno == EEXIST )
+        printf("Microcode already up to date\n");
+    else if ( ret )
     {
         fprintf(stderr, "Failed to update microcode. (err: %s)\n",
                 strerror(errno));
xen/arch/x86/cpu/microcode/core.c +1 -1
index e738a88f5cd1..762111838f5f 100644
@@ -640,7 +640,7 @@ static long cf_check microcode_update_helper(void *data)
                    "microcode: couldn't find any newer%s revision in the provided blob!\n",
                    opt_ucode_allow_same ? " (or the same)" : "");
             microcode_free_patch(patch);
-            ret = -ENOENT;
+            ret = -EEXIST;
 
             goto put;
         }

base-commit: a2330b51df267e20e66bbba6c5bf08f0570ed58b

Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrew Cooper

Right now, Xen returns -ENOENT for both "the provided blob isn't correct for this CPU", and "the blob isn't newer than what's loaded".

This in turn causes xen-ucode to exit with an error, when "nothing to do" is more commonly a success condition.

Handle EEXIST specially and exit cleanly.

Thanks.