diff options
author | Tianyu Lan <Tianyu.Lan@microsoft.com> | 2019-08-14 08:32:15 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-08-23 10:59:53 -0400 |
commit | adb87ff4f96c9700718e09c97a804124d5cd61ff (patch) | |
tree | 477a173e4b350b879c369d07e2af20f9bdfefff7 | |
parent | dce3e8fd039cc1b62760b3ad6822cf04c262cd0e (diff) |
clocksource/drivers/hyperv: Allocate Hyper-V TSC page statically
Prepare to add Hyper-V sched clock callback and move Hyper-V Reference TSC
initialization much earlier in the boot process. Earlier initialization is
needed so that it happens while the timestamp value is still 0 and no
discontinuity in the timestamp will occur when pv_ops.time.sched_clock
calculates its offset.
The earlier initialization requires that the Hyper-V TSC page be allocated
statically instead of with vmalloc(), so fixup the references to the TSC
page and the method of getting its physical address.
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lkml.kernel.org/r/20190814123216.32245-2-Tianyu.Lan@microsoft.com
-rw-r--r-- | arch/x86/entry/vdso/vma.c | 2 | ||||
-rw-r--r-- | drivers/clocksource/hyperv_timer.c | 12 |
2 files changed, 5 insertions, 9 deletions
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 349a61d8bf34..f5937742b290 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c | |||
@@ -122,7 +122,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, | |||
122 | 122 | ||
123 | if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK)) | 123 | if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK)) |
124 | return vmf_insert_pfn(vma, vmf->address, | 124 | return vmf_insert_pfn(vma, vmf->address, |
125 | vmalloc_to_pfn(tsc_pg)); | 125 | virt_to_phys(tsc_pg) >> PAGE_SHIFT); |
126 | } | 126 | } |
127 | 127 | ||
128 | return VM_FAULT_SIGBUS; | 128 | return VM_FAULT_SIGBUS; |
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index ba2c79e6a0ee..432aa331df04 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c | |||
@@ -214,17 +214,17 @@ EXPORT_SYMBOL_GPL(hyperv_cs); | |||
214 | 214 | ||
215 | #ifdef CONFIG_HYPERV_TSCPAGE | 215 | #ifdef CONFIG_HYPERV_TSCPAGE |
216 | 216 | ||
217 | static struct ms_hyperv_tsc_page *tsc_pg; | 217 | static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE); |
218 | 218 | ||
219 | struct ms_hyperv_tsc_page *hv_get_tsc_page(void) | 219 | struct ms_hyperv_tsc_page *hv_get_tsc_page(void) |
220 | { | 220 | { |
221 | return tsc_pg; | 221 | return &tsc_pg; |
222 | } | 222 | } |
223 | EXPORT_SYMBOL_GPL(hv_get_tsc_page); | 223 | EXPORT_SYMBOL_GPL(hv_get_tsc_page); |
224 | 224 | ||
225 | static u64 notrace read_hv_sched_clock_tsc(void) | 225 | static u64 notrace read_hv_sched_clock_tsc(void) |
226 | { | 226 | { |
227 | u64 current_tick = hv_read_tsc_page(tsc_pg); | 227 | u64 current_tick = hv_read_tsc_page(&tsc_pg); |
228 | 228 | ||
229 | if (current_tick == U64_MAX) | 229 | if (current_tick == U64_MAX) |
230 | hv_get_time_ref_count(current_tick); | 230 | hv_get_time_ref_count(current_tick); |
@@ -280,12 +280,8 @@ static bool __init hv_init_tsc_clocksource(void) | |||
280 | if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) | 280 | if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) |
281 | return false; | 281 | return false; |
282 | 282 | ||
283 | tsc_pg = vmalloc(PAGE_SIZE); | ||
284 | if (!tsc_pg) | ||
285 | return false; | ||
286 | |||
287 | hyperv_cs = &hyperv_cs_tsc; | 283 | hyperv_cs = &hyperv_cs_tsc; |
288 | phys_addr = page_to_phys(vmalloc_to_page(tsc_pg)); | 284 | phys_addr = virt_to_phys(&tsc_pg); |
289 | 285 | ||
290 | /* | 286 | /* |
291 | * The Hyper-V TLFS specifies to preserve the value of reserved | 287 | * The Hyper-V TLFS specifies to preserve the value of reserved |