From nobody Tue Apr 7 17:39:25 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A210CC4332F for ; Thu, 20 Oct 2022 08:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbiJTIdH (ORCPT ); Thu, 20 Oct 2022 04:33:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiJTIdF (ORCPT ); Thu, 20 Oct 2022 04:33:05 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C2A184989; Thu, 20 Oct 2022 01:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666254769; x=1697790769; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=24YMBCVcJ762KNP35Wql1ASoAixWvlrZlk6OghTOrWs=; b=Vht6SK/4W+VN/EXAfShHBg81hgGky1WwqTxTI1G69GlDlE7NfA5CF01E 9WSjUWqJ7JujEcT0vgdm5DW4EOwLahjn+y2Mk40E1ogGUevcrfhFQRPi/ ITzLWuER9dbaF5itWGaT9sBfwa+0Stnj0zaHdS8ymGusuSO3OrCCsD6S4 sh+hMB/oVFYL+nXR9gorrml5FSLmRD2dNyiVsOjHtVhPYMk3RoNoNSuBS PwQV1NCVSzCd56+CqL//gNg2oEFIwBJOYvCrtRo5UowK+0Ft0Kqj2AMDS 44ZNRiUTAwuJnf7mXNIO4+4D3Jd2yamWknwP5P92JIJv3JT+T1feu7ZLl g==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="308331471" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="308331471" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 01:32:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="718928199" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="718928199" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.132]) by FMSMGA003.fm.intel.com with ESMTP; 20 Oct 2022 01:32:45 -0700 From: Zhao Liu To: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny , "Fabio M . De Francesco" , Zhenyu Wang , Zhao Liu Subject: [PATCH v2] x86/hyperv: Remove BUG_ON() for kmap_local_page() Date: Thu, 20 Oct 2022 16:38:20 +0800 Message-Id: <20221020083820.2341088-1-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhao Liu 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/ Suggested-by: Fabio M. De Francesco Suggested-by: Ira Weiny Reviewed-by: Ira Weiny Signed-off-by: Zhao Liu --- Change in v2: - Removed "Fixes" tag in patch message. --- 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); =20 pg =3D vmalloc_to_page(hv_hypercall_pg); - dst =3D kmap_local_page(pg); src =3D memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAG= E_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 =3D vmalloc_to_pfn(hv_hypercall_pg); wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); --=20 2.34.1