lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260118135126.102472-1-zishun.yi.dev@gmail.com>
Date: Sun, 18 Jan 2026 21:51:26 +0800
From: zishun yi <zishun.yi.dev@...il.com>
To: shuah@...nel.org
Cc: vivek.kasireddy@...el.com,
	akpm@...ux-foundation.org,
	linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	richard.weiyang@...il.com,
	reddybalavignesh9979@...il.com,
	zishun yi <zishun.yi.dev@...il.com>
Subject: [PATCH v1] selftests: udmabuf: fix hugepage size calculation

udmabuf's test 6 and 7 is intended to verify the behavior of 2MB huge pages migration,
but the helper function still calculates the size using standard (4KB) pages.

Signed-off-by: zishun yi <zishun.yi.dev@...il.com>
---
 tools/testing/selftests/drivers/dma-buf/udmabuf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
index d78aec662586..8887fb9b79df 100644
--- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
+++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
@@ -69,7 +69,7 @@ static int create_udmabuf_list(int devfd, int memfd, off64_t memfd_size)
 	for (i = 0; i < NUM_ENTRIES; i++) {
 		list->list[i].memfd  = memfd;
 		list->list[i].offset = i * (memfd_size / NUM_ENTRIES);
-		list->list[i].size   = getpagesize() * NUM_PAGES;
+		list->list[i].size   = page_size * NUM_PAGES;
 	}
 
 	list->count = NUM_ENTRIES;
@@ -115,8 +115,8 @@ static int compare_chunks(void *addr1, void *addr2, off64_t memfd_size)
 	while (i < NUM_ENTRIES) {
 		off = i * (memfd_size / NUM_ENTRIES);
 		for (j = 0; j < NUM_PAGES; j++, k++) {
-			char1 = *((char *)addr1 + off + (j * getpagesize()));
-			char2 = *((char *)addr2 + (k * getpagesize()));
+			char1 = *((char *)addr1 + off + (j * page_size));
+			char2 = *((char *)addr2 + (k * page_size));
 			if (char1 != char2) {
 				ret = -1;
 				goto err;
@@ -126,7 +126,7 @@ static int compare_chunks(void *addr1, void *addr2, off64_t memfd_size)
 	}
 err:
 	munmap(addr1, memfd_size);
-	munmap(addr2, NUM_ENTRIES * NUM_PAGES * getpagesize());
+	munmap(addr2, NUM_ENTRIES * NUM_PAGES * page_size);
 	return ret;
 }
 
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
 	addr1 = mmap_fd(memfd, size);
 	write_to_memfd(addr1, size, 'a');
 	buf = create_udmabuf_list(devfd, memfd, size);
-	addr2 = mmap_fd(buf, NUM_PAGES * NUM_ENTRIES * getpagesize());
+	addr2 = mmap_fd(buf, NUM_PAGES * NUM_ENTRIES * page_size);
 	write_to_memfd(addr1, size, 'b');
 	ret = compare_chunks(addr1, addr2, size);
 	if (ret < 0)
@@ -256,7 +256,7 @@ int main(int argc, char *argv[])
 	size = MEMFD_SIZE * page_size;
 	memfd = create_memfd_with_seals(size, true);
 	buf = create_udmabuf_list(devfd, memfd, size);
-	addr2 = mmap_fd(buf, NUM_PAGES * NUM_ENTRIES * getpagesize());
+	addr2 = mmap_fd(buf, NUM_PAGES * NUM_ENTRIES * page_size);
 	addr1 = mmap_fd(memfd, size);
 	write_to_memfd(addr1, size, 'a');
 	write_to_memfd(addr1, size, 'b');
-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ