x86/hyperv: Remove BUG_ON() for kmap_local_page()
Subsystems (3)
PATCH v2 1/1 x86/hyperv: Remove BUG_ON() for kmap_local_page()
From: Zhao Liu <[email protected]>
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/
---
Change in v2:
- Removed "Fixes" tag in patch message.
--- arch/x86/hyperv/hv_init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/hyperv/hv_init.c +2 -4
@@ -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);
Signature · 1 line
2.34.1
Quoted 9 lines · Zhao Liu
From: Zhao Liu <[email protected]>
The commit
154fb14df7a3c("x86/hyperv: Replacekmap()withkmap_local_page()") keeps theBUG_ON()to check ifkmap_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]
Quoted 8 lines
So directly use
memcpy_to_page()which creates local mapping to copy.[1]: https://lore.kernel.org/lkml/YztFEyUA48et0yTt@iweiny-mobl/
Suggested-by Fabio M. De Francesco <[email protected]>Suggested-by Ira Weiny <[email protected]>Reviewed-by Ira Weiny <[email protected]>Signed-off-by Zhao Liu <[email protected]>
Applied to hyperv-fixes. Thanks.
Quoted 16 lines · Wei Liu
Date: Wed, 26 Oct 2022 15:17:18 +0000
From: Wei Liu <[email protected]>
Subject: Re: [PATCH v2] x86/hyperv: RemoveBUG_ON()forkmap_local_page()Quoted 11 lines · Zhao Liu
From: Zhao Liu <[email protected]>
The commit
154fb14df7a3c("x86/hyperv: Replacekmap()withkmap_local_page()") keeps theBUG_ON()to check ifkmap_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.
Quoted 8 lines
Quoted 6 lines
[1]: https://lore.kernel.org/lkml/YztFEyUA48et0yTt@iweiny-mobl/
Suggested-by Fabio M. De Francesco <[email protected]>Suggested-by Ira Weiny <[email protected]>Reviewed-by Ira Weiny <[email protected]>Signed-off-by Zhao Liu <[email protected]>Applied to hyperv-fixes. Thanks.
Sorry Wei, I appology for not deleting unused variables, which caused the next tree break. Do I need to send another v3 to make up for my carelessness?
Zhao
Wei Liu
maintainerQuoted 24 lines · Zhao Liu
Quoted 23 lines · Wei Liu
Date: Wed, 26 Oct 2022 15:17:18 +0000
From: Wei Liu <[email protected]>
Subject: Re: [PATCH v2] x86/hyperv: RemoveBUG_ON()forkmap_local_page()Quoted 17 lines · Zhao Liu
From: Zhao Liu <[email protected]>
The commit
154fb14df7a3c("x86/hyperv: Replacekmap()withkmap_local_page()") keeps theBUG_ON()to check ifkmap_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/
Suggested-by Fabio M. De Francesco <[email protected]>Suggested-by Ira Weiny <[email protected]>Reviewed-by Ira Weiny <[email protected]>Signed-off-by Zhao Liu <[email protected]>
Quoted 5 lines
Quoted 1 line
Applied to hyperv-fixes. Thanks.
Sorry Wei, I appology for not deleting unused variables, which caused the next tree break. Do I need to send another v3 to make up for my carelessness?
There is no need to send v3. I've dealt with it.
Thanks,
Wei.