From: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
To: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Cc: Stanislav Kinsburskiy <stanislav.kinsburskiy@gmail.com>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
KY 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>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: RE: [PATCH v3 3/4] drivers/clocksource/hyper-v: Use TSC PFN getter to map vvar page
Date: Thu, 3 Nov 2022 20:59:36 +0000 [thread overview]
Message-ID: <BYAPR21MB1688BFD31B3F71C7BA8F46CAD7389@BYAPR21MB1688.namprd21.prod.outlook.com> (raw)
In-Reply-To: <166749833939.218190.14095015146003109462.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net>
From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Thursday, November 3, 2022 10:59 AM
>
> Instead of converting the virtual address to physical directly.
>
> This is a precursor patch for the upcoming support for TSC page mapping into
> Microsoft Hypervisor root partition, where TSC PFN will be defined by the
> hypervisor and thus can't be obtained by linear translation of the physical
> address.
>
> Signed-off-by: Stanislav Kinsburskiy <stanislav.kinsburskiy@gmail.com>
> CC: Andy Lutomirski <luto@kernel.org>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Borislav Petkov <bp@alien8.de>
> CC: Dave Hansen <dave.hansen@linux.intel.com>
> CC: x86@kernel.org
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Wei Liu <wei.liu@kernel.org>
> CC: Dexuan Cui <decui@microsoft.com>
> CC: Daniel Lezcano <daniel.lezcano@linaro.org>
> CC: linux-kernel@vger.kernel.org
> CC: linux-hyperv@vger.kernel.org
> ---
> arch/x86/entry/vdso/vma.c | 7 +++----
> drivers/clocksource/hyperv_timer.c | 3 ++-
> include/clocksource/hyperv_timer.h | 6 ++++++
> 3 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
> index 311eae30e089..6976416b2c9f 100644
> --- a/arch/x86/entry/vdso/vma.c
> +++ b/arch/x86/entry/vdso/vma.c
> @@ -210,11 +210,10 @@ static vm_fault_t vvar_fault(const struct
> vm_special_mapping *sm,
> pgprot_decrypted(vma->vm_page_prot));
> }
> } else if (sym_offset == image->sym_hvclock_page) {
> - struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page();
> + pfn = hv_get_tsc_pfn();
>
> - if (tsc_pg && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK))
> - return vmf_insert_pfn(vma, vmf->address,
> - virt_to_phys(tsc_pg) >> PAGE_SHIFT);
> + if (pfn && vclock_was_used(VDSO_CLOCKMODE_HVCLOCK))
> + return vmf_insert_pfn(vma, vmf->address, pfn);
> } else if (sym_offset == image->sym_timens_page) {
> struct page *timens_page = find_timens_vvar_page(vma);
>
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index b7af19d06b51..9445a1558fe9 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -370,10 +370,11 @@ static union {
> static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page;
> static unsigned long tsc_pfn;
>
> -static unsigned long hv_get_tsc_pfn(void)
> +unsigned long hv_get_tsc_pfn(void)
> {
> return tsc_pfn;
> }
> +EXPORT_SYMBOL_GPL(hv_get_tsc_pfn);
>
> struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
> {
> diff --git a/include/clocksource/hyperv_timer.h
> b/include/clocksource/hyperv_timer.h
> index b3f5d73ae1d6..3078d23faaea 100644
> --- a/include/clocksource/hyperv_timer.h
> +++ b/include/clocksource/hyperv_timer.h
> @@ -32,6 +32,7 @@ extern void hv_stimer0_isr(void);
>
> extern void hv_init_clocksource(void);
>
> +extern unsigned long hv_get_tsc_pfn(void);
> extern struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
>
> static inline notrace u64
> @@ -90,6 +91,11 @@ hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
> }
>
> #else /* CONFIG_HYPERV_TIMER */
> +static inline unsigned long hv_get_tsc_pfn(void)
> +{
> + return 0;
> +}
> +
> static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
> {
> return NULL;
>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
next prev parent reply other threads:[~2022-11-03 20:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 17:58 [PATCH v3 0/4] hyper-v: Introduce TSC page for root partition Stanislav Kinsburskii
2022-11-03 17:58 ` [PATCH v3 1/4] drivers/clocksource/hyper-v: Introduce a pointer to TSC page Stanislav Kinsburskii
2022-11-03 20:58 ` Michael Kelley (LINUX)
2022-11-03 17:58 ` [PATCH v3 2/4] drivers/clocksource/hyper-v: Introduce TSC PFN getter Stanislav Kinsburskii
2022-11-03 20:58 ` Michael Kelley (LINUX)
2022-11-03 17:58 ` [PATCH v3 3/4] drivers/clocksource/hyper-v: Use TSC PFN getter to map vvar page Stanislav Kinsburskii
2022-11-03 20:59 ` Michael Kelley (LINUX) [this message]
2022-11-03 17:59 ` [PATCH v3 4/4] drivers/clocksource/hyper-v: Add TSC page support for root partition Stanislav Kinsburskii
2022-11-03 20:33 ` Michael Kelley (LINUX)
2022-11-03 1:37 ` Stanislav Kinsburskii
2022-11-04 1:44 ` Michael Kelley (LINUX)
2022-11-04 20:40 ` [PATCH v4] " Stanislav Kinsburskii
2022-11-04 20:50 ` Michael Kelley (LINUX)
2022-11-14 13:54 ` [PATCH v3 0/4] hyper-v: Introduce TSC page " Wei Liu
2022-12-02 12:55 ` Daniel Lezcano
2022-12-02 17:10 ` Stanislav Kinsburskii
2022-12-02 18:15 ` Wei Liu
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=BYAPR21MB1688BFD31B3F71C7BA8F46CAD7389@BYAPR21MB1688.namprd21.prod.outlook.com \
--to=mikelley@microsoft.com \
--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=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=skinsburskii@linux.microsoft.com \
--cc=stanislav.kinsburskiy@gmail.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