Commit 917ea427 authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Drivers: hv: Setup a mapping for Hyper-V's notion cpu ID

On win8 (ws2012), incoming vmbus interrupt load can be spread across all
available VCPUs in the guest. On a per-channel basis, the interrupts can
be bound to specific CPUs. The Linux notion of cpu ID may be different
from that of the hypervisor's. Setup a mapping structure.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3be77774
...@@ -137,6 +137,8 @@ int hv_init(void) ...@@ -137,6 +137,8 @@ int hv_init(void)
memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS); memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
memset(hv_context.synic_message_page, 0, memset(hv_context.synic_message_page, 0,
sizeof(void *) * NR_CPUS); sizeof(void *) * NR_CPUS);
memset(hv_context.vp_index, 0,
sizeof(int) * NR_CPUS);
max_leaf = query_hypervisor_info(); max_leaf = query_hypervisor_info();
...@@ -296,6 +298,7 @@ void hv_synic_init(void *irqarg) ...@@ -296,6 +298,7 @@ void hv_synic_init(void *irqarg)
union hv_synic_siefp siefp; union hv_synic_siefp siefp;
union hv_synic_sint shared_sint; union hv_synic_sint shared_sint;
union hv_synic_scontrol sctrl; union hv_synic_scontrol sctrl;
u64 vp_index;
u32 irq_vector = *((u32 *)(irqarg)); u32 irq_vector = *((u32 *)(irqarg));
int cpu = smp_processor_id(); int cpu = smp_processor_id();
...@@ -355,6 +358,14 @@ void hv_synic_init(void *irqarg) ...@@ -355,6 +358,14 @@ void hv_synic_init(void *irqarg)
wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64); wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
hv_context.synic_initialized = true; hv_context.synic_initialized = true;
/*
* Setup the mapping between Hyper-V's notion
* of cpuid and Linux' notion of cpuid.
* This array will be indexed using Linux cpuid.
*/
rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
hv_context.vp_index[cpu] = (u32)vp_index;
return; return;
cleanup: cleanup:
......
...@@ -502,6 +502,16 @@ struct hv_context { ...@@ -502,6 +502,16 @@ struct hv_context {
void *synic_message_page[NR_CPUS]; void *synic_message_page[NR_CPUS];
void *synic_event_page[NR_CPUS]; void *synic_event_page[NR_CPUS];
/*
* Hypervisor's notion of virtual processor ID is different from
* Linux' notion of CPU ID. This information can only be retrieved
* in the context of the calling CPU. Setup a map for easy access
* to this information:
*
* vp_index[a] is the Hyper-V's processor ID corresponding to
* Linux cpuid 'a'.
*/
u32 vp_index[NR_CPUS];
}; };
extern struct hv_context hv_context; extern struct hv_context hv_context;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment