Lines Matching +full:page +full:- +full:based

1 // SPDX-License-Identifier: GPL-2.0
5 * provided by the Hyper-V hypervisor to guest VMs, as described
6 * in the Hyper-V Top Level Functional Spec (TLFS). This driver
36 * mechanism is used when running on older versions of Hyper-V
37 * that don't support Direct Mode. While Hyper-V provides
44 * However, for legacy versions of Hyper-V when Direct Mode
51 static int stimer0_irq = -1;
64 ce->event_handler(ce); in hv_stimer0_isr()
70 * per-cpu interrupts, which also implies Direct Mode.
128 * hv_stimer_init - Per-cpu initialization of the clockevent
138 ce->name = "Hyper-V clockevent"; in hv_stimer_init()
139 ce->features = CLOCK_EVT_FEAT_ONESHOT; in hv_stimer_init()
140 ce->cpumask = cpumask_of(cpu); in hv_stimer_init()
143 * Lower the rating of the Hyper-V timer in a TDX VM without paravisor, in hv_stimer_init()
145 * such a VM. The Hyper-V timer is not preferred in such a VM because in hv_stimer_init()
146 * it depends on the slow VM Reference Counter MSR (the Hyper-V TSC in hv_stimer_init()
147 * page is not enbled in such a VM because the VM uses Invariant TSC in hv_stimer_init()
148 * as a better clocksource and it's challenging to mark the Hyper-V in hv_stimer_init()
149 * TSC page shared in very early boot). in hv_stimer_init()
152 ce->rating = 90; in hv_stimer_init()
154 ce->rating = 1000; in hv_stimer_init()
156 ce->set_state_shutdown = hv_ce_shutdown; in hv_stimer_init()
157 ce->set_state_oneshot = hv_ce_set_oneshot; in hv_stimer_init()
158 ce->set_next_event = hv_ce_set_next_event; in hv_stimer_init()
168 * hv_stimer_cleanup - Per-cpu cleanup of the clockevent
181 * must unbind the stimer-based clockevent device so in hv_stimer_cleanup()
204 * they don't support per-cpu IRQs (such as x86/x64).
215 /* Called only on architectures with per-cpu IRQs (i.e., not x86/x64) */
223 pr_err("Can't register Hyper-V stimer0 GSI. Error %d", ret); in hv_setup_stimer0_irq()
229 "Hyper-V stimer0", &stimer0_evt); in hv_setup_stimer0_irq()
231 pr_err("Can't request Hyper-V stimer0 IRQ %d. Error %d", in hv_setup_stimer0_irq()
234 stimer0_irq = -1; in hv_setup_stimer0_irq()
241 if (stimer0_irq == -1) { in hv_remove_stimer0_irq()
246 stimer0_irq = -1; in hv_remove_stimer0_irq()
260 /* hv_stimer_alloc - Global initialization of the clockevent and stimer0 */
267 * Hyper-V on x86. In that case, return as error as Linux will use a in hv_stimer_alloc()
268 * clockevent based on emulated LAPIC timer hardware. in hv_stimer_alloc()
271 return -EINVAL; in hv_stimer_alloc()
275 return -ENOMEM; in hv_stimer_alloc()
317 * hv_stimer_legacy_init -- Called from the VMbus driver to handle
340 * hv_stimer_legacy_cleanup -- Called from the VMbus driver to
375 stimer0_irq = -1; in hv_stimer_global_cleanup()
398 * Code and definitions for the Hyper-V clocksources. Two
399 * clocksources are defined: one that reads the Hyper-V defined MSR, and
400 * the other that uses the TSC reference page feature as defined in the
402 * Hyper-V and 32-bit x86. The TSC reference page version is preferred.
406 struct ms_hyperv_tsc_page page; member
410 static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page;
430 * The Hyper-V Top-Level Function Spec (TLFS), section Timers, in read_hv_clock_tsc()
433 * to the MSR in case the TSC page indicates unavailability. in read_hv_clock_tsc()
448 return (read_hv_clock_tsc() - hv_sched_clock_offset) * in read_hv_sched_clock_tsc()
456 /* Disable the TSC page */ in suspend_hv_clock_tsc()
467 /* Re-enable the TSC page */ in resume_hv_clock_tsc()
477 * used to calculate time for hv tsc page based sched_clock, to account for
482 hv_sched_clock_offset -= offset; in hv_adj_sched_clock_offset()
531 * The Hyper-V sched clock read function returns nanoseconds, not in hv_setup_sched_clock()
532 * the normal 100ns units of the Hyper-V synthetic clock. in hv_setup_sched_clock()
551 * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly in hv_init_tsc_clocksource()
554 * Hyper-V Reference TSC rating, causing the generic TSC to be used. in hv_init_tsc_clocksource()
555 * TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference in hv_init_tsc_clocksource()
569 * TSC page mapping works differently in root compared to guest. in hv_init_tsc_clocksource()
570 * - In guest partition the guest PFN has to be passed to the in hv_init_tsc_clocksource()
572 * - In root partition it's other way around: it has to map the PFN in hv_init_tsc_clocksource()
576 * page later in hv_remap_tsc_clocksource(). in hv_init_tsc_clocksource()
579 * (read_hv_clock_tsc) has a MSR-based fallback mechanism, used when in hv_init_tsc_clocksource()
580 * TSC page is zeroed (which is the case until the PFN is remapped) and in hv_init_tsc_clocksource()
581 * thus TSC clocksource will work even without the real TSC page in hv_init_tsc_clocksource()
597 * will be faster than reading the TSC page. But if not invariant, use in hv_init_tsc_clocksource()
598 * the TSC page so that live migrations across hosts with different in hv_init_tsc_clocksource()
610 * Try to set up the TSC page clocksource, then the MSR clocksource. in hv_init_clocksource()
612 * versions of Hyper-V on x86. In that case we won't have a Hyper-V in hv_init_clocksource()
613 * clocksource, but Linux will still run with a clocksource based in hv_init_clocksource()
631 WARN(1, "%s: attempt to remap TSC page in guest partition\n", in hv_remap_tsc_clocksource()
639 pr_err("Failed to remap Hyper-V TSC page.\n"); in hv_remap_tsc_clocksource()