* [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
@ 2022-11-03 15:23 Anirudh Rayabharam
2022-11-03 15:34 ` Michael Kelley (LINUX)
0 siblings, 1 reply; 6+ messages in thread
From: Anirudh Rayabharam @ 2022-11-03 15:23 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
Daniel Lezcano, Thomas Gleixner
Cc: mail, kumarpraveen, Anirudh Rayabharam, Michael Kelley,
linux-hyperv, linux-kernel
__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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
2022-11-03 15:23 [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN Anirudh Rayabharam
@ 2022-11-03 15:34 ` Michael Kelley (LINUX)
2022-11-03 15:48 ` Wei Liu
0 siblings, 1 reply; 6+ messages in thread
From: Michael Kelley (LINUX) @ 2022-11-03 15:34 UTC (permalink / raw)
To: Anirudh Rayabharam, KY Srinivasan, Haiyang Zhang, Wei Liu,
Dexuan Cui, Daniel Lezcano, Thomas Gleixner
Cc: mail, kumarpraveen, linux-hyperv, linux-kernel
From: Anirudh Rayabharam <anrayabh@linux.microsoft.com> Sent: Thursday, November 3, 2022 8:24 AM
>
> __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
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
2022-11-03 15:34 ` Michael Kelley (LINUX)
@ 2022-11-03 15:48 ` Wei Liu
2022-12-02 12:33 ` Daniel Lezcano
0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2022-11-03 15:48 UTC (permalink / raw)
To: Michael Kelley (LINUX)
Cc: Anirudh Rayabharam, KY Srinivasan, Haiyang Zhang, Wei Liu,
Dexuan Cui, Daniel Lezcano, Thomas Gleixner, mail, kumarpraveen,
linux-hyperv, linux-kernel
On Thu, Nov 03, 2022 at 03:34:23PM +0000, Michael Kelley (LINUX) wrote:
> From: Anirudh Rayabharam <anrayabh@linux.microsoft.com> Sent: Thursday, November 3, 2022 8:24 AM
> >
> > __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
>
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Thank you both for the quick turnaround. I will just squash this patch
into the previous one.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
2022-11-03 15:48 ` Wei Liu
@ 2022-12-02 12:33 ` Daniel Lezcano
2022-12-02 18:14 ` Wei Liu
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2022-12-02 12:33 UTC (permalink / raw)
To: Wei Liu, Michael Kelley (LINUX)
Cc: Anirudh Rayabharam, KY Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, mail, kumarpraveen, linux-hyperv, linux-kernel
Hi,
On 03/11/2022 16:48, Wei Liu wrote:
[ ... ]
>> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
>
> Thank you both for the quick turnaround. I will just squash this patch
> into the previous one.
Can you point to the mailing list the squashed version ?
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
2022-12-02 12:33 ` Daniel Lezcano
@ 2022-12-02 18:14 ` Wei Liu
2022-12-02 18:34 ` Daniel Lezcano
0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2022-12-02 18:14 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Wei Liu, Michael Kelley (LINUX),
Anirudh Rayabharam, KY Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, mail, kumarpraveen, linux-hyperv, linux-kernel
On Fri, Dec 02, 2022 at 01:33:17PM +0100, Daniel Lezcano wrote:
>
> Hi,
>
> On 03/11/2022 16:48, Wei Liu wrote:
>
> [ ... ]
>
> > > Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> >
> > Thank you both for the quick turnaround. I will just squash this patch
> > into the previous one.
>
> Can you point to the mailing list the squashed version ?
The squashed patch is this one:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4ad1aa571214e8d6468a1806794d987b374b5a08
Thanks,
Wei.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN
2022-12-02 18:14 ` Wei Liu
@ 2022-12-02 18:34 ` Daniel Lezcano
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2022-12-02 18:34 UTC (permalink / raw)
To: Wei Liu
Cc: Michael Kelley (LINUX),
Anirudh Rayabharam, KY Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, mail, kumarpraveen, linux-hyperv, linux-kernel
On 02/12/2022 19:14, Wei Liu wrote:
> On Fri, Dec 02, 2022 at 01:33:17PM +0100, Daniel Lezcano wrote:
>>
>> Hi,
>>
>> On 03/11/2022 16:48, Wei Liu wrote:
>>
>> [ ... ]
>>
>>>> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
>>>
>>> Thank you both for the quick turnaround. I will just squash this patch
>>> into the previous one.
>>
>> Can you point to the mailing list the squashed version ?
>
> The squashed patch is this one:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4ad1aa571214e8d6468a1806794d987b374b5a08
Thanks!
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-02 18:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 15:23 [PATCH] clocksource/drivers/hyperv: use Hyper-V's page size to calculate PFN Anirudh Rayabharam
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).