From: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
To: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: mail@anirudhrb.com, kumarpraveen@linux.microsoft.com,
Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
Michael Kelley <mikelley@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
Date: Thu, 3 Nov 2022 20:53:37 +0530 [thread overview]
Message-ID: <20221103152338.2926983-1-anrayabh@linux.microsoft.com> (raw)
__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. The PFN for the
TSC page always needs to be a Hyper-V PFN.
Use HVPFN_DOWN() to calculate the PFN of the TSC page from the physical
address.
Reported-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
Signed-off-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
---
drivers/clocksource/hyperv_timer.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 11332c82d1af..18de1f439ffd 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -21,6 +21,7 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/acpi.h>
+#include <linux/hyperv.h>
#include <clocksource/hyperv_timer.h>
#include <asm/hyperv-tlfs.h>
#include <asm/mshyperv.h>
@@ -412,7 +413,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)
/* Re-enable the TSC page */
tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC);
tsc_msr.enable = 1;
- tsc_msr.pfn = __phys_to_pfn(phys_addr);
+ tsc_msr.pfn = HVPFN_DOWN(phys_addr);
hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64);
}
@@ -532,7 +533,7 @@ static bool __init hv_init_tsc_clocksource(void)
*/
tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC);
tsc_msr.enable = 1;
- tsc_msr.pfn = __phys_to_pfn(phys_addr);
+ tsc_msr.pfn = HVPFN_DOWN(phys_addr);
hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64);
clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
--
2.34.1
next reply other threads:[~2022-11-03 15:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 15:23 Anirudh Rayabharam [this message]
2022-11-03 15:34 ` Michael Kelley (LINUX)
2022-11-03 15:48 ` Wei Liu
2022-12-02 12:33 ` Daniel Lezcano
2022-12-02 18:14 ` Wei Liu
2022-12-02 18:34 ` Daniel Lezcano
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=20221103152338.2926983-1-anrayabh@linux.microsoft.com \
--to=anrayabh@linux.microsoft.com \
--cc=daniel.lezcano@linaro.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kumarpraveen@linux.microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@anirudhrb.com \
--cc=mikelley@microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@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
all inboxes | Powered by JetHome®