Skip to content

Commit 03b9a6e

Browse files
trueptolemyliuw
authored andcommitted
x86/hyperv: Remove BUG_ON() for kmap_local_page()
The commit 154fb14 ("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/ Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Suggested-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20221020083820.2341088-1-zhao1.liu@linux.intel.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 247f34f commit 03b9a6e

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

arch/x86/hyperv/hv_init.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void __init hyperv_init(void)
444444

445445
if (hv_root_partition) {
446446
struct page *pg;
447-
void *src, *dst;
447+
void *src;
448448

449449
/*
450450
* For the root partition, the hypervisor will set up its
@@ -459,13 +459,11 @@ void __init hyperv_init(void)
459459
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
460460

461461
pg = vmalloc_to_page(hv_hypercall_pg);
462-
dst = kmap_local_page(pg);
463462
src = memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAGE_SIZE,
464463
MEMREMAP_WB);
465-
BUG_ON(!(src && dst));
466-
memcpy(dst, src, HV_HYP_PAGE_SIZE);
464+
BUG_ON(!src);
465+
memcpy_to_page(pg, 0, src, HV_HYP_PAGE_SIZE);
467466
memunmap(src);
468-
kunmap_local(dst);
469467
} else {
470468
hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
471469
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);

0 commit comments

Comments
 (0)