Bug 196689 - 4.12.5 compile fails -- Error: instruction `andn' isn't supported in 16-bit mode.
Summary: 4.12.5 compile fails -- Error: instruction `andn' isn't supported in 16-bit m...
Status: CLOSED INVALID
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: other_configuration@kernel-bugs.osdl.org
URL: https://bugs.gentoo.org/show_bug.cgi?...
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-17 10:43 UTC by Alex
Modified: 2018-06-27 00:53 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.12.5
Subsystem:
Regression: No
Bisected commit-id:


Attachments
kernel config (90.84 KB, text/plain)
2017-08-17 10:43 UTC, Alex
Details
/proc/cpuinfo (4.43 KB, text/plain)
2017-08-17 10:44 UTC, Alex
Details
cpucheck.S (57.37 KB, text/plain)
2017-08-17 20:49 UTC, Alex
Details
cpucheck.SV (verbose) (63.64 KB, text/plain)
2017-08-17 20:49 UTC, Alex
Details

Description Alex 2017-08-17 10:43:55 UTC
Created attachment 257989 [details]
kernel config

Hi,

While usual kernel update from 4.9.34 to 4.12.5 it fails with the error:

-------------------------------------------------------------
/tmp/cc3rZjPi.s: Assembler messages:
/tmp/cc3rZjPi.s:32: Error: instruction `andn' isn't supported in 16-bit mode.
/tmp/cc3rZjPi.s:40: Error: instruction `shlx' isn't supported in 16-bit mode.
make[1]: *** [scripts/Makefile.build:302: arch/x86/boot/cpucheck.o] Error 1
make: *** [arch/x86/Makefile:281: bzImage] Error 2
make: *** Waiting for unfinished jobs....
------------------------------------------------------------

There's neither boot image in /boot, nor modules in /lib/modules installed.

I've never seen errors like that before, and have no idea how to fix or debug this issue...

My compiling options:

KCFLAGS="-O2 -march=native -fno-stack-protector -fomit-frame-pointer" KCPPFLAGS=$KCFLAGS KCXXFLAGS=$KCFLAGS make -j4 && make modules_install && make install 2>&1

Also tried with "-O3" and without any "-O" -- same error.

The same issue on Gentoo bugtracker https://bugs.gentoo.org/show_bug.cgi?id=627890

Regards,
Alex
Comment 1 Alex 2017-08-17 10:44:31 UTC
Created attachment 257991 [details]
/proc/cpuinfo
Comment 2 Alex 2017-08-17 20:48:17 UTC
Tried to debug this issue following this https://sourceware.org/bugzilla/show_bug.cgi?id=17421

With "make V=1 -j1" The last command before fail is:
------------------------------------------------------------------
gcc -Wp,-MD,arch/x86/boot/.cpucheck.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -O2 -march=native -fno-stack-protector -fomit-frame-pointer -m16 -g -Os -D__KERNEL__ -DDISABLE_BRANCH_PROFILING -Wall -Wstrict-prototypes -march=i386 -mregparm=3 -fno-strict-aliasing -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -ffreestanding -fno-stack-protector -D_SETUP    -DKBUILD_BASENAME='"cpucheck"'  -DKBUILD_MODNAME='"cpucheck"' -c -o arch/x86/boot/cpucheck.o arch/x86/boot/cpucheck.c
---------------------------------------------------------------

Adjusted it to get asm source:
------------------------------------------------------------------
gcc -Wp,-MD,arch/x86/boot/.cpucheck.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -O2 -march=native -fno-stack-protector -fomit-frame-pointer -m16 -g -Os -D__KERNEL__ -DDISABLE_BRANCH_PROFILING -Wall -Wstrict-prototypes -march=i386 -mregparm=3 -fno-strict-aliasing -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -ffreestanding -fno-stack-protector -D_SETUP    -DKBUILD_BASENAME='"cpucheck"'  -DKBUILD_MODNAME='"cpucheck"' -c -S -o arch/x86/boot/cpucheck.S arch/x86/boot/cpucheck.c
-----------------------------------------------------------------

Compiling the resulted cpucheck.S gives (almost) the same errors:
-------------------------------------------------------------------
# as  arch/x86/boot/cpucheck.S -c -o temp.o
arch/x86/boot/cpucheck.S: Assembler messages:
arch/x86/boot/cpucheck.S:32: Error: instruction `andn' isn't supported in 16-bit mode.
arch/x86/boot/cpucheck.S:40: Error: instruction `shlx' isn't supported in 16-bit mode.
arch/x86/boot/cpucheck.S:84: Error: register save offset not a multiple of 8
arch/x86/boot/cpucheck.S:91: Error: register save offset not a multiple of 8
----------------------------------------------------------------

Adjusted the command again to get more verbose asm source. Compiling cpucheck.SV also shows the same errors:
------------------------------------------------------------------------
# as  arch/x86/boot/cpucheck.SV -c -o temp.o
arch/x86/boot/cpucheck.SV: Assembler messages:
arch/x86/boot/cpucheck.SV:105: Error: instruction `andn' isn't supported in 16-bit mode.
arch/x86/boot/cpucheck.SV:113: Error: instruction `shlx' isn't supported in 16-bit mode.
arch/x86/boot/cpucheck.SV:157: Error: register save offset not a multiple of 8
arch/x86/boot/cpucheck.SV:164: Error: register save offset not a multiple of 8
-------------------------------------------------------------------------------

Both cpucheck.S and cpucheck.SV are attached and they do have the specified instructions in specified lines.

However, I still have no idea how to fix it.
Comment 3 Alex 2017-08-17 20:49:19 UTC
Created attachment 258003 [details]
cpucheck.S
Comment 4 Alex 2017-08-17 20:49:45 UTC
Created attachment 258005 [details]
cpucheck.SV (verbose)
Comment 5 Alex 2017-08-17 21:05:10 UTC
It seems to me something is wrong with AND NOT and left shift in this function of cpucheck.c:

-----------------------------------------------------------------------
/* Returns a bitmask of which words we have error bits in */
static int check_cpuflags(void)
{
	u32 err;
	int i;

	err = 0;
	for (i = 0; i < NCAPINTS; i++) {
		err_flags[i] = req_flags[i] & ~cpu.flags[i];
		if (err_flags[i])
			err |= 1 << i;
	}

	return err;
}
------------------------------------------------------------------------
Comment 7 Alex 2017-08-18 20:41:52 UTC
The bug finally landed here https://sourceware.org/bugzilla/show_bug.cgi?id=21965

4.12.5 builds with gcc-5.4.0 and '--march=broadwell'

Sorry, kernel guys.

Regards,
Alex
Comment 8 Randy Dunlap 2018-03-08 02:36:48 UTC
Needs newer gcc or don't use -march=native.

Note You need to log in before you can comment on or make changes to this bug.