Skip to content

Commit ddc61bb

Browse files
fbqdlezcano
authored andcommitted
clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page
Currently, the reserved size for a tsc page is 4K, which is enough for communicating with hypervisor. However, in the case where we want to export the tsc page to userspace (e.g. for vDSO to read the clocksource), the tsc page should be at least PAGE_SIZE, otherwise, when PAGE_SIZE is larger than 4K, extra kernel data will be mapped into userspace, which means leaking kernel information. Therefore reserve PAGE_SIZE space for tsc_pg as a preparation for the vDSO support of ARM64 in the future. Also, while at it, replace all reference to tsc_pg with hv_get_tsc_page() since it should be the only interface to access tsc page. Signed-off-by: Boqun Feng (Microsoft) <boqun.feng@gmail.com> Cc: linux-hyperv@vger.kernel.org Reviewed-by: Michael Kelley <mikelley@microsoft.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20191126021723.4710-1-boqun.feng@gmail.com
1 parent 0629346 commit ddc61bb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/clocksource/hyperv_timer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,20 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);
307307
struct clocksource *hyperv_cs;
308308
EXPORT_SYMBOL_GPL(hyperv_cs);
309309

310-
static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE);
310+
static union {
311+
struct ms_hyperv_tsc_page page;
312+
u8 reserved[PAGE_SIZE];
313+
} tsc_pg __aligned(PAGE_SIZE);
311314

312315
struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
313316
{
314-
return &tsc_pg;
317+
return &tsc_pg.page;
315318
}
316319
EXPORT_SYMBOL_GPL(hv_get_tsc_page);
317320

318321
static u64 notrace read_hv_clock_tsc(struct clocksource *arg)
319322
{
320-
u64 current_tick = hv_read_tsc_page(&tsc_pg);
323+
u64 current_tick = hv_read_tsc_page(hv_get_tsc_page());
321324

322325
if (current_tick == U64_MAX)
323326
hv_get_time_ref_count(current_tick);
@@ -397,7 +400,7 @@ static bool __init hv_init_tsc_clocksource(void)
397400
return false;
398401

399402
hyperv_cs = &hyperv_cs_tsc;
400-
phys_addr = virt_to_phys(&tsc_pg);
403+
phys_addr = virt_to_phys(hv_get_tsc_page());
401404

402405
/*
403406
* The Hyper-V TLFS specifies to preserve the value of reserved

0 commit comments

Comments
 (0)