* 2 of the License, or (at your option) any later version.
*/
+#include <xen/alternative-call.h>
#include <xen/cpu.h>
#include <xen/earlycpio.h>
#include <xen/err.h>
microcode_scan_module(module_map, mbi);
}
-static const struct microcode_ops __read_mostly *microcode_ops;
+static struct microcode_ops __ro_after_init ucode_ops;
static DEFINE_SPINLOCK(microcode_mutex);
*/
static struct microcode_patch *parse_blob(const char *buf, size_t len)
{
- microcode_ops->collect_cpu_info();
+ alternative_vcall(ucode_ops.collect_cpu_info);
- return microcode_ops->cpu_request_microcode(buf, len);
+ return alternative_call(ucode_ops.cpu_request_microcode, buf, len);
}
static void microcode_free_patch(struct microcode_patch *patch)
if ( !microcode_cache )
microcode_cache = patch;
- else if ( microcode_ops->compare_patch(patch,
- microcode_cache) == NEW_UCODE )
+ else if ( alternative_call(ucode_ops.compare_patch,
+ patch, microcode_cache) == NEW_UCODE )
{
microcode_free_patch(microcode_cache);
microcode_cache = patch;
{
int err;
- microcode_ops->collect_cpu_info();
+ alternative_vcall(ucode_ops.collect_cpu_info);
spin_lock(µcode_mutex);
if ( patch )
- err = microcode_ops->apply_microcode(patch);
+ err = alternative_call(ucode_ops.apply_microcode, patch);
else if ( microcode_cache )
{
- err = microcode_ops->apply_microcode(microcode_cache);
+ err = alternative_call(ucode_ops.apply_microcode, microcode_cache);
if ( err == -EIO )
{
microcode_free_patch(microcode_cache);
if ( !wait_for_state(LOADING_ENTER) )
return -EBUSY;
- ret = microcode_ops->apply_microcode(patch);
+ ret = alternative_call(ucode_ops.apply_microcode, patch);
if ( !ret )
atomic_inc(&cpu_updated);
atomic_inc(&cpu_out);
}
/* Control thread loads ucode first while others are in NMI handler. */
- ret = microcode_ops->apply_microcode(patch);
+ ret = alternative_call(ucode_ops.apply_microcode, patch);
if ( !ret )
atomic_inc(&cpu_updated);
atomic_inc(&cpu_out);
*/
spin_lock(µcode_mutex);
if ( microcode_cache &&
- microcode_ops->compare_patch(patch, microcode_cache) != NEW_UCODE )
+ alternative_call(ucode_ops.compare_patch,
+ patch, microcode_cache) != NEW_UCODE )
{
spin_unlock(µcode_mutex);
printk(XENLOG_WARNING "microcode: couldn't find any newer revision "
if ( len != (uint32_t)len )
return -E2BIG;
- if ( microcode_ops == NULL )
+ if ( !ucode_ops.apply_microcode )
return -EINVAL;
buffer = xmalloc_flex_struct(struct ucode_buf, buffer, len);
/* Load a cached update to current cpu */
int microcode_update_one(void)
{
- if ( !microcode_ops )
+ if ( !ucode_ops.apply_microcode )
return -EOPNOTSUPP;
- microcode_ops->collect_cpu_info();
+ alternative_vcall(ucode_ops.collect_cpu_info);
return microcode_update_cpu(NULL);
}
{
case X86_VENDOR_AMD:
if ( c->x86 >= 0x10 )
- microcode_ops = &amd_ucode_ops;
+ ucode_ops = amd_ucode_ops;
break;
case X86_VENDOR_INTEL:
if ( c->x86 >= 6 )
- microcode_ops = &intel_ucode_ops;
+ ucode_ops = intel_ucode_ops;
break;
}
- if ( !microcode_ops )
+ if ( !ucode_ops.apply_microcode )
{
printk(XENLOG_WARNING "Microcode loading not available\n");
return -ENODEV;
}
- microcode_ops->collect_cpu_info();
+ alternative_vcall(ucode_ops.collect_cpu_info);
if ( ucode_mod.mod_end || ucode_blob.size )
rc = early_microcode_update_cpu();