From nobody Sat Feb 7 21:52:56 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A10FF2236FD; Wed, 30 Apr 2025 22:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050764; cv=none; b=fuqYRZhaO2mXM+mZnq9i543X2ABiBDEKbR+QP6N5voWWbrwZ84l8YK9BVtv+scq46VX/HnWpVgrk8Sdnkmt5p7wdQl71HbPbhPa22aqlxTkJvuYW0OdMpNHNj2578dsMfxFoSO4FEsKRpiPPskR/mXhiKcGJh9YhNkDz1dvG3rU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050764; c=relaxed/simple; bh=TFis9gHNrqk1OOK9/GuBTdb5nDgh6BXGx7Wi6DhZdyY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ieRX/SBv9zjwKEIbMSCUQXKIxcdAxtTEmhWLUY63AYJAH+7BXbw4HXvQan15QteDFIVAOs+a6WFOiFYMtJX6vDL3YY8aOGi4OeqIEV7XAKKOotpQ66f9xcoM02vi3XdgMSq05grkQo67i3waUeaw0TDWz2rfO9uH3dX9p4soCcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b=GoVn4/UD; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="GoVn4/UD" Received: by linux.microsoft.com (Postfix, from userid 1202) id 281E6204E7FF; Wed, 30 Apr 2025 15:06:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 281E6204E7FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1746050761; bh=PqxNSFralGdoPjwbpzjkm4fl3Ci7ss7SzZhupHdZjQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoVn4/UDSvqHiDhx+vVXHpJQ4TmgXiSK0tnWw69d1s64ZPxMnc6FlHPD8OMEtlD2a h5L1h6iWW0dddyZMAGrTDMWjka7+Zku0uoQYUPh3aexNoHqf5Qa4Dd8QirW56NUpnB Y3G+XSVhaFhsNBk8y5MmZsRZlF43yrsxNPWJdaUE= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Greg Kroah-Hartman , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [Patch v2 1/4] Drivers: hv: Allocate interrupt and monitor pages aligned to system page boundary Date: Wed, 30 Apr 2025 15:05:55 -0700 Message-Id: <1746050758-6829-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> References: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Long Li There are use cases that interrupt and monitor pages are mapped to user-mode through UIO, they need to be system page aligned. Some Hyper-V allocation APIs introduced earlier broke those requirements. Fix those APIs by always allocating Hyper-V page at system page boundaries. Cc: stable@vger.kernel.org Fixes: ca48739e59df ("Drivers: hv: vmbus: Move Hyper-V page allocator to ar= ch neutral code") Signed-off-by: Long Li --- drivers/hv/hv_common.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index a7d7494feaca..297ccd7d4997 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -106,41 +106,26 @@ void __init hv_common_free(void) } =20 /* - * Functions for allocating and freeing memory with size and - * alignment HV_HYP_PAGE_SIZE. These functions are needed because - * the guest page size may not be the same as the Hyper-V page - * size. We depend upon kmalloc() aligning power-of-two size - * allocations to the allocation size boundary, so that the - * allocated memory appears to Hyper-V as a page of the size - * it expects. + * A Hyper-V page can be used by UIO for mapping to user-space, it should + * always be allocated on system page boundaries. */ - void *hv_alloc_hyperv_page(void) { - BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); - - if (PAGE_SIZE =3D=3D HV_HYP_PAGE_SIZE) - return (void *)__get_free_page(GFP_KERNEL); - else - return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); + return (void *)__get_free_page(GFP_KERNEL); } EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page); =20 void *hv_alloc_hyperv_zeroed_page(void) { - if (PAGE_SIZE =3D=3D HV_HYP_PAGE_SIZE) - return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); - else - return kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); + return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); } EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page); =20 void hv_free_hyperv_page(void *addr) { - if (PAGE_SIZE =3D=3D HV_HYP_PAGE_SIZE) - free_page((unsigned long)addr); - else - kfree(addr); + free_page((unsigned long)addr); } EXPORT_SYMBOL_GPL(hv_free_hyperv_page); =20 @@ -272,7 +257,7 @@ static void hv_kmsg_dump_unregister(void) atomic_notifier_chain_unregister(&panic_notifier_list, &hyperv_panic_report_block); =20 - hv_free_hyperv_page(hv_panic_page); + kfree(hv_panic_page); hv_panic_page =3D NULL; } =20 @@ -280,7 +265,7 @@ static void hv_kmsg_dump_register(void) { int ret; =20 - hv_panic_page =3D hv_alloc_hyperv_zeroed_page(); + hv_panic_page =3D kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); if (!hv_panic_page) { pr_err("Hyper-V: panic message page memory allocation failed\n"); return; @@ -289,7 +274,7 @@ static void hv_kmsg_dump_register(void) ret =3D kmsg_dump_register(&hv_kmsg_dumper); if (ret) { pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret); - hv_free_hyperv_page(hv_panic_page); + kfree(hv_panic_page); hv_panic_page =3D NULL; } } --=20 2.34.1 From nobody Sat Feb 7 21:52:56 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3374E22331C; Wed, 30 Apr 2025 22:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050765; cv=none; b=fR2UpaTW4fR16C3GJNlDbvktuJHtU+3cKU/PpnUD2qkQ9iXeAyr0lPicqxTRg0Kzqba4rjBSJ8VWORdPIAIsI0dJQuqVn8XdbQIZMUt+BbGwZ2FoQ92KM4mwR9fYdW+ej/QujjpSidf4IR43rdbd1KxP0pb0HXJfwi8g+QO0ZD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050765; c=relaxed/simple; bh=CcTWI7FuPMWJcnrhBbCO+CeRY9DtaORQiOzNsDkNitc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=cO5wUkcOxOzuhCMPorzS/rGU14Du1JIA+fHDEc21s4HTqcTaSr11j+c52S6jTB5NVC5aSsGJMArVScqxmvdy2vgPRVKESeTR2M9OZFKacTj4h7yQQhqq4V3yqQokYBZLWxLcbFC+NXRhQl17hLnHq0acXJiiXtNRb/2DEHMJW0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b=a2mpgc2X; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="a2mpgc2X" Received: by linux.microsoft.com (Postfix, from userid 1202) id D3D6F204E7FD; Wed, 30 Apr 2025 15:06:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D3D6F204E7FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1746050761; bh=Tv99LGSGPSCu8e4+xjFTlVcnfQVc8DLTvncQgdvLHFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a2mpgc2XJgLHFUTTxEns3eEN2FCDa6f/4gn0EFkCO7zuF/6nG0scerSL0jE908ewf v90IqT/BD7mBctbrBFKZ7okYtrCRmwaB6tTNVPGgdOYpMAh/IGjEeBioObQfFqn1Ja TfHgYO5cqTOLVK4KJE4tlypehLN+PSGTGyaowjPM= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Greg Kroah-Hartman , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [Patch v2 2/4] uio_hv_generic: Use correct size for interrupt and monitor pages Date: Wed, 30 Apr 2025 15:05:56 -0700 Message-Id: <1746050758-6829-3-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> References: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Long Li Interrupt and monitor pages should be in Hyper-V page size (4k bytes). This can be different to the system page size. This size is read and used by the user-mode program to determine the mapped data region. An example of such user-mode program is the VMBUS driver in DPDK. Cc: stable@vger.kernel.org Fixes: 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus") Signed-off-by: Long Li --- drivers/uio/uio_hv_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c index 1b19b5647495..08385b04c4ab 100644 --- a/drivers/uio/uio_hv_generic.c +++ b/drivers/uio/uio_hv_generic.c @@ -287,13 +287,13 @@ hv_uio_probe(struct hv_device *dev, pdata->info.mem[INT_PAGE_MAP].name =3D "int_page"; pdata->info.mem[INT_PAGE_MAP].addr =3D (uintptr_t)vmbus_connection.int_page; - pdata->info.mem[INT_PAGE_MAP].size =3D PAGE_SIZE; + pdata->info.mem[INT_PAGE_MAP].size =3D HV_HYP_PAGE_SIZE; pdata->info.mem[INT_PAGE_MAP].memtype =3D UIO_MEM_LOGICAL; =20 pdata->info.mem[MON_PAGE_MAP].name =3D "monitor_page"; pdata->info.mem[MON_PAGE_MAP].addr =3D (uintptr_t)vmbus_connection.monitor_pages[1]; - pdata->info.mem[MON_PAGE_MAP].size =3D PAGE_SIZE; + pdata->info.mem[MON_PAGE_MAP].size =3D HV_HYP_PAGE_SIZE; pdata->info.mem[MON_PAGE_MAP].memtype =3D UIO_MEM_LOGICAL; =20 if (channel->device_id =3D=3D HV_NIC) { --=20 2.34.1 From nobody Sat Feb 7 21:52:56 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0FCD221729; Wed, 30 Apr 2025 22:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050764; cv=none; b=RkNYwKwbFsVg2zEfS+eQ3L61EPJ4FxKe02lgnfFCZOkcqqUvlpzuJznn3FpFyAyAYOJEKNjvIM2dxIBgR2Th2VoIz+QA1+ymQr2k1CuawwduRlJnDqDpjXZ9eLopjZkxw7uuPaNG+quQxmkJwTlG9EjX7NozeMDZj3nfX0YkRX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050764; c=relaxed/simple; bh=5fuitnncfD5tDUPddDF+UDVEs5aeUDwBqWLUYZxf27Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=I5QqKK5H1dBAj3wAUhdQJLw3d7yu/4wB980ENk1GyjBvlEddWRNYSs7b0BEYWqVGfGbAbNIo06/N4VqyxZiv5cXe5Wr+SeD3weOL3Sgfqarf4tKAoATB6j1rFTFzd8QbB9QCxfFXAtbVEOs5BfdFgj+DRNN8/oTfdvb25E6tTKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b=iImSj47e; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="iImSj47e" Received: by linux.microsoft.com (Postfix, from userid 1202) id 86A98204E7FE; Wed, 30 Apr 2025 15:06:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 86A98204E7FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1746050762; bh=cEirtZm/SmFjzm0Vy14RfmaUhYtp12qkUzkZo1lRLGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iImSj47e07xsBznoeQZejw+4P9PkzBztTIYHqH5HzOisxe8kF32Im5Zu5RPLNfmAe N3xgl/l7sXhWbrUKmJxwd4csshn+X7AMecSc+A8liwJXMf2Ye83MdsnEUwPFfU529I 7fJr1M+maMSvsMIPJx9QQdclIWboWJXu0CHDwZkk= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Greg Kroah-Hartman , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [Patch v2 3/4] uio_hv_generic: Adjust ring size according to system page alignment Date: Wed, 30 Apr 2025 15:05:57 -0700 Message-Id: <1746050758-6829-4-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> References: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Long Li Following the ring header, the ring data should align to system page boundary. Adjust the size if necessary. Cc: stable@vger.kernel.org Fixes: 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus") Signed-off-by: Long Li --- drivers/uio/uio_hv_generic.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c index 08385b04c4ab..dfc5f0e1a254 100644 --- a/drivers/uio/uio_hv_generic.c +++ b/drivers/uio/uio_hv_generic.c @@ -256,6 +256,12 @@ hv_uio_probe(struct hv_device *dev, if (!ring_size) ring_size =3D SZ_2M; =20 + /* + * Adjust ring size if necessary to have the ring data region page + * aligned + */ + ring_size =3D VMBUS_RING_SIZE(ring_size); + pdata =3D devm_kzalloc(&dev->device, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; --=20 2.34.1 From nobody Sat Feb 7 21:52:56 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2429922370A; Wed, 30 Apr 2025 22:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050766; cv=none; b=Ec/GY+MZycOZ5IYOtv1cNSKndn5PM0n/ndDN4hGoR9gcDnx5CTrZlTS4lSsbd+uzLkE6U9RAq2BxxyM3mY/9euVqrcHdQ2bDltan2E+wCX3VBMrh/sGoztWjLQxg7GH1QNUD4dWBIQ5YjyMec2RQ6XMBUpqDGlE9jjqLFn7Bn/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746050766; c=relaxed/simple; bh=Ip8kCIs/NCxhLce9W0wi+ojRYSwPsFGesZ5pyNqongM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=V0gxJS7R3p5o1E63+805kV8QHfHKsLY27oCvScp5TmtycqlKt5ZivGcE2gnDfjEdcbJJ47WJrIaURxOtNuJmGU0s8PRPo+9zFkmsxZaXPJjj/xaNaNxyZMVTeMV36HlBd/8at5bbczVMLi23COvr27nP+6j2Hes7Yf96GYC1ccI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b=ATtOmQef; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxonhyperv.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="ATtOmQef" Received: by linux.microsoft.com (Postfix, from userid 1202) id C526021130A4; Wed, 30 Apr 2025 15:06:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C526021130A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1746050763; bh=oEUBSZ8NILqC1QUWEk7J5DCevmeOgK9HDP3Grif/Ql8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ATtOmQefJCnNfY+URkn72qohw97BvneZDHlZ2fTk3PYu6CMVsqYOU8MbHanRKhlCD qnErqWnZpWDes6gdMonAMAoN1G78LulTcm56cBGd5HyQ5bnwsYykhUsAR+h33CMjNx o9X2sNajZGpSBacvyA7JXQUEbPhuC4LOhuL7/qPs= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Greg Kroah-Hartman , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [Patch v2 4/4] Drivers: hv: Remove hv_free/alloc_* helpers Date: Wed, 30 Apr 2025 15:05:58 -0700 Message-Id: <1746050758-6829-5-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> References: <1746050758-6829-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Long Li Those helpers are simply wrappers for page allocations. Signed-off-by: Long Li --- drivers/hv/connection.c | 23 +++++++++++++++++------ drivers/hv/hv_common.c | 24 ------------------------ include/asm-generic/mshyperv.h | 4 ---- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 8351360bba16..a0160b73b593 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -206,11 +206,20 @@ int vmbus_connect(void) INIT_LIST_HEAD(&vmbus_connection.chn_list); mutex_init(&vmbus_connection.channel_mutex); =20 + /* + * The following Hyper-V interrupt and monitor pages can be used by + * UIO for mapping to user-space, it should always be allocated on + * system page boundaries. We use page allocation functions to allocate + * those pages. We assume system page be bigger than Hyper-v page. + */ + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); + /* * Setup the vmbus event connection for channel interrupt * abstraction stuff */ - vmbus_connection.int_page =3D hv_alloc_hyperv_zeroed_page(); + vmbus_connection.int_page =3D + (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); if (vmbus_connection.int_page =3D=3D NULL) { ret =3D -ENOMEM; goto cleanup; @@ -225,8 +234,8 @@ int vmbus_connect(void) * Setup the monitor notification facility. The 1st page for * parent->child and the 2nd page for child->parent */ - vmbus_connection.monitor_pages[0] =3D hv_alloc_hyperv_page(); - vmbus_connection.monitor_pages[1] =3D hv_alloc_hyperv_page(); + vmbus_connection.monitor_pages[0] =3D (void *)__get_free_page(GFP_KERNEL); + vmbus_connection.monitor_pages[1] =3D (void *)__get_free_page(GFP_KERNEL); if ((vmbus_connection.monitor_pages[0] =3D=3D NULL) || (vmbus_connection.monitor_pages[1] =3D=3D NULL)) { ret =3D -ENOMEM; @@ -342,21 +351,23 @@ void vmbus_disconnect(void) destroy_workqueue(vmbus_connection.work_queue); =20 if (vmbus_connection.int_page) { - hv_free_hyperv_page(vmbus_connection.int_page); + free_page((unsigned long)vmbus_connection.int_page); vmbus_connection.int_page =3D NULL; } =20 if (vmbus_connection.monitor_pages[0]) { if (!set_memory_encrypted( (unsigned long)vmbus_connection.monitor_pages[0], 1)) - hv_free_hyperv_page(vmbus_connection.monitor_pages[0]); + free_page((unsigned long) + vmbus_connection.monitor_pages[0]); vmbus_connection.monitor_pages[0] =3D NULL; } =20 if (vmbus_connection.monitor_pages[1]) { if (!set_memory_encrypted( (unsigned long)vmbus_connection.monitor_pages[1], 1)) - hv_free_hyperv_page(vmbus_connection.monitor_pages[1]); + free_page((unsigned long) + vmbus_connection.monitor_pages[1]); vmbus_connection.monitor_pages[1] =3D NULL; } } diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 297ccd7d4997..421376cea17e 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -105,30 +105,6 @@ void __init hv_common_free(void) hv_synic_eventring_tail =3D NULL; } =20 -/* - * A Hyper-V page can be used by UIO for mapping to user-space, it should - * always be allocated on system page boundaries. - */ -void *hv_alloc_hyperv_page(void) -{ - BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); - return (void *)__get_free_page(GFP_KERNEL); -} -EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page); - -void *hv_alloc_hyperv_zeroed_page(void) -{ - BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); - return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); -} -EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page); - -void hv_free_hyperv_page(void *addr) -{ - free_page((unsigned long)addr); -} -EXPORT_SYMBOL_GPL(hv_free_hyperv_page); - static void *hv_panic_page; =20 /* diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index ccccb1cbf7df..4033508fbb11 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -236,10 +236,6 @@ int hv_common_cpu_init(unsigned int cpu); int hv_common_cpu_die(unsigned int cpu); void hv_identify_partition_type(void); =20 -void *hv_alloc_hyperv_page(void); -void *hv_alloc_hyperv_zeroed_page(void); -void hv_free_hyperv_page(void *addr); - /** * hv_cpu_number_to_vp_number() - Map CPU to VP. * @cpu_number: CPU number in Linux terms --=20 2.34.1