return OLD_UCODE;
}
-/* Check an update against the CPU signature and current update revision */
-static enum microcode_match_result microcode_update_match(
- const struct microcode_patch *mc)
+/* Check whether this microcode patch is applicable for the current CPU. */
+static bool microcode_fits_cpu(const struct microcode_patch *mc)
{
const struct extended_sigtable *ext;
unsigned int i;
/* Check the main microcode signature. */
if ( signature_matches(cpu_sig, mc->sig, mc->pf) )
- goto found;
+ return true;
/* If there is an extended signature table, check each of them. */
if ( (ext = get_ext_sigtable(mc)) != NULL )
for ( i = 0; i < ext->count; ++i )
if ( signature_matches(cpu_sig, ext->sigs[i].sig, ext->sigs[i].pf) )
- goto found;
-
- return MIS_UCODE;
+ return true;
- found:
- return compare_revisions(cpu_sig->rev, mc->rev);
+ return false;
}
static enum microcode_match_result cf_check compare_patch(
* Both patches to compare are supposed to be applicable to local CPU.
* Just compare the revision number.
*/
- ASSERT(microcode_update_match(old) != MIS_UCODE);
- ASSERT(microcode_update_match(new) != MIS_UCODE);
+ ASSERT(microcode_fits_cpu(old));
+ ASSERT(microcode_fits_cpu(new));
return compare_revisions(old->rev, new->rev);
}
enum microcode_match_result result;
bool ucode_force = flags & XENPF_UCODE_FORCE;
- result = microcode_update_match(patch);
-
- if ( result == MIS_UCODE )
+ if ( !microcode_fits_cpu(patch) )
return -EINVAL;
+ result = compare_revisions(old_rev, patch->rev);
+
if ( !ucode_force && (result == SAME_UCODE || result == OLD_UCODE) )
return -EEXIST;
* If the new update covers current CPU, compare updates and store the
* one with higher revision.
*/
- if ( (microcode_update_match(mc) != MIS_UCODE) &&
+ if ( microcode_fits_cpu(mc) &&
(!saved || compare_revisions(saved->rev, mc->rev) == NEW_UCODE) )
saved = mc;