Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86-hyperv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86/hyperv changes from Ingo Molnar:
"These changes enable Linux guests to boot as 'Modern VM' guest kernels
on MS-Hyperv hosts"

* 'x86-hyperv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86, hyperv: Move a variable to avoid an unused variable warning
x86, hyperv: Fix build error due to missing <asm/apic.h> include
x86, hyperv: Correctly guard the local APIC calibration code
x86, hyperv: Get the local APIC timer frequency from the hypervisor

+46
+19
arch/x86/include/uapi/asm/hyperv.h
··· 27 27 #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0) 28 28 /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/ 29 29 #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1) 30 + 31 + /* 32 + * There is a single feature flag that signifies the presence of the MSR 33 + * that can be used to retrieve both the local APIC Timer frequency as 34 + * well as the TSC frequency. 35 + */ 36 + 37 + /* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is available */ 38 + #define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11) 39 + 40 + /* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */ 41 + #define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11) 42 + 30 43 /* 31 44 * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM 32 45 * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available ··· 148 135 149 136 /* MSR used to read the per-partition time reference counter */ 150 137 #define HV_X64_MSR_TIME_REF_COUNT 0x40000020 138 + 139 + /* MSR used to retrieve the TSC frequency */ 140 + #define HV_X64_MSR_TSC_FREQUENCY 0x40000022 141 + 142 + /* MSR used to retrieve the local APIC timer frequency */ 143 + #define HV_X64_MSR_APIC_FREQUENCY 0x40000023 151 144 152 145 /* Define the virtual APIC registers */ 153 146 #define HV_X64_MSR_EOI 0x40000070
+27
arch/x86/kernel/cpu/mshyperv.c
··· 15 15 #include <linux/clocksource.h> 16 16 #include <linux/module.h> 17 17 #include <linux/hardirq.h> 18 + #include <linux/efi.h> 18 19 #include <linux/interrupt.h> 19 20 #include <asm/processor.h> 20 21 #include <asm/hypervisor.h> ··· 24 23 #include <asm/desc.h> 25 24 #include <asm/idle.h> 26 25 #include <asm/irq_regs.h> 26 + #include <asm/i8259.h> 27 + #include <asm/apic.h> 27 28 28 29 struct ms_hyperv_info ms_hyperv; 29 30 EXPORT_SYMBOL_GPL(ms_hyperv); ··· 78 75 79 76 printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n", 80 77 ms_hyperv.features, ms_hyperv.hints); 78 + 79 + #ifdef CONFIG_X86_LOCAL_APIC 80 + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) { 81 + /* 82 + * Get the APIC frequency. 83 + */ 84 + u64 hv_lapic_frequency; 85 + 86 + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency); 87 + hv_lapic_frequency = div_u64(hv_lapic_frequency, HZ); 88 + lapic_timer_frequency = hv_lapic_frequency; 89 + printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n", 90 + lapic_timer_frequency); 91 + 92 + /* 93 + * On Hyper-V, when we are booting off an EFI firmware stack, 94 + * we do not have many legacy devices including PIC, PIT etc. 95 + */ 96 + if (efi_enabled(EFI_BOOT)) { 97 + printk(KERN_INFO "HyperV: Using null_legacy_pic\n"); 98 + legacy_pic = &null_legacy_pic; 99 + } 100 + } 101 + #endif 81 102 82 103 if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE) 83 104 clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);