From nobody Fri Dec 19 20:12:26 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7854D1A0A12; Wed, 13 Mar 2024 17:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710349507; cv=none; b=byYPqKLrP8Q/Hbl/tVlUwpOz0hLfBw5G0TLiu6wq3dGrN+eK+l8bj7eHyFhOoH+7coyHucRJWtUED6URjw/9jezYDoGF9z3MM2tEzbN8DFeF801JMTiZbfD70157SsyO5pDH0eSOOLwrHpslxDxEse2599WFmEO+HYgi4qIQgDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710349507; c=relaxed/simple; bh=8pkugNJXCAGQDIXWP8dF/TDqhdMUENJaJJI8RkjeAeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uj4FzWcTsGmShT7eGxivjQr/crEGSX/9D5r102VQ8KOAhNbOlNPMt5r5mcq2txviw3mFI2XorZWVB4uiK5E8c1G1G5rWxixoE5sUpwD1bAHA8C/EVAHVUn1bPcbDXXzDQSl7vHLE0H1JTs0OllrP6FAEjC+I6vqj7VRuNRjZjEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r5k/dVVE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r5k/dVVE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDD1FC43399; Wed, 13 Mar 2024 17:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710349507; bh=8pkugNJXCAGQDIXWP8dF/TDqhdMUENJaJJI8RkjeAeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r5k/dVVE2QTUYOvLjD+aFYttX9L5YuqWSt2GPCtT+vtwknRgfRDE08OXYFRtNIlqi Ys1cUywb/fTi6jr1uHO3KqXCw5rUMX+L7W8v5rXoJdCI61MEH1s3AsKu6SOVUF71Gt iyAaRO9/8OQ4T8+HxPRgkLCuSNUBRylzOxy90EuY3aB4Rmr/S5Ul6oH4LyjRd4Jr2g yvt+4jPTm1WrYDqEt/1o22lpwl/QZGn+F87J3iPHdNwC/qDthuzdqNi3kTlnfp/P6k xOViUokphK+loLgA8BNl/yJ/8olFakLuR/dMIGoLK0hljZzTPX4p9KdKmqPrYJxLBY ZHbaeycszrtzQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nico Pache , Donet Tom , Shuah Khan , Christophe Leroy , Michael Ellerman , Andrew Morton , Sasha Levin Subject: [PATCH 4.19 26/41] selftests: mm: fix map_hugetlb failure on 64K page size systems Date: Wed, 13 Mar 2024 13:04:20 -0400 Message-ID: <20240313170435.616724-27-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313170435.616724-1-sashal@kernel.org> References: <20240313170435.616724-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.310-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.310-rc1 X-KernelTest-Deadline: 2024-03-15T17:04+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nico Pache [ Upstream commit 91b80cc5b39f00399e8e2d17527cad2c7fa535e2 ] On systems with 64k page size and 512M huge page sizes, the allocation and test succeeds but errors out at the munmap. As the comment states, munmap will failure if its not HUGEPAGE aligned. This is due to the length of the mapping being 1/2 the size of the hugepage causing the munmap to not be hugepage aligned. Fix this by making the mapping length the full hugepage if the hugepage is larger than the length of the mapping. Link: https://lkml.kernel.org/r/20240119131429.172448-1-npache@redhat.com Signed-off-by: Nico Pache Cc: Donet Tom Cc: Shuah Khan Cc: Christophe Leroy Cc: Michael Ellerman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- tools/testing/selftests/vm/map_hugetlb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selft= ests/vm/map_hugetlb.c index 5a2d7b8efc407..ab349c6db00d4 100644 --- a/tools/testing/selftests/vm/map_hugetlb.c +++ b/tools/testing/selftests/vm/map_hugetlb.c @@ -15,6 +15,7 @@ #include #include #include +#include "vm_util.h" =20 #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -70,10 +71,16 @@ int main(int argc, char **argv) { void *addr; int ret; + size_t hugepage_size; size_t length =3D LENGTH; int flags =3D FLAGS; int shift =3D 0; =20 + hugepage_size =3D default_huge_page_size(); + /* munmap with fail if the length is not page aligned */ + if (hugepage_size > length) + length =3D hugepage_size; + if (argc > 1) length =3D atol(argv[1]) << 20; if (argc > 2) { --=20 2.43.0