From dd6a85ccd54dec45bb555a68923a6facb308ecc5 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 17 Jul 2017 18:03:13 -0700 Subject: [PATCH] uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp Modified Android.mk to define cflag "USER_MODE_LINUX" if TARGET_USER_MODE_LINUX := true in BoardCofig.mk. Modified set_mmap_rnd_bits_action to return 0 if "USER_MODE_LINUX" is defined. This is needed since uml does not support the mmap_rnd_bits sysctl, and init would otherwise crash without this check. Test: manual Bug: 32523022 Change-Id: I409ef64a1fa253bfb3f9fb59d0267be159819bb8 Signed-off-by: Quang Luong --- init/Android.mk | 4 ++++ init/init.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/init/Android.mk b/init/Android.mk index 6cd47f476..325614e3a 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -30,6 +30,10 @@ endif init_options += -DLOG_UEVENTS=0 +ifeq ($(TARGET_USER_MODE_LINUX), true) + init_cflags += -DUSER_MODE_LINUX +endif + init_cflags += \ $(init_options) \ -Wall -Wextra \ diff --git a/init/init.cpp b/init/init.cpp index 0562dad2b..ec43cb438 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -379,7 +379,10 @@ static int set_mmap_rnd_bits_action(const std::vector& args) int ret = -1; /* values are arch-dependent */ -#if defined(__aarch64__) +#if defined(USER_MODE_LINUX) + /* uml does not support mmap_rnd_bits */ + ret = 0; +#elif defined(__aarch64__) /* arm64 supports 18 - 33 bits depending on pagesize and VA_SIZE */ if (set_mmap_rnd_bits_min(33, 24, false) && set_mmap_rnd_bits_min(16, 16, true)) {