lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <SA1PR21MB1317ADFF74CF19B691D3CEFFBFC82@SA1PR21MB1317.namprd21.prod.outlook.com>
Date: Thu, 20 Jun 2024 23:00:40 +0000
From: Dexuan Cui <decui@...rosoft.com>
To: mhklinux <mhklinux@...look.com>, KY Srinivasan <kys@...rosoft.com>,
	Haiyang Zhang <haiyangz@...rosoft.com>, Wei Liu <wei.liu@...nel.org>, Thomas
 Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav
 Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>, "H. Peter
 Anvin" <hpa@...or.com>, Daniel Lezcano <daniel.lezcano@...aro.org>, "open
 list:Hyper-V/Azure CORE AND DRIVERS" <linux-hyperv@...r.kernel.org>, "open
 list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <linux-kernel@...r.kernel.org>
CC: "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [PATCH] clocksource: hyper-v: Use lapic timer in a TDX VM without
 paravisor

> From: Michael Kelley <mhklinux@...look.com>
> Sent: Thursday, June 20, 2024 2:19 PM
> To: Dexuan Cui <decui@...rosoft.com>; KY Srinivasan
> [...]
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -449,9 +449,13 @@ static void __init ms_hyperv_init_platform(void)
> >  			ms_hyperv.hints &=
> ~HV_X64_APIC_ACCESS_RECOMMENDED;
> >
> >  			if (!ms_hyperv.paravisor_present) {
> > -				/* To be supported: more work is required.
> */
> > +				/* Use Invariant TSC as a better
> clocksource. */
> 
> I got confused by this comment, partly because I've forgotten the
> meaning of the ms_hyperv.feature flags. :-( Perhaps you could be
> more explicit in the comment and say "Mark the Hyper-V TSC page
> feature as disabled in a TDX VM so that the Invariant TSC, which is
> a better clocksource anyway, is used instead."
> 
> >  				ms_hyperv.features &=
> ~HV_MSR_REFERENCE_TSC_AVAILABLE;
> >
> > +				/* Use the Ref Counter in case Invariant
> TSC is unavailable. */
> > +				if (!(ms_hyperv.features &
> HV_ACCESS_TSC_INVARIANT))
> > +					pr_warn("Hyper-V: Invariant TSC is
> unavailable\n");
> 
> The above comment was even more confusing, because the code block
> doesn't do anything except print a message. The code doesn't force
> the use of the Ref Counter. I'd suggest something like: "The Invariant
> TSC is expected to be available, but if not, print a warning message.
> The slower Hyper-V MSR-based Ref Counter should end up being
> the clocksource."
> 
> Michael

Thanks for the good "comments"! :-)

I'm going to post v2 with the change below.

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index e0fd57a8ba840..954b7cbfa2f02 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -449,9 +449,23 @@ static void __init ms_hyperv_init_platform(void)
                        ms_hyperv.hints &= ~HV_X64_APIC_ACCESS_RECOMMENDED;

                        if (!ms_hyperv.paravisor_present) {
-                               /* To be supported: more work is required.  */
+                               /*
+                                * Mark the Hyper-V TSC page feature as disabled
+                                * in a TDX VM without paravisor so that the
+                                * Invariant TSC, which is a better clocksource
+                                * anyway, is used instead.
+                                */
                                ms_hyperv.features &= ~HV_MSR_REFERENCE_TSC_AVAILABLE;

+                               /*
+                                * The Invariant TSC is expected to be available
+                                * in a TDX VM without paravisor, but if not,
+                                * print a warning message. The slower Hyper-V MSR-based
+                                * Ref Counter should end up being the clocksource.
+                                */
+                               if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
+                                       pr_warn("Hyper-V: Invariant TSC is unavailable\n");
+
                                /* HV_MSR_CRASH_CTL is unsupported. */
                                ms_hyperv.misc_features &= ~HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ