Skip to content

Commit 364adc4

Browse files
skinsburskyliuw
authored andcommitted
clocksource: hyper-v: Use TSC PFN getter to map vvar page
Instead of converting the virtual address to physical directly. This is a precursor patch for the upcoming support for TSC page mapping into Microsoft Hypervisor root partition, where TSC PFN will be defined by the hypervisor and thus can't be obtained by linear translation of the physical address. Signed-off-by: Stanislav Kinsburskiy <stanislav.kinsburskiy@gmail.com> CC: Andy Lutomirski <luto@kernel.org> CC: Thomas Gleixner <tglx@linutronix.de> CC: Ingo Molnar <mingo@redhat.com> CC: Borislav Petkov <bp@alien8.de> CC: Dave Hansen <dave.hansen@linux.intel.com> CC: x86@kernel.org CC: "H. Peter Anvin" <hpa@zytor.com> CC: "K. Y. Srinivasan" <kys@microsoft.com> CC: Haiyang Zhang <haiyangz@microsoft.com> CC: Wei Liu <wei.liu@kernel.org> CC: Dexuan Cui <decui@microsoft.com> CC: Daniel Lezcano <daniel.lezcano@linaro.org> CC: linux-kernel@vger.kernel.org CC: linux-hyperv@vger.kernel.org Reviewed-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com> Link: https://lore.kernel.org/r/166749833939.218190.14095015146003109462.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent e1f5c66 commit 364adc4

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

arch/x86/entry/vdso/vma.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
210210
pgprot_decrypted(vma->vm_page_prot));
211211
}
212212
} else if (sym_offset == image->sym_hvclock_page) {
213-
struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page();
213+
pfn = hv_get_tsc_pfn();
214214

215-
if (tsc_pg && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK))
216-
return vmf_insert_pfn(vma, vmf->address,
217-
virt_to_phys(tsc_pg) >> PAGE_SHIFT);
215+
if (pfn && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK))
216+
return vmf_insert_pfn(vma, vmf->address, pfn);
218217
} else if (sym_offset == image->sym_timens_page) {
219218
struct page *timens_page = find_timens_vvar_page(vma);
220219

drivers/clocksource/hyperv_timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,11 @@ static union {
370370
static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page;
371371
static unsigned long tsc_pfn;
372372

373-
static unsigned long hv_get_tsc_pfn(void)
373+
unsigned long hv_get_tsc_pfn(void)
374374
{
375375
return tsc_pfn;
376376
}
377+
EXPORT_SYMBOL_GPL(hv_get_tsc_pfn);
377378

378379
struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
379380
{

include/clocksource/hyperv_timer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern void hv_stimer0_isr(void);
3232

3333
extern void hv_init_clocksource(void);
3434

35+
extern unsigned long hv_get_tsc_pfn(void);
3536
extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
3637

3738
static inline notrace u64
@@ -90,6 +91,11 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
9091
}
9192

9293
#else /* CONFIG_HYPERV_TIMER */
94+
static inline unsigned long hv_get_tsc_pfn(void)
95+
{
96+
return 0;
97+
}
98+
9399
static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
94100
{
95101
return NULL;

0 commit comments

Comments
 (0)