From nobody Sun Dec 14 19:23:18 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE8D82A1D7; Fri, 18 Apr 2025 00:43:20 +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=1744937002; cv=none; b=Z3TWQJ2ZKa7gVYgK0xqSm0wQmC1GX2u3VnVGm8UNEtGi0ofVjN/OBO6UfiR1aVRVEfu2o7gJIFXBXxYzlGs+fJsmeE2+X9wO3dV385F6dzUGHsvpVOtqQEyhhHOgaobC2Fh+OvuQsmEBUcHMMC1GSuaPstacTTszd2Sa6ZISe3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744937002; c=relaxed/simple; bh=wPsRF+g0CgGHIn8Cu2/Fm5NCeD5ZL4NsGfulFAUvTHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=hRMva9BpWzSoMhevLrNFU2XkfGSjjifTE7/VjRNN1avk8UDGkWZPaXIfRpYivCVr8EBIUIr7JUC7zJgkg2jGVBaWGkc7REKPoJAaVmVrX+5Gc8kJOOfbGMYiwW1xzDPDei3MogqNsGXVaVH+d2ahwmgwj8vqZCquFvZHAJlhU2Q= 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=tD/yyzsS; 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="tD/yyzsS" Received: by linux.microsoft.com (Postfix, from userid 1202) id 919042052516; Thu, 17 Apr 2025 17:43:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 919042052516 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1744937000; bh=ngeSLap9FR3I8QT9yiNwCoXHVRvVw9uTKGk8eFA6FUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tD/yyzsSlHwDfXqbv66esrz1SlxSt8JVfxW7bGDLeJ1uzRnpVa45FyQITd39TMS3U gSjOWs7EECBVH0wICKfaFOMJZRpckqzCUjAcCr+p3GdWzqZp+nbkqI2xP/IEdit5mP 1hvWbkpX4AXNPzVhR8KKyo15y/g8zQxcPC5HAO7U= 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 1/2] Drivers: hv: Allocate interrupt and monitor pages aligned to system page boundary Date: Thu, 17 Apr 2025 17:43:16 -0700 Message-Id: <1744936997-7844-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1744936997-7844-1-git-send-email-longli@linuxonhyperv.com> References: <1744936997-7844-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 | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index a7d7494feaca..f426aaa9b8f9 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 --=20 2.34.1