Message ID | 20221020083820.2341088-1-zhao1.liu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp137286wrs; Thu, 20 Oct 2022 01:38:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WBDvTpRvADalUDgIswIe3IOU5zhm8jEKq1cqK+3x3u+UiHIOh9XTXTXRr7cZfI9uDNw8O X-Received: by 2002:a17:907:c05:b0:73d:6e0a:8d22 with SMTP id ga5-20020a1709070c0500b0073d6e0a8d22mr10055924ejc.646.1666255113190; Thu, 20 Oct 2022 01:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666255113; cv=none; d=google.com; s=arc-20160816; b=v467OhqKz16SIg4UA1Su8PlFuUiil8H+ePBrnHCPsHjGZGdd+UAkZz2gNZNFgjwvGT XlTC7AXLCkABWjA3LL4UbfuDugO3QmJAGqZyOsVZrLzH4GGAdE1PSFTVWRYXKOAz9hh6 X3vxtbYxOSFcJ5YuoQG/3GENMFXlufVqwaFWvhenAJoZZYa6T6C+ymllrwDdAM+gnYFe 6v9ODL3jce8wV453uomYobVL2gkpgDwp7SFgB662i8HLidb0t+Zj+fBAd7gvxTp7DReY VStyLTHN3vvdYeVAi3sgDSevFzMiFMz8OdSBfHdGrZzN7OPZblcZpxWEkY3PJTLqUYBG i0nw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056402350b00b0045cbe305b94si18673002edd.365.2022.10.20.01.38.07; Thu, 20 Oct 2022 01:38:33 -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 <rfc822;realc9580@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <zhao1.liu@linux.intel.com> To: "K . Y . Srinivasan" <kys@microsoft.com>, Haiyang Zhang <haiyangz@microsoft.com>, Stephen Hemminger <sthemmin@microsoft.com>, Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny <ira.weiny@intel.com>, "Fabio M . De Francesco" <fmdefrancesco@gmail.com>, Zhenyu Wang <zhenyu.z.wang@intel.com>, Zhao Liu <zhao1.liu@intel.com> 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: <linux-kernel.vger.kernel.org> 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?1747195121530090004?= |
Series |
[v2] x86/hyperv: Remove BUG_ON() for kmap_local_page()
|
|
Commit Message
Zhao Liu
Oct. 20, 2022, 8:38 a.m. UTC
From: Zhao Liu <zhao1.liu@intel.com> 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 <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> --- Change in v2: - Removed "Fixes" tag in patch message. --- arch/x86/hyperv/hv_init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Comments
On Thu, Oct 20, 2022 at 04:38:20PM +0800, Zhao Liu wrote: > From: Zhao Liu <zhao1.liu@intel.com> > > 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 <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> Applied to hyperv-fixes. Thanks.
On Wed, Oct 26, 2022 at 03:17:18PM +0000, Wei Liu wrote: > Date: Wed, 26 Oct 2022 15:17:18 +0000 > From: Wei Liu <wei.liu@kernel.org> > Subject: Re: [PATCH v2] x86/hyperv: Remove BUG_ON() for kmap_local_page() > > On Thu, Oct 20, 2022 at 04:38:20PM +0800, Zhao Liu wrote: > > From: Zhao Liu <zhao1.liu@intel.com> > > > > 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 <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> > > Applied to hyperv-fixes. Thanks. Sorry Wei, I appology for not deleting unused variables, which caused the next tree break. Do I need to send another v3 to make up for my carelessness? Zhao
On Thu, Oct 27, 2022 at 06:05:48PM +0800, Zhao Liu wrote: > On Wed, Oct 26, 2022 at 03:17:18PM +0000, Wei Liu wrote: > > Date: Wed, 26 Oct 2022 15:17:18 +0000 > > From: Wei Liu <wei.liu@kernel.org> > > Subject: Re: [PATCH v2] x86/hyperv: Remove BUG_ON() for kmap_local_page() > > > > On Thu, Oct 20, 2022 at 04:38:20PM +0800, Zhao Liu wrote: > > > From: Zhao Liu <zhao1.liu@intel.com> > > > > > > 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 <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> > > > > Applied to hyperv-fixes. Thanks. > > Sorry Wei, I appology for not deleting unused variables, which caused > the next tree break. Do I need to send another v3 to make up for my > carelessness? There is no need to send v3. I've dealt with it. Thanks, Wei.
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);