diff options
Diffstat (limited to 'sys/dev/cpuctl/cpuctl.c')
-rw-r--r-- | sys/dev/cpuctl/cpuctl.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/cpuctl/cpuctl.c b/sys/dev/cpuctl/cpuctl.c index 9253b17a259d..deaabaaaa1fc 100644 --- a/sys/dev/cpuctl/cpuctl.c +++ b/sys/dev/cpuctl/cpuctl.c @@ -344,7 +344,7 @@ ucode_intel_load_rv(void *arg) d = arg; if (PCPU_GET(cpuid) == d->cpu) - d->ret = ucode_intel_load(d->ptr, true, NULL, NULL); + d->ret = ucode_intel_load(d->ptr, SAFE, NULL, NULL); } static int @@ -402,19 +402,20 @@ out: * its workings. */ static void -amd_ucode_wrmsr(void *ucode_ptr) +amd_ucode_wrmsr(void *arg) { + struct ucode_update_data *d = arg; uint32_t tmp[4]; - wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)ucode_ptr); + if (PCPU_GET(cpuid) == d->cpu) + d->ret = wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)d->ptr); do_cpuid(0, tmp); } static int update_amd(int cpu, cpuctl_update_args_t *args, struct thread *td) { - void *ptr; - int ret; + struct ucode_update_data d = { .cpu = cpu }; if (args->size == 0 || args->data == NULL) { DPRINTF("[cpuctl,%d]: zero-sized firmware image", __LINE__); @@ -430,18 +431,17 @@ update_amd(int cpu, cpuctl_update_args_t *args, struct thread *td) * malloc(9) always returns the pointer aligned at least on * the size of the allocation. */ - ptr = malloc(args->size + 16, M_CPUCTL, M_ZERO | M_WAITOK); - if (copyin(args->data, ptr, args->size) != 0) { + d.ptr = malloc(args->size + 16, M_CPUCTL, M_ZERO | M_WAITOK); + if (copyin(args->data, d.ptr, args->size) != 0) { DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed", __LINE__, args->data, ptr, args->size); - ret = EFAULT; + d.ret = EFAULT; goto fail; } - smp_rendezvous(NULL, amd_ucode_wrmsr, NULL, ptr); - ret = 0; + smp_rendezvous(NULL, amd_ucode_wrmsr, NULL, &d); fail: - free(ptr, M_CPUCTL); - return (ret); + free(d.ptr, M_CPUCTL); + return (d.ret); } static int |