From: Ira Weiny <ira.weiny@intel.com>
To: Zhao Liu <zhao1.liu@linux.intel.com>
Cc: "K . Y . Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
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>,
"H . Peter Anvin" <hpa@zytor.com>, <linux-hyperv@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Fabio M . De Francesco" <fmdefrancesco@gmail.com>,
Zhenyu Wang <zhenyu.z.wang@intel.com>,
Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PATCH] x86/hyperv: Remove BUG_ON() for kmap_local_page()
Date: Tue, 18 Oct 2022 19:58:49 -0700 [thread overview]
Message-ID: <Y09n6dRN+zxsaLW/@iweiny-desk3> (raw)
In-Reply-To: <20221018162117.2332508-1-zhao1.liu@linux.intel.com>
On Wed, Oct 19, 2022 at 12:21:17AM +0800, Zhao Liu wrote:
> From: Zhao Liu <zhao1.liu@intel.com>
>
> The commit 154fb14df7a3c ("x86/hyperv: Replace kmap() with
> kmap_local_page()") keeps the BUG_ON() to check if kmap_local_page()
> fails.
>
> But in fact, kmap_local_page() always returns a valid kernel address
> and won't return NULL here. It will BUG on its own if it fails. [1]
>
> So directly use memcpy_to_page() which creates local mapping to copy.
>
> [1]: https://lore.kernel.org/lkml/YztFEyUA48et0yTt@iweiny-mobl/
>
> Fixes: 154fb14df7a3 ("x86/hyperv: Replace kmap() with kmap_local_page()")
I don't know that a fixes is required here. We are not looking to backport any
of this and the other patch was correct. This is just a follow on cleanup.
> Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
Code looks good. Without the fixes.
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> arch/x86/hyperv/hv_init.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 29774126e931..f66c5709324f 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -459,13 +459,11 @@ void __init hyperv_init(void)
> wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
>
> pg = vmalloc_to_page(hv_hypercall_pg);
> - dst = kmap_local_page(pg);
> src = memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAGE_SIZE,
> MEMREMAP_WB);
> - BUG_ON(!(src && dst));
> - memcpy(dst, src, HV_HYP_PAGE_SIZE);
> + BUG_ON(!src);
> + memcpy_to_page(pg, 0, src, HV_HYP_PAGE_SIZE);
> memunmap(src);
> - kunmap_local(dst);
> } else {
> hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
> wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-10-19 2:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 16:21 [PATCH] x86/hyperv: Remove BUG_ON() for kmap_local_page() Zhao Liu
2022-10-19 2:58 ` Ira Weiny [this message]
2022-10-20 8:30 ` Zhao 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=Y09n6dRN+zxsaLW/@iweiny-desk3 \
--to=ira.weiny@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=fmdefrancesco@gmail.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=mingo@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
--cc=zhao1.liu@intel.com \
--cc=zhao1.liu@linux.intel.com \
--cc=zhenyu.z.wang@intel.com \
/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