Index: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c =================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c @@ -32,7 +32,8 @@ #include #include -#include "hv_vmbus_priv.h" +#include +#include /* * Internal functions @@ -301,7 +302,7 @@ KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); chan->target_cpu = cpu; - chan->target_vcpu = hv_vmbus_g_context.hv_vcpu_index[cpu]; + chan->target_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, cpu); if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", @@ -744,7 +745,7 @@ return outgoing_channel; } - cur_vcpu = hv_vmbus_g_context.hv_vcpu_index[smp_pro_id]; + cur_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, smp_pro_id); TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { if (new_channel->state != HV_CHANNEL_OPENED_STATE){ Index: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c =================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c +++ head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c @@ -213,7 +213,6 @@ { struct vmbus_softc *sc = vmbus_get_softc(); int cpu; - uint64_t hv_vcpu_index; hv_vmbus_synic_simp simp; hv_vmbus_synic_siefp siefp; hv_vmbus_synic_scontrol sctrl; @@ -271,8 +270,7 @@ * Set up the cpuid mapping from Hyper-V to FreeBSD. * The array is indexed using FreeBSD cpuid. */ - hv_vcpu_index = rdmsr(HV_X64_MSR_VP_INDEX); - hv_vmbus_g_context.hv_vcpu_index[cpu] = (uint32_t)hv_vcpu_index; + VMBUS_PCPU_GET(sc, vcpuid, cpu) = rdmsr(HV_X64_MSR_VP_INDEX); } static void Index: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h =================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h +++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h @@ -202,11 +202,6 @@ typedef struct { hv_bool_uint8_t syn_ic_initialized; - - /* - * For FreeBSD cpuid to Hyper-V vcpuid mapping. - */ - uint32_t hv_vcpu_index[MAXCPU]; } hv_vmbus_context; /* Index: head/sys/dev/hyperv/vmbus/vmbus_var.h =================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_var.h +++ head/sys/dev/hyperv/vmbus/vmbus_var.h @@ -36,6 +36,7 @@ struct vmbus_pcpu_data { u_long *intr_cnt; /* Hyper-V interrupt counter */ struct vmbus_message *message; /* shared messages */ + uint32_t vcpuid; /* virtual cpuid */ int event_flag_cnt; /* # of event flags */ union vmbus_event_flags *event_flag; /* shared event flags */