ANDROID: 16K: x86_64: Disable 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.

Disable the UFFD if emulating 16KB (larger than 4KB) page sizes on
x86_64.

Bug: 383389337
Bug: 379001861
Bug: 384985178
Bug: 377361489
Test: Tested on Android Studio x86_64 emulator no system restarts.
Test: grep -i 'collectortype' logcat; Expect collector type CC instead
      of collectortype CMC (UFFD GC)
Change-Id: Idad47e5f57aa1843921d550f16f248ed34da2100
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2024-12-18 18:23:54 -08:00
committed by Carlos Llamas
parent c94c31e526
commit 596774b15c

View File

@@ -18,6 +18,7 @@
#include <linux/mm_inline.h>
#include <linux/mmu_notifier.h>
#include <linux/poll.h>
#include <linux/page_size_compat.h>
#include <linux/slab.h>
#include <linux/seq_file.h>
#include <linux/file.h>
@@ -2154,6 +2155,9 @@ static inline bool userfaultfd_syscall_allowed(int flags)
SYSCALL_DEFINE1(userfaultfd, int, flags)
{
if (__PAGE_SIZE != PAGE_SIZE)
return -EOPNOTSUPP;
if (!userfaultfd_syscall_allowed(flags))
return -EPERM;