]> Git Repo - linux.git/commitdiff
clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page
authorBoqun Feng <[email protected]>
Tue, 26 Nov 2019 02:17:20 +0000 (10:17 +0800)
committerDaniel Lezcano <[email protected]>
Thu, 16 Jan 2020 18:07:09 +0000 (19:07 +0100)
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) <[email protected]>
Cc: [email protected]
Reviewed-by: Michael Kelley <[email protected]>
Signed-off-by: Daniel Lezcano <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
drivers/clocksource/hyperv_timer.c

index 1aec08e82b7a8cff673dc395f7a618a62e9369be..12d75b50a3178e6332512a94fb5f7ae5c61074e4 100644 (file)
@@ -307,17 +307,20 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);
 struct clocksource *hyperv_cs;
 EXPORT_SYMBOL_GPL(hyperv_cs);
 
-static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE);
+static union {
+       struct ms_hyperv_tsc_page page;
+       u8 reserved[PAGE_SIZE];
+} tsc_pg __aligned(PAGE_SIZE);
 
 struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
 {
-       return &tsc_pg;
+       return &tsc_pg.page;
 }
 EXPORT_SYMBOL_GPL(hv_get_tsc_page);
 
 static u64 notrace read_hv_clock_tsc(struct clocksource *arg)
 {
-       u64 current_tick = hv_read_tsc_page(&tsc_pg);
+       u64 current_tick = hv_read_tsc_page(hv_get_tsc_page());
 
        if (current_tick == U64_MAX)
                hv_get_time_ref_count(current_tick);
@@ -397,7 +400,7 @@ static bool __init hv_init_tsc_clocksource(void)
                return false;
 
        hyperv_cs = &hyperv_cs_tsc;
-       phys_addr = virt_to_phys(&tsc_pg);
+       phys_addr = virt_to_phys(hv_get_tsc_page());
 
        /*
         * The Hyper-V TLFS specifies to preserve the value of reserved
This page took 0.067766 seconds and 4 git commands to generate.