# FreeBSD 11.2 kernel recompile throws AVX errors



## teekwan (May 22, 2019)

Hi!

I'm not very experienced with kernel recompiles so you'll excuse some of my ignorances 
I've tried to find any bit of info that could help me to resolve this but since I was unable to, I decided to post here
Anyway I need multiple FIBs and that's why I wanted to recompile the kernel.
I've made a file containing this:

```
include GENERIC
ident NEWKERN

options      ROUTETABLES=5        # Add support for 3 FIB routing tables
options        IPFIREWALL
options        IPFIREWALL_DEFAULT_TO_ACCEPT
options        DUMMYNET
options        HZ=1000
```

And ran it using these lines:

```
mkdir -p /root/kernels
touch /root/kernels/NEWKERN
cd /usr/src/sys/amd64/conf
ln -s /root/kernels/NEWKERN
cd /usr/src/
make buildkernel KERNCONF=NEWKERN && make installkernel KERNCONF=NEWKERN
```

But I get these errors and it stops:

```
/usr/src/sys/amd64/amd64/support.S:1112:2: error: instruction requires: AVX-512 ISA
 vmovdqa64 %zmm0, %gs:0x3c0
 ^
/usr/src/sys/amd64/amd64/support.S:1113:2: error: instruction requires: AVX-512 ISA
 vpxor %zmm0, %zmm0, %zmm0
 ^
/usr/src/sys/amd64/amd64/support.S:1116:2: error: instruction requires: AVX-512 DQ ISA
 vorpd (%rdx), %zmm0, %zmm0
 ^
/usr/src/sys/amd64/amd64/support.S:1117:2: error: instruction requires: AVX-512 DQ ISA
 vorpd (%rdx), %zmm0, %zmm0
 ^
/usr/src/sys/amd64/amd64/support.S:1129:2: error: instruction requires: AVX-512 ISA
 vmovdqa64 %gs:0x3c0, %zmm0
```

My server has Xeon E5620 and judging by this link below it lacks AVX:


			Intel Xeon E5620 vs E5-2620
		


Can anyone tell me what I can do to recompile kernel successfully to handle multiple FIBs? 

Thanks!
Darko


----------



## SirDice (May 22, 2019)

What's in /etc/make.conf and/or /etc/src.conf (if they exists)?


----------



## teekwan (May 23, 2019)

Hi SirDice,

First I had none of those two conf files.
Then I was googling around and tried creating /etc/make.conf from /usr/src/share/examples/etc/make.conf
All lines were commented by default, I've only set CPUTYPE?=nocona and then changed it to CPUTYPE?=k8 - everytime it fails the same way.
I haven't been fiddling with /etc/src.conf yet

I've been grepping for these instructions in all files below /usr/src/sys/amd64/ and they appear only in /usr/src/sys/amd64/amd64/support.S
Can I somehow omit this file from recompiling?


----------



## Crivens (May 23, 2019)

You should leave that file (/etc/make.conf) alone unless you do know *extremely* well what you are doing there. If it fails, that is a sign you did something wrong there. Leave that file alone if you can't have it failing. Even if it builds, that is not a guarantee that it runs.

Anyway, just look at the top output how much system load there is, and think about that you may shave 1% or so from the time in kernel, which is itself maybe 5% of the system load. Compare that to the risk you are taking.


----------



## teekwan (May 23, 2019)

Hi Crivens!

Well, I'm not trying to shave system load here, that's not my reason for kernel recompiling at all! 
If you have a look in my kernel config from the first post you might have seen this line:
_options      ROUTETABLES=5_

I've been searching all around for a way to introduce multiple routing tables to FreeBSD and seems kernel recompiling with this option included is the only way.
I've recompiled FreeBSD 11.2 without any problems before but it was another newer machine which had AVX instruction set in its Xeon E5 CPU.

Can I maybe recompile only networking portion of kernel?
I guess multiple FIBs are there only (once again - excuse my ignorance)

Thanks!


----------



## SirDice (May 23, 2019)

Yeah, as far as I know that `ROUTETABLES` option can only be set statically during the build. 

As Crivens already mentioned remove that /etc/make.conf, you don't need it. It's common for new users to put all sorts of compiler "optimizations" in it and then wonder why it doesn't work. That was the main reason why I asked about that file. It can really screw up things in all sorts of weird and wonderful ways. 

Where did the source come from? If the source is wrong that could explain it. If the source is correct there are a few things you can try.

`make clean` # Start with a clean slate. Sometimes half built stuff can get in the way. Make sure you start "fresh". 
`make kernel-toolchain` # This builds all the tools needed to build a kernel. Do this before `make buildkernel`.


----------



## teekwan (May 23, 2019)

I guess you expected something like that, but it really isn't the case here. I don't really care for optimizing kernel (yet at least) but I really do need multiple FIBs.
I obtained source like this:

```
pkg install subversion
rehash
svn co https://svn0.eu.FreeBSD.org/base/stable/11 /usr/src
```

This is a freshly installed 11.2 so when I ventured into kernel rebuilding there was absolutely nothing that could be a leftover of sorts.
If you gurus have any idea how to circumvent/exclude that _system.S_ file from being recompiled, I'm all ears (or eyes in this case  )


----------



## SirDice (May 23, 2019)

That's not the correct source, the source you fetched is for 11-STABLE. For 11.2-RELEASE you need to checkout /base/releng/11.2.

You don't need to install devel/subversion, you can use svnlite(1). It doesn't hurt though and both can be used.


----------



## teekwan (May 23, 2019)

Thanks guys, _svn switch https://svn0.eu.FreeBSD.org/base/releng/11.2 _did the trick!
After I've changed source to 11.2-RELEASE and it recompiled without any issues at all!


----------

