diff options
Diffstat (limited to 'drivers/staging/hv/hv.c')
-rw-r--r-- | drivers/staging/hv/hv.c | 111 |
1 files changed, 21 insertions, 90 deletions
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index 0b06f4fe5838..a2cc0911de58 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -19,13 +19,15 @@ * Hank Janssen <hjanssen@microsoft.com> * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/kernel.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/vmalloc.h> -#include "hv_api.h" -#include "logging.h" -#include "vmbus_private.h" + +#include "hyperv.h" +#include "hyperv_vmbus.h" /* The one and only */ struct hv_context hv_context = { @@ -80,33 +82,7 @@ static int query_hypervisor_info(void) op = HVCPUID_VENDOR_MAXFUNCTION; cpuid(op, &eax, &ebx, &ecx, &edx); - DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c", - (ebx & 0xFF), - ((ebx >> 8) & 0xFF), - ((ebx >> 16) & 0xFF), - ((ebx >> 24) & 0xFF), - (ecx & 0xFF), - ((ecx >> 8) & 0xFF), - ((ecx >> 16) & 0xFF), - ((ecx >> 24) & 0xFF), - (edx & 0xFF), - ((edx >> 8) & 0xFF), - ((edx >> 16) & 0xFF), - ((edx >> 24) & 0xFF)); - max_leaf = eax; - eax = 0; - ebx = 0; - ecx = 0; - edx = 0; - op = HVCPUID_INTERFACE; - cpuid(op, &eax, &ebx, &ecx, &edx); - - DPRINT_INFO(VMBUS, "Interface ID: %c%c%c%c", - (eax & 0xFF), - ((eax >> 8) & 0xFF), - ((eax >> 16) & 0xFF), - ((eax >> 24) & 0xFF)); if (max_leaf >= HVCPUID_VERSION) { eax = 0; @@ -115,7 +91,7 @@ static int query_hypervisor_info(void) edx = 0; op = HVCPUID_VERSION; cpuid(op, &eax, &ebx, &ecx, &edx); - DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",\ + pr_info("Hyper-V Host OS Build:%d-%d.%d-%d-%d.%d\n", eax, ebx >> 16, ebx & 0xFFFF, @@ -137,18 +113,11 @@ static u64 do_hypercall(u64 control, void *input, void *output) u64 output_address = (output) ? virt_to_phys(output) : 0; volatile void *hypercall_page = hv_context.hypercall_page; - DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p " - "output phys %llx virt %p hypercall %p>", - control, input_address, input, - output_address, output, hypercall_page); - __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8"); __asm__ __volatile__("call *%3" : "=a" (hv_status) : "c" (control), "d" (input_address), "m" (hypercall_page)); - DPRINT_DBG(VMBUS, "Hypercall <return %llx>", hv_status); - return hv_status; #else @@ -165,18 +134,12 @@ static u64 do_hypercall(u64 control, void *input, void *output) u32 output_address_lo = output_address & 0xFFFFFFFF; volatile void *hypercall_page = hv_context.hypercall_page; - DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>", - control, input, output); - __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi), "=a"(hv_status_lo) : "d" (control_hi), "a" (control_lo), "b" (input_address_hi), "c" (input_address_lo), "D"(output_address_hi), "S"(output_address_lo), "m" (hypercall_page)); - DPRINT_DBG(VMBUS, "Hypercall <return %llx>", - hv_status_lo | ((u64)hv_status_hi << 32)); - return hv_status_lo | ((u64)hv_status_hi << 32); #endif /* !x86_64 */ } @@ -197,13 +160,8 @@ int hv_init(void) memset(hv_context.synic_message_page, 0, sizeof(void *) * MAX_NUM_CPUS); - if (!query_hypervisor_presence()) { - DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!"); - goto Cleanup; - } - - DPRINT_INFO(VMBUS, - "Windows hypervisor detected! Retrieving more info..."); + if (!query_hypervisor_presence()) + goto cleanup; max_leaf = query_hypervisor_info(); /* HvQueryHypervisorFeatures(maxLeaf); */ @@ -213,11 +171,8 @@ int hv_init(void) */ rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid); - if (hv_context.guestid != 0) { - DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!", - hv_context.guestid); - goto Cleanup; - } + if (hv_context.guestid != 0) + goto cleanup; /* Write our OS info */ wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID); @@ -232,11 +187,8 @@ int hv_init(void) */ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC); - if (!virtaddr) { - DPRINT_ERR(VMBUS, - "unable to allocate hypercall page!!"); - goto Cleanup; - } + if (!virtaddr) + goto cleanup; hypercall_msr.enable = 1; @@ -247,23 +199,17 @@ int hv_init(void) hypercall_msr.as_uint64 = 0; rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); - if (!hypercall_msr.enable) { - DPRINT_ERR(VMBUS, "unable to set hypercall page!!"); - goto Cleanup; - } + if (!hypercall_msr.enable) + goto cleanup; hv_context.hypercall_page = virtaddr; - DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx", - hv_context.hypercall_page, - (u64)hypercall_msr.guest_physical_address << PAGE_SHIFT); - /* Setup the global signal event param for the signal event hypercall */ hv_context.signal_event_buffer = kmalloc(sizeof(struct hv_input_signal_event_buffer), GFP_KERNEL); if (!hv_context.signal_event_buffer) - goto Cleanup; + goto cleanup; hv_context.signal_event_param = (struct hv_input_signal_event *) @@ -278,7 +224,7 @@ int hv_init(void) return ret; -Cleanup: +cleanup: if (virtaddr) { if (hypercall_msr.enable) { hypercall_msr.as_uint64 = 0; @@ -394,24 +340,20 @@ void hv_synic_init(void *irqarg) /* Check the version */ rdmsrl(HV_X64_MSR_SVERSION, version); - DPRINT_INFO(VMBUS, "SynIC version: %llx", version); - hv_context.synic_message_page[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); if (hv_context.synic_message_page[cpu] == NULL) { - DPRINT_ERR(VMBUS, - "unable to allocate SYNIC message page!!"); - goto Cleanup; + pr_err("Unable to allocate SYNIC message page\n"); + goto cleanup; } hv_context.synic_event_page[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); if (hv_context.synic_event_page[cpu] == NULL) { - DPRINT_ERR(VMBUS, - "unable to allocate SYNIC event page!!"); - goto Cleanup; + pr_err("Unable to allocate SYNIC event page\n"); + goto cleanup; } /* Setup the Synic's message page */ @@ -420,8 +362,6 @@ void hv_synic_init(void *irqarg) simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu]) >> PAGE_SHIFT; - DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.as_uint64); - wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64); /* Setup the Synic's event page */ @@ -430,14 +370,8 @@ void hv_synic_init(void *irqarg) siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu]) >> PAGE_SHIFT; - DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.as_uint64); - wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64); - /* Setup the interception SINT. */ - /* wrmsrl((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */ - /* interceptionSint.as_uint64); */ - /* Setup the shared SINT. */ rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); @@ -446,9 +380,6 @@ void hv_synic_init(void *irqarg) shared_sint.masked = false; shared_sint.auto_eoi = true; - DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx", - shared_sint.as_uint64); - wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); /* Enable the global synic bit */ @@ -460,7 +391,7 @@ void hv_synic_init(void *irqarg) hv_context.synic_initialized = true; return; -Cleanup: +cleanup: if (hv_context.synic_event_page[cpu]) free_page((unsigned long)hv_context.synic_event_page[cpu]); |