Skip to content

Commit 6b4b87d

Browse files
john-cabajnukelet
authored andcommitted
Revert "UBUNTU: SAUCE: clocksource: hyper-v: Use InvariantTSC and enable TSC page for a TDX VM without paravisor"
BugLink: https://bugs.launchpad.net/bugs/2104836 This reverts commit 8e5f337. Upstream 7f828d5: "clocksource: hyper-v: Use lapic timer in a TDX VM without paravisor" has since been committed to Ubuntu kernels 6.8 and newer, which removes the need for this SAUCE patch. Signed-off-by: John Cabaj <[email protected]> Acked-by: Kuba Pawlak <[email protected]> Acked-by: Massimiliano Pellizzer <[email protected]> Signed-off-by: John Cabaj <[email protected]>
1 parent 254ecd2 commit 6b4b87d

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

arch/x86/entry/vdso/vma.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/time_namespace.h>
1818

1919
#include <asm/pvclock.h>
20-
#include <asm/mshyperv.h>
2120
#include <asm/vgtod.h>
2221
#include <asm/proto.h>
2322
#include <asm/vdso.h>
@@ -190,13 +189,9 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
190189
}
191190
} else if (sym_offset == image->sym_hvclock_page) {
192191
pfn = hv_get_tsc_pfn();
193-
if (pfn && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK)) {
194-
if (ms_hyperv.paravisor_present)
195-
return vmf_insert_pfn(vma, vmf->address, pfn);
196-
else
197-
return vmf_insert_pfn_prot(vma, vmf->address,
198-
pfn, pgprot_decrypted(vma->vm_page_prot));
199-
}
192+
193+
if (pfn && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK))
194+
return vmf_insert_pfn(vma, vmf->address, pfn);
200195
} else if (sym_offset == image->sym_timens_page) {
201196
struct page *timens_page = find_timens_vvar_page(vma);
202197

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ static void __init ms_hyperv_init_platform(void)
507507
ms_hyperv.hints &= ~HV_X64_APIC_ACCESS_RECOMMENDED;
508508

509509
if (!ms_hyperv.paravisor_present) {
510+
/*
511+
* Mark the Hyper-V TSC page feature as disabled
512+
* in a TDX VM without paravisor so that the
513+
* Invariant TSC, which is a better clocksource
514+
* anyway, is used instead.
515+
*/
516+
ms_hyperv.features &= ~HV_MSR_REFERENCE_TSC_AVAILABLE;
517+
510518
/*
511519
* The Invariant TSC is expected to be available
512520
* in a TDX VM without paravisor, but if not,

drivers/clocksource/hyperv_timer.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/irq.h>
2323
#include <linux/acpi.h>
2424
#include <linux/hyperv.h>
25-
#include <linux/set_memory.h>
2625
#include <clocksource/hyperv_timer.h>
2726
#include <asm/hyperv-tlfs.h>
2827
#include <asm/mshyperv.h>
@@ -405,8 +404,8 @@ static __always_inline u64 read_hv_clock_msr(void)
405404

406405
static union {
407406
struct ms_hyperv_tsc_page page;
408-
u8 reserved[SZ_2M];
409-
} tsc_pg __bss_decrypted __aligned(SZ_2M);
407+
u8 reserved[PAGE_SIZE];
408+
} tsc_pg __bss_decrypted __aligned(PAGE_SIZE);
410409

411410
static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page;
412411
static unsigned long tsc_pfn;
@@ -547,7 +546,6 @@ static __always_inline void hv_setup_sched_clock(void *sched_clock) {}
547546
static void __init hv_init_tsc_clocksource(void)
548547
{
549548
union hv_reference_tsc_msr tsc_msr;
550-
int ret;
551549

552550
/*
553551
* If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
@@ -567,12 +565,6 @@ static void __init hv_init_tsc_clocksource(void)
567565

568566
hv_read_reference_counter = read_hv_clock_tsc;
569567

570-
if (hv_isolation_type_tdx() && !ms_hyperv.paravisor_present) {
571-
ret = set_memory_decrypted((unsigned long)tsc_page, SZ_2M/PAGE_SIZE);
572-
BUG_ON(ret);
573-
memset(tsc_page, 0, PAGE_SIZE);
574-
}
575-
576568
/*
577569
* TSC page mapping works differently in root compared to guest.
578570
* - In guest partition the guest PFN has to be passed to the
@@ -596,10 +588,6 @@ static void __init hv_init_tsc_clocksource(void)
596588
tsc_pfn = HVPFN_DOWN(virt_to_phys(tsc_page));
597589
tsc_msr.enable = 1;
598590
tsc_msr.pfn = tsc_pfn;
599-
600-
if (hv_isolation_type_tdx() && !ms_hyperv.paravisor_present)
601-
tsc_msr.pfn = PHYS_PFN(cc_mkdec(PFN_PHYS(tsc_msr.pfn)));
602-
603591
hv_set_msr(HV_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
604592

605593
clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);

0 commit comments

Comments
 (0)