Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6236306rwi; Tue, 18 Oct 2022 09:43:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6P417eSeXHQSjGOHpMUiwyMKwityC3tkaT68/Hcq1e7NCS0vMz/kgNyjG93ooXw5WzwYJG X-Received: by 2002:a17:90a:8c97:b0:20d:a1a2:bfda with SMTP id b23-20020a17090a8c9700b0020da1a2bfdamr4576200pjo.234.1666111393159; Tue, 18 Oct 2022 09:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666111393; cv=none; d=google.com; s=arc-20160816; b=X7FcVo112m8+6KttsUyXAMndLLVtN81KWV2RGChyh0ryGA89ET0vbo/cu63VF9uR6X I2Z0yRr/cqmVaYQByzeBlNWPhWZwufOL5tAT7OPiq3G2BVj21fS/1l9kf90hwLvCoZG2 2m9aP4WEoOjzuNcMo4U5bgAFi3N7GitnUyg0feINyDmbCxLN1V4ZnBXFV8mX61/xvE+z 3zT3egIkeRhMJNeVSjHXjo+crvKUHOCGUcoBWrBp5+GylZNqHxTbwFTuk1ugrNfMEup2 UNAUXeiXavG1Fqo+n4QO2iELo5wj6H077JM2PUHFxW/mldIiM9avHD+ERH0K97cVSkEI y0bQ== 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=CdBJa317yco2yAS9pBP4+jzSXADxKwvNWFnqCnVegh0=; b=IXZXwJbte5ubpfym5K3vZ7ah2/z/j1+8hN1YOkRZFRs35MDOBUDv9I4sr0BFRzeZOI G22K2Qh6Lf0ZeF9E6DPg2HKruFwJb4EzIIhTcAEMbpV3LDG0iZVjVOfX+oJ/t1OQeo+q zKTHw0JvWyoAK8Lim7zqT5wf76+Oc8wUwoUdnQ2bZ+/bM+I5I3lhXXciriwVg1VpBy9p V92PMl2KoYYFfTfOW/LNZSLtMdcFbH6MmhjTt8ElfwV9qYTKleKvgQPkck11Fywxth41 4MUmcYnTu+vpcu3Kk9VhH8E3yA0m8ZgTdy+g5wvrH0/zpNWn2imSirf1B8TNERndUlYP clhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AuDAbU4v; 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 y11-20020a056a001c8b00b00562c5e2a99bsi12324363pfw.163.2022.10.18.09.42.59; Tue, 18 Oct 2022 09:43:13 -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=AuDAbU4v; 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 S230184AbiJRQPw (ORCPT + 99 others); Tue, 18 Oct 2022 12:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiJRQPu (ORCPT ); Tue, 18 Oct 2022 12:15:50 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD3F522B28; Tue, 18 Oct 2022 09:15: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=1666109749; x=1697645749; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=oVwEkTvo388mdVRGCGIjhvZMJ0FRpThRSVZC/miQszI=; b=AuDAbU4viKFqSvmi08HqDMh4LyP6hB6ONicoUlsX1ZWArzPl22qOrmy+ iTlstDMbQMLTjJoS3KULOevmBSQ9FxP7Gh5/+lJhjpLjR6DqHnjaD1Cto fMK52B15BxMUdUKL4JHhRK8uMkrm/HrQhvjwhdwaPoepQlKonymSCzZD1 iWnAeIjmLanUu/34MqkclFuCqinRSH//HYEIS7+/aOpYqf96R6OrU3CGg 3U7T4zE3a3KLc9tiK0+dwi5RSQOw1TI4QA22VJEP9wNusKwv4jFgP7uyj DWKWTv1AMBzu/h3LdpZcQtiBJoas4oUMKBtr/OTvfMlxqMOyvUZFmH+0N w==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="293524770" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="293524770" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 09:15:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="606617636" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="606617636" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.132]) by orsmga006.jf.intel.com with ESMTP; 18 Oct 2022 09:15: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] x86/hyperv: Remove BUG_ON() for kmap_local_page() Date: Wed, 19 Oct 2022 00:21:17 +0800 Message-Id: <20221018162117.2332508-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.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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/ Fixes: 154fb14df7a3 ("x86/hyperv: Replace kmap() with kmap_local_page()") Suggested-by: Fabio M. De Francesco Suggested-by: Ira Weiny Signed-off-by: Zhao Liu --- 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