From patchwork Tue Oct 18 16:21:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 4247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2049476wrs; Tue, 18 Oct 2022 09:32:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46Qv2SH2/Cfq1FzUUW+5wXQzFXJ3813Kk6ffyxqpbLccBOOGKrpdwPxYYj+rM9Sefi8geS X-Received: by 2002:a17:90b:4c45:b0:20d:4ead:6e3b with SMTP id np5-20020a17090b4c4500b0020d4ead6e3bmr4626041pjb.76.1666110726770; Tue, 18 Oct 2022 09:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666110726; cv=none; d=google.com; s=arc-20160816; b=ezqorRhWMN533P9FoqIqXTsvwdIYv2fufc83i3KOn1oUNXuF+/Mf6bLFvQl6jPFB0P 7LI5Ow8RRTkHROe/hFilvPQzRGWlNoWQ/V1lYiKKS6Gw2IPHwDYwjZy40Szx/eC7bWvb OUu7tDbl8CsVQxB2tEGWOv7IQRKN5z5B/UT18CB98M0zV19vre5KON6Cu+eVx6oGd4HD GpJv5RgXFcsrlAO3atMfJYHgvjsrEFfxDOPgt111urWKf4TJSIxacntH96MnWls4WTWz 9xpGd8jWVE9sjp+bXZ2i+sgjrIXMgGab1Yf/iwhsYq7J4KwbNdgWb2LYAjJ2mH2srV5+ ka/A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a630c04000000b0045f98453934si16521329pgl.872.2022.10.18.09.31.52; Tue, 18 Oct 2022 09:32:06 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747043721439523532?= X-GMAIL-MSGID: =?utf-8?q?1747043721439523532?= 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 Reviewed-by: Ira Weiny --- 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);