Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp536285rwi; Thu, 20 Oct 2022 01:54:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5T0TBr9MeCTdRl2g9Mp/OeYTDq2+xglFpa5v4wEIz1HdwN8Orqq9IFckHq0HzHZZIN60h3 X-Received: by 2002:a17:907:78d:b0:740:33e1:998 with SMTP id xd13-20020a170907078d00b0074033e10998mr10371945ejb.162.1666256080818; Thu, 20 Oct 2022 01:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666256080; cv=none; d=google.com; s=arc-20160816; b=xXPKMIWvA2gfpx+7JP+l6z74Db94DBQndefFjxDiMkvyBdbSCdNUenFjUll82SFrCP 3ssh5ThV/oRK+UsgmZhVqXT+Vzr9bKoh0e2s+smEbP4ke9m9wow70q47tH1OT9lc1aPD nAteOUtPqmVpI+q75HxPH/t0Qv3QmkF08eDHmtoOOCKgSn746aeAUTevvvWJbAhKDmoX qTNrVpKs8AbQqvHLXSqdVBOu6uaeOXk41ChQKCRCQLuf2dly/8XlI69Fvnzr3eiq9STf s3MBAnOg5/Q+tXA54tnywisJ1F9RAlIRdsi6jE73EBrqxQ6P587HKRLE0YqlO1EW4u3S 1G5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wcWMTUn6awfT6FsetcsWtlbGYuqQTlq+PvX6fZIq7Sk=; b=lPxYhlJo2Uhez+0R1w/oazt48c6JPbzjmgctZTdozEGhuOFX7nk0nDg78NUirDGyIJ nNAuDsK1B5lior69F+BzvrF8xCLXwml2SQcZ9Ut4TCybP1tKMbajNWSsddii+ZKogm2X bRLWj5sewnr9wu9+S8RggvbptP8i9CsHgW+A2TLkJpUIKXzzRp6xjJqa7eqCc3+33Rsg +GLloJfkzKpB5sR1P+RhACl16dzNgz8YGQLfgBKr0BRnAH0Crn4YrSUL1u1i+jkm0fG+ 8YHrW29RW5DawD9+YrDU7n7FtifZpxXeCHdqIf1tM9H/MznqkLs3mDHMpdnB/VcfepNt jH2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Vht6SK/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170906361100b00787d08d5ff4si14083100ejb.695.2022.10.20.01.54.09; Thu, 20 Oct 2022 01:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Vht6SK/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230097AbiJTIdH (ORCPT + 99 others); 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: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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