Skip to content

Commit adb87ff

Browse files
Tianyu LanKAGA-KOKO
authored andcommitted
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
1 parent dce3e8f commit adb87ff

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

‎arch/x86/entry/vdso/vma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
122122

123123
if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK))
124124
return vmf_insert_pfn(vma, vmf->address,
125-
vmalloc_to_pfn(tsc_pg));
125+
virt_to_phys(tsc_pg) >> PAGE_SHIFT);
126126
}
127127

128128
return VM_FAULT_SIGBUS;

‎drivers/clocksource/hyperv_timer.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ EXPORT_SYMBOL_GPL(hyperv_cs);
214214

215215
#ifdef CONFIG_HYPERV_TSCPAGE
216216

217-
static struct ms_hyperv_tsc_page *tsc_pg;
217+
static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE);
218218

219219
struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
220220
{
221-
return tsc_pg;
221+
return &tsc_pg;
222222
}
223223
EXPORT_SYMBOL_GPL(hv_get_tsc_page);
224224

225225
static u64 notrace read_hv_sched_clock_tsc(void)
226226
{
227-
u64 current_tick = hv_read_tsc_page(tsc_pg);
227+
u64 current_tick = hv_read_tsc_page(&tsc_pg);
228228

229229
if (current_tick == U64_MAX)
230230
hv_get_time_ref_count(current_tick);
@@ -280,12 +280,8 @@ static bool __init hv_init_tsc_clocksource(void)
280280
if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
281281
return false;
282282

283-
tsc_pg = vmalloc(PAGE_SIZE);
284-
if (!tsc_pg)
285-
return false;
286-
287283
hyperv_cs = &hyperv_cs_tsc;
288-
phys_addr = page_to_phys(vmalloc_to_page(tsc_pg));
284+
phys_addr = virt_to_phys(&tsc_pg);
289285

290286
/*
291287
* The Hyper-V TLFS specifies to preserve the value of reserved

0 commit comments

Comments
 (0)