aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hv/hv.c11
-rw-r--r--drivers/hv/hyperv_vmbus.h10
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index dd0af8940657..76304a622140 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -137,6 +137,8 @@ int hv_init(void)
137 memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS); 137 memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
138 memset(hv_context.synic_message_page, 0, 138 memset(hv_context.synic_message_page, 0,
139 sizeof(void *) * NR_CPUS); 139 sizeof(void *) * NR_CPUS);
140 memset(hv_context.vp_index, 0,
141 sizeof(int) * NR_CPUS);
140 142
141 max_leaf = query_hypervisor_info(); 143 max_leaf = query_hypervisor_info();
142 144
@@ -296,6 +298,7 @@ void hv_synic_init(void *irqarg)
296 union hv_synic_siefp siefp; 298 union hv_synic_siefp siefp;
297 union hv_synic_sint shared_sint; 299 union hv_synic_sint shared_sint;
298 union hv_synic_scontrol sctrl; 300 union hv_synic_scontrol sctrl;
301 u64 vp_index;
299 302
300 u32 irq_vector = *((u32 *)(irqarg)); 303 u32 irq_vector = *((u32 *)(irqarg));
301 int cpu = smp_processor_id(); 304 int cpu = smp_processor_id();
@@ -355,6 +358,14 @@ void hv_synic_init(void *irqarg)
355 wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64); 358 wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
356 359
357 hv_context.synic_initialized = true; 360 hv_context.synic_initialized = true;
361
362 /*
363 * Setup the mapping between Hyper-V's notion
364 * of cpuid and Linux' notion of cpuid.
365 * This array will be indexed using Linux cpuid.
366 */
367 rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
368 hv_context.vp_index[cpu] = (u32)vp_index;
358 return; 369 return;
359 370
360cleanup: 371cleanup:
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 1bc7500fb84c..6bbc197cbdfa 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -502,6 +502,16 @@ struct hv_context {
502 502
503 void *synic_message_page[NR_CPUS]; 503 void *synic_message_page[NR_CPUS];
504 void *synic_event_page[NR_CPUS]; 504 void *synic_event_page[NR_CPUS];
505 /*
506 * Hypervisor's notion of virtual processor ID is different from
507 * Linux' notion of CPU ID. This information can only be retrieved
508 * in the context of the calling CPU. Setup a map for easy access
509 * to this information:
510 *
511 * vp_index[a] is the Hyper-V's processor ID corresponding to
512 * Linux cpuid 'a'.
513 */
514 u32 vp_index[NR_CPUS];
505}; 515};
506 516
507extern struct hv_context hv_context; 517extern struct hv_context hv_context;