From bf3d08843a415d6871c30e1d7ea1170efeae90ca Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Mon, 19 May 2025 19:49:51 -0700 Subject: [PATCH] ANDROID: 16K: x86_64: Remove /dev/userfaultfd When emulating 16KB page size on x86_64, the kernel presents a 16KB page size to userspace. However the kernel and hardware still operates at a 4KB page size granularity. This mean that even though the mimumun size of memory that userspace can request is 16384 (from mmap); faults still happen at a 4KB granularity in the kernel. This is inherently incompatible with UFFD, which is used by the default ART GC in Android V. Since UFFD necessarily needs to operate on PTEs (4096) but from the client's perspective in userspace the page size is 16384. Don't create /dev/userfaultfd if emulating 16KB (larger than 4KB) page sizes on x86_64. Bug: 409631148 Bug: 379001861 Bug: 384985178 Bug: 377361489 Test: atest vts_linux_kselftest_x86_64:mm_uffd_unit_tests_x86_64#mm_uffd_unit_tests_x86_64 -- --abi x86_64 Change-Id: Idce473108e2275c806eba3815a54f7753e0a1352 Signed-off-by: Kalesh Singh --- fs/userfaultfd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 304a5442cb1f..4539fc167c5e 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -2189,6 +2189,9 @@ static int __init userfaultfd_init(void) { int ret; + if (__PAGE_SIZE != PAGE_SIZE) + return 0; + ret = misc_register(&userfaultfd_misc); if (ret) return ret;