Gentoo Archives: gentoo-hardened

From: Yannis Kontekakis <tolis@×××××××××××.gr>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] erlang fails to install on kvm guest (illegal instruction) - solved
Date: Wed, 21 Nov 2012 15:02:23
Message-Id: 50ACD496.4090609@foss.teithe.gr
In Reply to: Re: [gentoo-hardened] erlang fails to install on kvm guest (illegal instruction) by Yannis Kontekakis
1 On 11/20/2012 06:28 PM, Yannis Kontekakis wrote:
2 > On 11/20/2012 06:13 PM, Alexander Tsoy wrote:
3 >> В Tue, 20 Nov 2012 17:50:36 +0200
4 >> Yannis Kontekakis<tolis@×××××××××××.gr> пишет:
5 >>
6 >>> On 11/20/2012 05:34 PM, Alexander Tsoy wrote:
7 >>>> В Tue, 20 Nov 2012 16:54:39 +0200
8 >>>> Yannis Kontekakis<tolis@×××××××××××.gr> пишет:
9 >>>>
10 >>>>> Hello,
11 >>>>>
12 >>>>> I am trying to install erlang on a hardened amd64 gentoo system
13 >>>>> running
14 >>>>> on a kvm guest. The use flags and version of erlang are the
15 >>>>> following:
16 >>>>>
17 >>>>> dev-lang/erlang-15.2 USE="hipe java kpoll odbc smp ssl
18 >>>>> -compat-ethread
19 >>>>> -doc -emacs -halfword -sctp -tk -wxwidgets"
20 >>>>>
21 >>>>> my CFLAGS are:
22 >>>>> CFLAGS="-march=core2 -O2 -pipe"
23 >>>>> CXXFLAGS="${CFLAGS}"
24 >>>>>
25 >>>>> cat /proc/cpuinfo reports 4 cores of:
26 >>>>>
27 >>>>> processor : 3
28 >>>>> vendor_id : AuthenticAMD
29 >>>>> cpu family : 6
30 >>>>> model : 2
31 >>>>> model name : QEMU Virtual CPU version 1.0
32 >>>>> stepping : 3
33 >>>>> microcode : 0x1000065
34 >>>>> cpu MHz : 2100.278
35 >>>>> cache size : 512 KB
36 >>>>> fpu : yes
37 >>>>> fpu_exception : yes
38 >>>>> cpuid level : 4
39 >>>>> wp : yes
40 >>>>> flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge
41 >>>>> mca cmov
42 >>>>> pat pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl pni cx16
43 >>>>> popcnt
44 >>>>> hypervisor lahf_lm svm abm sse4a
45 >>>>> bogomips : 4200.55
46 >>>>> TLB size : 1024 4K pages
47 >>>>> clflush size : 64
48 >>>>> cache_alignment : 64
49 >>>>> address sizes : 40 bits physical, 48 bits virtual
50 >>>>> power management:
51 >>>>>
52 >>>>> the error message that emerge prints while dying:
53 >>>>>
54 >>>>> === Entering application hipe
55 >>>>> make[3]: Entering directory
56 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib/hipe/rtl'
57 >>>>>
58 >>>>> (cd ../main&& make hipe.hrl)
59 >>>>> make[4]: Entering directory
60 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib/hipe/main'
61 >>>>>
62 >>>>> sed -e "s;%VSN%;3.9;" ../../hipe/main/hipe.hrl.src>
63 >>>>> ../../hipe/main/hipe.hrl
64 >>>>> make[4]: Leaving directory
65 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib/hipe/main'
66 >>>>>
67 >>>>> erlc -W +debug_info +inline -o../ebin hipe_rtl.erl
68 >>>>> make[3]: *** [../ebin/hipe_rtl.beam] Illegal instruction
69 >>>>> make[3]: Leaving directory
70 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib/hipe/rtl'
71 >>>>>
72 >>>>> make[2]: *** [opt] Error 2
73 >>>>> make[2]: Leaving directory
74 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib/hipe'
75 >>>>> make[1]: *** [opt] Error 2
76 >>>>> make[1]: Leaving directory
77 >>>>> `/var/tmp/portage/dev-lang/erlang-15.2/work/otp_src_R15B/lib'
78 >>>>> make: *** [secondary_bootstrap_build] Error 2
79 >>>>> emake failed
80 >>>>> * ERROR: dev-lang/erlang-15.2 failed (compile phase):
81 >>>>> * (no error message)
82 >>>>> *
83 >>>>> * Call stack:
84 >>>>> * ebuild.sh, line 93: Called src_compile
85 >>>>> * environment, line 3965: Called die
86 >>>>> * The specific snippet of code:
87 >>>>> * emake -j1 || die;
88 >>>>> *
89 >>>>>
90 >>>>> And finally, dmesg reports:
91 >>>>> beam.smp[27752] trap invalid opcode ip:54b49c00c4 sp:3d9f459d3f0
92 >>>>> error:0
93 >>>>> in beam.smp[54b48e4000+261000]
94 >>>>>
95 >>>>> Emerging erlang on my desktop(a similar hardened gentoo setup)
96 >>>>> completes
97 >>>>> successfully. The only thing I can think of is that something is
98 >>>>> wrong
99 >>>>> with my CFLAGS(but this is just an assumption).
100 >>>>>
101 >>>>> Any help would be appreciated
102 >>>>>
103 >>>>> Regards,
104 >>>>>
105 >>>>> Yannis
106 >>>>>
107 >>>> It seems that KVM host is and AMD-based system. I suggest you to drop
108 >>>> "-march=core2" from CFLAGS. Or if you do not plan to migrate this VM
109 >>>> you can also try to replace it with something like "-march=amdfam10
110 >>>> -mno-3dnow". :)
111 >>>>
112 >>> I thought so... I now have to rebuild the whole world :) Is anyone
113 >>> aware
114 >>> of an -march value that can be used interchangeably between 64bit intel
115 >>> & amd cpus? The kvm host is not under my administration, so at any
116 >>> time
117 >>> my guest could be switched between hosts.
118 >>>
119 >> Simply do not use -march:
120 >> CFLAGS="-O2 -pipe"
121 >> Binaries compiled with this cflags should work on any x86_64 system.
122 >>
123 > Thanks. I will go with it.
124 >
125
126 After reemerging world with the aforementioned CFLAGS everything worked
127 just fine.
128
129 Thank you