From: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
To: Wei Liu <wei.liu@kernel.org>
Cc: "Michael Kelley (LINUX)" <mikelley@microsoft.com>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Dexuan Cui <decui@microsoft.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"stanislav.kinsburskiy@gmail.com"
<stanislav.kinsburskiy@gmail.com>,
"kumarpraveen@linux.microsoft.com"
<kumarpraveen@linux.microsoft.com>,
"mail@anirudhrb.com" <mail@anirudhrb.com>
Subject: Re: [PATCH v2 1/2] clocksource/drivers/hyperv: add data structure for reference TSC MSR
Date: Thu, 3 Nov 2022 21:00:15 +0530 [thread overview]
Message-ID: <Y2Peh/+kz8FtlnAm@anrayabh-desk> (raw)
In-Reply-To: <Y2PPBREz76rMyhnx@liuwe-devbox-debian-v2>
On Thu, Nov 03, 2022 at 02:24:05PM +0000, Wei Liu wrote:
> On Wed, Nov 02, 2022 at 08:33:31PM +0000, Michael Kelley (LINUX) wrote:
> > From: Michael Kelley (LINUX) <mikelley@microsoft.com> Sent: Thursday, October 27, 2022 6:43 AM
> > > From: Anirudh Rayabharam <anrayabh@linux.microsoft.com> Sent: Thursday,
> > > October 27, 2022 2:57 AM
> > > >
> > > > Add a data structure to represent the reference TSC MSR similar to
> > > > other MSRs. This simplifies the code for updating the MSR.
> > > >
> > > > Signed-off-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
> > > > ---
> > > > drivers/clocksource/hyperv_timer.c | 28 ++++++++++++++--------------
> > > > include/asm-generic/hyperv-tlfs.h | 9 +++++++++
> > > > 2 files changed, 23 insertions(+), 14 deletions(-)
> > > >
> > > > diff --git a/drivers/clocksource/hyperv_timer.c
> > > b/drivers/clocksource/hyperv_timer.c
> > > > index bb47610bbd1c..11332c82d1af 100644
> > > > --- a/drivers/clocksource/hyperv_timer.c
> > > > +++ b/drivers/clocksource/hyperv_timer.c
> > > > @@ -395,25 +395,25 @@ static u64 notrace read_hv_sched_clock_tsc(void)
> > > >
> > > > static void suspend_hv_clock_tsc(struct clocksource *arg)
> > > > {
> > > > - u64 tsc_msr;
> > > > + union hv_reference_tsc_msr tsc_msr;
> > > >
> > > > /* Disable the TSC page */
> > > > - tsc_msr = hv_get_register(HV_REGISTER_REFERENCE_TSC);
> > > > - tsc_msr &= ~BIT_ULL(0);
> > > > - hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr);
> > > > + tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC);
> > > > + tsc_msr.enable = 0;
> > > > + hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64);
> > > > }
> > > >
> > > >
> > > > static void resume_hv_clock_tsc(struct clocksource *arg)
> > > > {
> > > > phys_addr_t phys_addr = virt_to_phys(&tsc_pg);
> > > > - u64 tsc_msr;
> > > > + union hv_reference_tsc_msr tsc_msr;
> > > >
> > > > /* Re-enable the TSC page */
> > > > - tsc_msr = hv_get_register(HV_REGISTER_REFERENCE_TSC);
> > > > - tsc_msr &= GENMASK_ULL(11, 0);
> > > > - tsc_msr |= BIT_ULL(0) | (u64)phys_addr;
> > > > - hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr);
> > > > + tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC);
> > > > + tsc_msr.enable = 1;
> > > > + tsc_msr.pfn = __phys_to_pfn(phys_addr);
> >
> > My previous review missed a problem here (and in the similar line below).
> > __phys_to_pfn() will return a PFN based on the guest page size, which might
> > be different from Hyper-V's page size that is always 4K. This needs to be a
> > Hyper-V PFN, and we have virt_to_hvpfn() available to do just that, assuming
> > that function is safe to use here and in the case below.
>
> Anirudh, please take a look.
Just sent a fix for this using HVPFN_DOWN() which looks safe to use
here.
Thanks,
Anirudh.
>
> I'm holding off sending hyperv-fixes to Linus for now.
>
> Thanks,
> Wei.
next prev parent reply other threads:[~2022-11-03 15:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 9:57 [PATCH v2 0/2] Fix MSR access errors during kexec in root partition Anirudh Rayabharam
2022-10-27 9:57 ` [PATCH v2 1/2] clocksource/drivers/hyperv: add data structure for reference TSC MSR Anirudh Rayabharam
2022-10-27 13:42 ` Michael Kelley (LINUX)
2022-11-02 20:33 ` Michael Kelley (LINUX)
2022-11-03 14:24 ` Wei Liu
2022-11-03 15:30 ` Anirudh Rayabharam [this message]
2022-10-27 9:57 ` [PATCH v2 2/2] x86/hyperv: fix invalid writes to MSRs during root partition kexec Anirudh Rayabharam
2022-10-27 13:44 ` Michael Kelley (LINUX)
2022-10-27 19:16 ` Wei Liu
2022-10-28 12:34 ` Anirudh Rayabharam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2Peh/+kz8FtlnAm@anrayabh-desk \
--to=anrayabh@linux.microsoft.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=daniel.lezcano@linaro.org \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kumarpraveen@linux.microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@anirudhrb.com \
--cc=mikelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=stanislav.kinsburskiy@gmail.com \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox