-
- Downloads
x86: Fix boot failure for GCC 4.9-built kernels
The current default cross toolchain for building x86 and x86_64 emulator kernels is GCC 4.8, i.e. $AOSP/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8 on Linux hosts. It is also possible to build these kernels with GCC 4.9 ($AOSP/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9), but unfortunately, the generated kernel images are not bootable. This issue affects both 3.4 and 3.10 kernels, and in the case of 3.10, both classic (goldfish) and ranchu configurations. The immediate cause of the boot failure is an invalid opcode exception (escalating into a triple fault). The offending instruction is MOVDQA, which belongs to the SSE2 instruction set. A postmortem on the vCPU shows that the kernel is in an early boot stage, because paging (CR0.PG) is not yet enabled. Nor is CR4.OSFXSR, which is in fact a prerequisite for any SSE instructions, hence the exception. The solution is to instruct GCC not to use SSE when compiling code for x86 boot. This is done by back-porting the following patches from upstream: 5c630089 x86/kbuild: Eliminate duplicate command line options 8b3b005d x86, build: Pass in additional -mno-mmx, -mno-sse options 5551a34e x86-64, build: Always pass in -mno-sse As to why GCC 4.9 behaves differently from GCC 4.8, this line from the GCC 4.9 changelog (https://gcc.gnu.org/gcc-4.9/changes.html) offers a possible explanation: * -mfpmath=sse is now implied by -ffast-math on all targets where SSE2 is supported. See https://android-review.googlesource.com/161639 for the related change in the 3.10 kernel. Change-Id: I4bdf6cda44e3c576dce6510409daa8f3835a0e4f Signed-off-by:Yu Ning <yu.ning@intel.com> (cherry picked from commit 6e093637)
Please register or sign in to comment