}
 early_initcall(save_microcode_in_initrd);
 
-static inline bool patch_cpus_equivalent(struct ucode_patch *p, struct ucode_patch *n)
+static inline bool patch_cpus_equivalent(struct ucode_patch *p,
+                                        struct ucode_patch *n,
+                                        bool ignore_stepping)
 {
        /* Zen and newer hardcode the f/m/s in the patch ID */
         if (x86_family(bsp_cpuid_1_eax) >= 0x17) {
                union cpuid_1_eax p_cid = ucode_rev_to_cpuid(p->patch_id);
                union cpuid_1_eax n_cid = ucode_rev_to_cpuid(n->patch_id);
 
-               /* Zap stepping */
-               p_cid.stepping = 0;
-               n_cid.stepping = 0;
+               if (ignore_stepping) {
+                       p_cid.stepping = 0;
+                       n_cid.stepping = 0;
+               }
 
                return p_cid.full == n_cid.full;
        } else {
        WARN_ON_ONCE(!n.patch_id);
 
        list_for_each_entry(p, µcode_cache, plist)
-               if (patch_cpus_equivalent(p, &n))
+               if (patch_cpus_equivalent(p, &n, false))
                        return p;
 
        return NULL;
 }
 
-static inline bool patch_newer(struct ucode_patch *p, struct ucode_patch *n)
+static inline int patch_newer(struct ucode_patch *p, struct ucode_patch *n)
 {
        /* Zen and newer hardcode the f/m/s in the patch ID */
         if (x86_family(bsp_cpuid_1_eax) >= 0x17) {
                zp.ucode_rev = p->patch_id;
                zn.ucode_rev = n->patch_id;
 
+               if (zn.stepping != zp.stepping)
+                       return -1;
+
                return zn.rev > zp.rev;
        } else {
                return n->patch_id > p->patch_id;
 static void update_cache(struct ucode_patch *new_patch)
 {
        struct ucode_patch *p;
+       int ret;
 
        list_for_each_entry(p, µcode_cache, plist) {
-               if (patch_cpus_equivalent(p, new_patch)) {
-                       if (!patch_newer(p, new_patch)) {
+               if (patch_cpus_equivalent(p, new_patch, true)) {
+                       ret = patch_newer(p, new_patch);
+                       if (ret < 0)
+                               continue;
+                       else if (!ret) {
                                /* we already have the latest patch */
                                kfree(new_patch->data);
                                kfree(new_patch);