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 <qal@google.com>
This commit is contained in:
Quang Luong 2017-07-17 18:03:13 -07:00
parent 3f4cea940d
commit dd6a85ccd5
2 changed files with 8 additions and 1 deletions

View file

@ -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 \

View file

@ -379,7 +379,10 @@ static int set_mmap_rnd_bits_action(const std::vector<std::string>& 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)) {