Linux-HyperV Archive on lore.kernel.org
 help / color / Atom feed
From: Michael Kelley <mikelley@microsoft.com>
To: Sasha Levin <sashal@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: RE: [PATCH AUTOSEL 5.5 389/542] clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page
Date: Fri, 14 Feb 2020 16:11:03 +0000
Message-ID: <MW2PR2101MB10526693E43DF07E03D5EB0FD7150@MW2PR2101MB1052.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20200214154854.6746-389-sashal@kernel.org>

This patch does not need to be backported to any stable releases.  It is prep work for guests on Hyper-V ARM64 when the guest page size is 16K or 64K, and that functionality isn't upstream yet.

Michael

> -----Original Message-----
> From: Sasha Levin <sashal@kernel.org>
> Sent: Friday, February 14, 2020 7:46 AM
> To: linux-kernel@vger.kernel.org; stable@vger.kernel.org
> Cc: Boqun Feng <boqun.feng@gmail.com>; linux-hyperv@vger.kernel.org; Michael Kelley
> <mikelley@microsoft.com>; Daniel Lezcano <daniel.lezcano@linaro.org>; Sasha Levin
> <sashal@kernel.org>
> Subject: [PATCH AUTOSEL 5.5 389/542] clocksource/drivers/hyper-v: Reserve PAGE_SIZE
> space for tsc page
> 
> From: Boqun Feng <boqun.feng@gmail.com>
> 
> [ Upstream commit ddc61bbc45017726a2b450350d476b4dc5ae25ce ]
> 
> Currently, the reserved size for a tsc page is 4K, which is enough for
> communicating with hypervisor. However, in the case where we want to
> export the tsc page to userspace (e.g. for vDSO to read the
> clocksource), the tsc page should be at least PAGE_SIZE, otherwise, when
> PAGE_SIZE is larger than 4K, extra kernel data will be mapped into
> userspace, which means leaking kernel information.
> 
> Therefore reserve PAGE_SIZE space for tsc_pg as a preparation for the
> vDSO support of ARM64 in the future. Also, while at it, replace all
> reference to tsc_pg with hv_get_tsc_page() since it should be the only
> interface to access tsc page.
> 
> Signed-off-by: Boqun Feng (Microsoft) <boqun.feng@gmail.com>
> Cc: linux-hyperv@vger.kernel.org
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Link:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fr
> %2F20191126021723.4710-1-
> boqun.feng%40gmail.com&amp;data=02%7C01%7Cmikelley%40microsoft.com%7C2f481a9
> 3db624cb4b5e208d7b16691f6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6371
> 72926408924092&amp;sdata=%2F1JNMBiq7l1ufSsWphZb%2FMLNep2EIOCzlXcG%2F9foZNw
> %3D&amp;reserved=0
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/clocksource/hyperv_timer.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index 287d8d58c21ac..b6ea3a2093c56 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -307,17 +307,20 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);
>  struct clocksource *hyperv_cs;
>  EXPORT_SYMBOL_GPL(hyperv_cs);
> 
> -static struct ms_hyperv_tsc_page tsc_pg __aligned(PAGE_SIZE);
> +static union {
> +	struct ms_hyperv_tsc_page page;
> +	u8 reserved[PAGE_SIZE];
> +} tsc_pg __aligned(PAGE_SIZE);
> 
>  struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
>  {
> -	return &tsc_pg;
> +	return &tsc_pg.page;
>  }
>  EXPORT_SYMBOL_GPL(hv_get_tsc_page);
> 
>  static u64 notrace read_hv_clock_tsc(struct clocksource *arg)
>  {
> -	u64 current_tick = hv_read_tsc_page(&tsc_pg);
> +	u64 current_tick = hv_read_tsc_page(hv_get_tsc_page());
> 
>  	if (current_tick == U64_MAX)
>  		hv_get_time_ref_count(current_tick);
> @@ -372,7 +375,7 @@ static bool __init hv_init_tsc_clocksource(void)
>  		return false;
> 
>  	hyperv_cs = &hyperv_cs_tsc;
> -	phys_addr = virt_to_phys(&tsc_pg);
> +	phys_addr = virt_to_phys(hv_get_tsc_page());
> 
>  	/*
>  	 * The Hyper-V TLFS specifies to preserve the value of reserved
> --
> 2.20.1


  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200214154854.6746-1-sashal@kernel.org>
2020-02-14 15:46 ` Sasha Levin
2020-02-14 16:11   ` Michael Kelley [this message]
2020-02-20 17:34     ` Sasha Levin
2020-02-14 15:47 ` [PATCH AUTOSEL 5.5 481/542] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs Sasha Levin

Reply instructions:

You may reply publically 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=MW2PR2101MB10526693E43DF07E03D5EB0FD7150@MW2PR2101MB1052.namprd21.prod.outlook.com \
    --to=mikelley@microsoft.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.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

Linux-HyperV Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hyperv/0 linux-hyperv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hyperv linux-hyperv/ https://lore.kernel.org/linux-hyperv \
		linux-hyperv@vger.kernel.org
	public-inbox-index linux-hyperv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hyperv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git