Kernel 4.16-rc1 Breaks latest drivers - 'Unknown symbol swiotlb_map_sg_attrs'

With Kernel 4.16-rc1, the latest NVIDIA drivers - 384.111 and 390.25 - both compile OK, but then fail to load/run:

modprobe: ERROR: could not insert ‘nvidia’: Unknown symbol in module, or unknown parameter (see dmesg)

dmesg:
[ 2142.352238] nvidia: Unknown symbol swiotlb_map_sg_attrs (err 0)

This symbol is no longer exported, since 4.16-rc1… (and thanks to Michal Kubeček for pointing out the relevant commit…)

[PATCH 11/22] swiotlb: remove various exports

Robert Gadsdon
rglinuxtech.com

I’d like to confirm this exists on my system as well, very problematic since a competitor’s CPU product I’m using is only stable with this kernel, and at the same time I have an nvidia GPU I wish to use in said system.

https://github.com/torvalds/linux/blob/e64b9562ba281dc1dc613408707375cb9c5660e5/lib/swiotlb.c#L969

https://github.com/torvalds/linux/commit/4bd89ed39b2ab8dc4ac4b6c59b07d420b0213bec

Nobody is using this symbol apparently.

EDIT: Reported to the kernel team 198997 – Nvidia driver broken

The missing exports are not the only problem.
I have build a kernel 4.16-rc4 with reverted commit, but nvidia doesn’t work at all.
There will be a kernel oops and not starting X.

towo:Defiant> journalctl -b -1 | grep nvid
Mär 05 19:00:10 Defiant kernel: nvidia: loading out-of-tree module taints kernel.
Mär 05 19:00:10 Defiant kernel: nvidia: module license 'NVIDIA' taints kernel.
Mär 05 19:00:11 Defiant kernel: caller _nv001170rm+0xe3/0x1d0 [nvidia] mapping multiple BARs
Mär 05 19:00:11 Defiant kernel: caller _nv029921rm+0x57/0x90 [nvidia] mapping multiple BARs
Mär 05 19:00:12 Defiant kernel: usercopy: Kernel memory exposure attempt detected from SLUB object 'nvidia_stack_cache' (offset 11440, size 3)!
Mär 05 19:00:12 Defiant kernel: Modules linked in: fuse vmw_vsock_vmci_transport vsock vmw_vmci snd_hda_codec_hdmi iTCO_wdt iTCO_vendor_support mxm_wmi intel_rapl x86_pkg_temp_thermal snd_hda_codec_realtek intel_powerclamp snd_hda_codec_generic crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc joydev input_leds evdev xpad snd_hda_intel aesni_intel aes_x86_64 eeprom snd_hda_codec crypto_simd glue_helper cryptd snd_hda_core snd_hwdep snd_pcm snd_timer snd sg mei_wdt soundcore shpchp lpc_ich video button wmi nvidia_drm(PO) drm nvidia_modeset(PO) nvidia(PO) ipmi_devintf ipmi_msghandler kyber_iosched kvm_intel kvm irqbypass coretemp parport_pc ppdev lp parport ip_tables x_tables ipv6 crc_ccitt autofs4 ext4 crc16 mbcache jbd2 fscrypto hid_logitech_hidpp hid_logitech_dj hid_generic usbhid sr_mod cdrom sd_mod crc32c_intel
Mär 05 19:00:12 Defiant kernel:  os_memcpy_to_user+0x1c/0x40 [nvidia]
Mär 05 19:00:12 Defiant kernel:  _nv009373rm+0xbf/0xe0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv028042rm+0x79/0x90 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv028042rm+0x55/0x90 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv013687rm+0xee/0x100 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv015333rm+0x154/0x270 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv008306rm+0x134/0x1a0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv008285rm+0x29c/0x2b0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv001073rm+0xe/0x20 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv007315rm+0xd8/0x100 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv001172rm+0x627/0x830 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? rm_ioctl+0x73/0x100 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? nvidia_ioctl+0x4f0/0x6f0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? nvidia_frontend_unlocked_ioctl+0x39/0x40 [nvidia]
Mär 05 19:00:12 Defiant kernel: Modules linked in: fuse vmw_vsock_vmci_transport vsock vmw_vmci snd_hda_codec_hdmi iTCO_wdt iTCO_vendor_support mxm_wmi intel_rapl x86_pkg_temp_thermal snd_hda_codec_realtek intel_powerclamp snd_hda_codec_generic crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc joydev input_leds evdev xpad snd_hda_intel aesni_intel aes_x86_64 eeprom snd_hda_codec crypto_simd glue_helper cryptd snd_hda_core snd_hwdep snd_pcm snd_timer snd sg mei_wdt soundcore shpchp lpc_ich video button wmi nvidia_drm(PO) drm nvidia_modeset(PO) nvidia(PO) ipmi_devintf ipmi_msghandler kyber_iosched kvm_intel kvm irqbypass coretemp parport_pc ppdev lp parport ip_tables x_tables ipv6 crc_ccitt autofs4 ext4 crc16 mbcache jbd2 fscrypto hid_logitech_hidpp hid_logitech_dj hid_generic usbhid sr_mod cdrom sd_mod crc32c_intel
Mär 05 19:00:12 Defiant kernel: RIP: 0010:_nv007213rm+0x25/0x90 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv025869rm+0x13/0x50 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? _nv035572rm+0x144/0x1e0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? rm_free_unused_clients+0x4f/0xe0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? os_pci_read_dword+0xd/0x20 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? nv_check_pci_config_space+0x258/0x2e0 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? nvidia_close+0xb5/0x350 [nvidia]
Mär 05 19:00:12 Defiant kernel:  ? nvidia_frontend_close+0x25/0x40 [nvidia]
Mär 05 19:00:12 Defiant kernel: RIP: _nv007213rm+0x25/0x90 [nvidia] RSP: ffffc9000262fd30
Mär 05 19:00:12 Defiant kernel: Modules linked in: fuse vmw_vsock_vmci_transport vsock vmw_vmci snd_hda_codec_hdmi iTCO_wdt iTCO_vendor_support mxm_wmi intel_rapl x86_pkg_temp_thermal snd_hda_codec_realtek intel_powerclamp snd_hda_codec_generic crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc joydev input_leds evdev xpad snd_hda_intel aesni_intel aes_x86_64 eeprom snd_hda_codec crypto_simd glue_helper cryptd snd_hda_core snd_hwdep snd_pcm snd_timer snd sg mei_wdt soundcore shpchp lpc_ich video button wmi nvidia_drm(PO) drm nvidia_modeset(PO) nvidia(PO) ipmi_devintf ipmi_msghandler kyber_iosched kvm_intel kvm irqbypass coretemp parport_pc ppdev lp parport ip_tables x_tables ipv6 crc_ccitt autofs4 ext4 crc16 mbcache jbd2 fscrypto hid_logitech_hidpp hid_logitech_dj hid_generic usbhid sr_mod cdrom sd_mod crc32c_intel

So there are more problems in 4.16 than the missing symbols.

Thanks towo. Reposted your logs on the kernel bug report. 198997 – Nvidia driver broken

The kernel team have marked the bug priority one.

This patch does work for me (x64 only, no spectre/meltdown mitigation enabled):
The driver uses this one symbol just to detect wheter swiotlb is really in use,
you can just ignore the whole path and just return that swiotlb isn’t used.

--- a/kernel/common/inc/nv-linux.h~     2018-01-25 06:09:41.000000000 +0100
+++ b/kernel/common/inc/nv-linux.h      2018-03-05 13:58:17.746725638 +0100
@@ -1209,6 +1209,7 @@ static inline NvU32 nv_alloc_init_flags(
 static inline NvBool nv_dma_maps_swiotlb(struct pci_dev *dev)
 {
     NvBool swiotlb_in_use = NV_FALSE;
+#if 0
 #if defined(CONFIG_SWIOTLB)
   #if defined(NV_DMA_OPS_PRESENT) || defined(NV_GET_DMA_OPS_PRESENT)
     /*
@@ -1251,7 +1252,7 @@ static inline NvBool nv_dma_maps_swiotlb
     swiotlb_in_use = (swiotlb == 1);
   #endif
 #endif
-
+#endif
     return swiotlb_in_use;
 }

Now i have done another test, new kernel build with CONFIG_HARDENED_USERCOPY_FALLBACK=y and the reverted commit e64b9562ba281dc1dc613408707375cb9c5660e5, now X is starting and seems to work.
In log i get the following trace:

[Di Mär  6 16:38:14 2018] ------------[ cut here ]------------
[Di Mär  6 16:38:14 2018] Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'nvidia_stack_cache' (offset 11440, size 3)!
[Di Mär  6 16:38:14 2018] WARNING: CPU: 2 PID: 720 at /build/linux-siduction-4.16~rc4/mm/usercopy.c:81 usercopy_warn+0x79/0x90
[Di Mär  6 16:38:14 2018] Modules linked in: vmnet(O) fuse vmw_vsock_vmci_transport vsock vmw_vmci vmmon(O) snd_hda_codec_hdmi intel_rapl x86_pkg_temp_thermal intel_powerclamp iTCO_wdt iTCO_vendor_support crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc mxm_wmi evdev joydev xpad input_leds snd_hda_codec_realtek snd_hda_codec_generic aesni_intel aes_x86_64 eeprom crypto_simd glue_helper snd_hda_intel cryptd snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_timer sg snd soundcore shpchp lpc_ich mei_wdt wmi video button nvidia_drm(PO) drm nvidia_modeset(PO) nvidia(PO) ipmi_devintf ipmi_msghandler kyber_iosched kvm_intel kvm irqbypass coretemp parport_pc ppdev lp parport ip_tables x_tables ipv6 crc_ccitt autofs4 ext4 crc16 mbcache jbd2 fscrypto hid_logitech_hidpp hid_logitech_dj hid_generic usbhid sr_mod sd_mod
[Di Mär  6 16:38:14 2018]  cdrom ahci libahci libata crc32c_intel xhci_pci ehci_pci r8169 i2c_i801 scsi_mod i2c_core mii ehci_hcd xhci_hcd fan thermal rtc_cmos
[Di Mär  6 16:38:14 2018] CPU: 2 PID: 720 Comm: Xorg Tainted: P           O     4.16.0-rc4-siduction-amd64 #1 siduction 4.16~rc4-1~exp5
[Di Mär  6 16:38:14 2018] Hardware name: MSI MS-7850/H87-G41 PC Mate(MS-7850), BIOS V3.9 07/17/2014
[Di Mär  6 16:38:14 2018] RIP: 0010:usercopy_warn+0x79/0x90
[Di Mär  6 16:38:14 2018] RSP: 0018:ffffc9000266bb78 EFLAGS: 00010296
[Di Mär  6 16:38:14 2018] RAX: 0000000000000088 RBX: ffff880406dfdcb0 RCX: 0000000000000001
[Di Mär  6 16:38:14 2018] RDX: 0000000080000001 RSI: ffffffff81dfb4b5 RDI: 00000000ffffffff
[Di Mär  6 16:38:14 2018] RBP: 0000000000000003 R08: 0000000000000098 R09: 000000000000033c
[Di Mär  6 16:38:14 2018] R10: ffffffff81e309b0 R11: 0000000000000001 R12: 0000000000000001
[Di Mär  6 16:38:14 2018] R13: ffff880406dfdcb3 R14: 0000000000000000 R15: ffff880406dfdcf8
[Di Mär  6 16:38:14 2018] FS:  00007f59f524e580(0000) GS:ffff88041dd00000(0000) knlGS:0000000000000000
[Di Mär  6 16:38:14 2018] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[Di Mär  6 16:38:14 2018] CR2: 00007f59ed3ac270 CR3: 0000000409136003 CR4: 00000000001606e0
[Di Mär  6 16:38:14 2018] Call Trace:
[Di Mär  6 16:38:14 2018]  __check_object_size+0x125/0x1a0
[Di Mär  6 16:38:14 2018]  os_memcpy_to_user+0x1c/0x40 [nvidia]
[Di Mär  6 16:38:14 2018]  _nv009373rm+0xbf/0xe0 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv028042rm+0x79/0x90 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv028042rm+0x55/0x90 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv013687rm+0xee/0x100 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv015333rm+0x154/0x270 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv008306rm+0x134/0x1a0 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv008285rm+0x29c/0x2b0 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv001073rm+0xe/0x20 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv007315rm+0xd8/0x100 [nvidia]
[Di Mär  6 16:38:14 2018]  ? _nv001172rm+0x627/0x830 [nvidia]
[Di Mär  6 16:38:14 2018]  ? rm_ioctl+0x73/0x100 [nvidia]
[Di Mär  6 16:38:14 2018]  ? nvidia_ioctl+0x4f0/0x6f0 [nvidia]
[Di Mär  6 16:38:14 2018]  ? nvidia_frontend_unlocked_ioctl+0x39/0x40 [nvidia]
[Di Mär  6 16:38:14 2018]  ? do_vfs_ioctl+0x8b/0x5f0
[Di Mär  6 16:38:14 2018]  ? __fput+0x12c/0x1e0
[Di Mär  6 16:38:14 2018]  ? preempt_count_add+0x63/0x90
[Di Mär  6 16:38:14 2018]  ? SyS_ioctl+0x6f/0x80
[Di Mär  6 16:38:14 2018]  ? do_syscall_64+0x69/0x120
[Di Mär  6 16:38:14 2018]  ? entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[Di Mär  6 16:38:14 2018] Code: 48 c7 c0 47 af e0 81 48 0f 44 c2 41 50 51 41 51 48 89 f9 49 89 f1 4d 89 d8 4c 89 d2 48 89 c6 48 c7 c7 90 af e0 81 e8 47 cb e7 ff <0f> 0b 48 83 c4 18 c3 48 c7 c6 b5 b4 df 81 49 89 f1 49 89 f3 eb 
[Di Mär  6 16:38:14 2018] ---[ end trace 88bfa81a4c6f4118 ]---

@mlau, Many thanks for the patch!

For 384.111 I had to increment the line number references by 100 to make it work, (so ‘…-1209,6 +1209,7…’ becomes ‘…-1309,6 +1309,7…’, etc.) but have tested this, and the NVIDIA driver compiles/loads OK, and runs OK, so far… (tested with Kernel 4.16-rc4, nopti, patched driver 384.111, on Fedora 27 with KDE/Plasma, and VMware 4.1.1)

Robert Gadsdon
rglinuxtech.com

so what could be a good fix for this and the 4.15.x kernel?
I ran across this

thanks
Matt

Finally linux kernel 4.16.0 has been released. So many distribution will release 4.16 kernel packages. Please hurry up!

Regards,

Hello,

I wanted to add here that I saw the same

Unknown symbol swiotlb_map_sg_attrs

issue from nvidia.ko(NVIDIA 390.42 GeForce GTX 860M driver) for the latest stable
4.16(https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.16.tar.xz). At first I thought, the

lib/swiotlb.c(which has swiotlb_map_sg_attrs() function)

was not built during the kernel build, so I explicitly cleaned and built

linux-4.16/lib/* directory(CONFIG_SWIOTLB enabled as well in kernel config)

and installed the kernel modules from therein onto the system

(/lib/modules/4.16.0/...)

.
Even then, nvidia.ko complained it couldn’t find swiotlb_map_sg_attrs(symbol). Then I
checked whether swiotlb_map_sg_attrs symbol was shown as defined(T) in any of the

linux-4.16/lib/*.ko(using nm tool)

None of them showed swiotlb_map_sg_attrs to be defined within them. So, that made me think
this swiotlb_map_sg_attrs symbol visibility might have changed in the latest 4.16 but it was
visible/exported in earlier kernels(4.15.15, 4.15.14, etc - for which I had no issues in
building, installing and using the same NVIDIA 390.42 GeForce GTX 860M driver). So, as
per one of the above comments, I disabled the logic which refers

swiotlb_map_sg_attrs in common/inc/nv-linux.h

and made the nv_dma_maps_swiotlb() to return NV_FALSE as swiotlb is not used anyway. Rebuilt

NVIDIA 390.42 GeForce GTX 860M driver

Installed, loaded the nvidia*.ko modules and that worked and is working without any issues
for the latest stable Linux kernel 4.16 for Ubuntu 17.10 x86_64.

Below are the specifics.

exp@exp:~$ 
exp@exp:~$ cat /proc/version 
Linux version 4.16.0 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #1 SMP Mon Apr 2 20:39:22 PDT 2018
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 17.10
Release:	17.10
Codename:	artful
exp@exp:~$ 
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ nvidia-smi
Tue Apr  3 00:01:15 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.42                 Driver Version: 390.42                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 860M    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   54C    P0    N/A /  N/A |    306MiB /  4046MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

exp@exp:~$ 
exp@exp:~$ 
exp@exp:~$ lsmod | grep nvidia
nvidia_uvm            815104  0 
nvidia_drm             24576  2 
nvidia_modeset       1105920  4 nvidia_drm
nvidia              14368768  230 nvidia_uvm,nvidia_modeset
ipmi_msghandler        61440  2 nvidia,ipmi_devintf
drm                   454656  6 nvidia_drm,i915,drm_kms_helper
exp@exp:~$ 
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ glxinfo | grep NVIDIA
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.5.0 NVIDIA 390.42
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 390.42
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 390.42
exp@exp:~$

exp@exp:~$ 
exp@exp:~$ sudo dmidecode -t system | grep "Manufacturer:\|Version:"
	Manufacturer: LENOVO
	Version: Lenovo Y50-70 Touch
exp@exp:~$

By the way, in the above whole experience, I am using

clang/LLVM as the compiler/toolchain to build NVIDIA 390.42 GeForce GTX 860M driver(latest as of now)

and also

Linux kernel 4.16(and the earlier kernels : 4.15.7 and above) is being built by me using clang/LLVM

.
For any one interested in this clang/LLVM related kernel/NVIDIA driver details, I have written a report here –

Success : Ubuntu 17.10 x86_64 on LLVM/clang-built kernel with Nvidia 390.25 driver : 
<a target='_blank' rel='noopener noreferrer' href='https://ubuntuforums.org/showthread.php?t=2386423'>https://ubuntuforums.org/showthread.php?t=2386423</a>

Cheers.

UPDATE : Above logic of disabling swiotlb specific code worked even with latest Nvidia v390.48 driver for Nvidia GeForce GTX 860M graphics card.

exp@exp:~$ 
exp@exp:~$ nvidia-smi 
Fri Apr  6 01:53:20 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48                 Driver Version: 390.48                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 860M    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   60C    P5    N/A /  N/A |    790MiB /  4046MiB |     17%      Default |
+-------------------------------+----------------------+----------------------+

exp@exp:~$ 
exp@exp:~$ ~/nvidia_driver_modules_version.sh 
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia.ko
version=390.48
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-drm.ko
version=390.48
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-uvm.ko
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-modeset.ko
version=390.48
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ ~/nvidia-driver-compiler.sh 
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.0/kernel/drivers/video/nvidia.ko
+++ grep 'clang version'
+++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia.ko
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.0/kernel/drivers/video/nvidia-drm.ko
+++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-drm.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.0/kernel/drivers/video/nvidia-modeset.ko
+++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-modeset.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.0/kernel/drivers/video/nvidia-uvm.ko
+++ strings -a /lib/modules/4.16.0/kernel/drivers/video/nvidia-uvm.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
exp@exp:~$

On Fedora 27, I compiled 4.16 with the default .config (copied from /boot/config-4.15.13-300.fc27.x86_64) modified so that no default drm except for xfree86 drm were included.

Then I got a kernel with System.map including swiotlb_map_sg_attrs,

$ grep swiotlb_map_sg_attrs /boot/System.map
ffffffff81458640 T swiotlb_map_sg_attrs
ffffffff815294c0 t xen_swiotlb_map_sg_attrs

but NVIDIA driver failed to compile. Why?

$ tail nvidia-installer.log
[  134.889586] /dev/vmnet: port on hub 8 successfully opened
[  135.288600] /dev/vmnet: open called by PID 8380 (vmnet-dhcpd)
[  135.288611] /dev/vmnet: port on hub 8 successfully opened
[  154.192379] VFIO - User Level meta-driver version: 0.3
[  154.319341] ipmi message handler version 39.2
[  154.331734] ipmi device interface
[  154.362253] nvidia: module license 'NVIDIA' taints kernel.
[  154.362256] Disabling lock debugging due to kernel taint
[  154.382780] nvidia: Unknown symbol swiotlb_map_sg_attrs (err 0)
ERROR: Installation has failed.  Please see the file '/var/log/nvidia-installer.log' for details.  You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

This breaks Ubuntu 16.04 (and I suppose all others too) when installing kernel 4.16.

gnome-session[7104]: gnome-session-binary[7104]: CRITICAL: We failed, but the fail whale is dead. Sorry....
lightdm[1279]: ** (lightdm:1279): CRITICAL **: session_get_login1_session_id: assertion 'session != NULL' failed
lightdm[1279]: update-alternatives: error: no alternatives for x86_64-linux-gnu_gfxcore_conf
kernel: [  264.813170] nvidia: Unknown symbol swiotlb_map_sg_attrs (err 0)

Driver Version: 390.30

The patch from mlau worked fine for me - Fedora 25 + kernel 4.16.0 rc7 fc28

[root@localhost ~]# uname -r
4.16.0-0.rc7.git0.1.fc28.x86_64
[root@localhost ~]# nvidia-smi
Fri Apr 6 10:49:41 2018
±----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48 Driver Version: 390.48 |

Same problem here on Gentoo, kernel 4.16.1, Nvidia driver 390.48

Gentoo, on 4.16.1 and drivers version 390.48. mlau’s patch (post #6) works for me.

opensuse tumbleweed recent update to 4.16 broke nvidia driver
please, fix it
mlau’s patch works, btw. thank you!

I have a similar problem on Slackware 14.2, kernel 4.16 (but also previous), driver 390.48 (but also previous).

The installation fails and the log is attached.

Any ideas?

Extracted from log file:

[  563.814283] nvidia: Unknown symbol pci_read_config_byte (err 0)
[  563.814284] nvidia: Unknown symbol acpi_evaluate_integer (err 0)
[  563.814284] nvidia: Unknown symbol strlen (err 0)
[  563.814284] nvidia: Unknown symbol iomem_resource (err 0)
[  563.814285] nvidia: Unknown symbol param_ops_int (err 0)
[  563.814285] nvidia: Unknown symbol vga_set_legacy_decoding (err 0)
[  563.814286] nvidia: Unknown symbol single_open (err 0)
[  563.814286] nvidia: Unknown symbol ioremap_wc (err 0)
[  563.814287] nvidia: Unknown symbol acpi_remove_notify_handler (err 0)
[  563.814287] nvidia: Unknown symbol vmalloc (err 0)
[  563.814288] nvidia: Unknown symbol pci_write_config_word (err 0)
[  563.814288] nvidia: Unknown symbol set_memory_array_uc (err 0)
[  563.814288] nvidia: Unknown symbol up_read (err 0)
[  563.814289] nvidia: Unknown symbol cdev_init (err 0)
[  563.814289] nvidia: Unknown symbol __kmalloc (err 0)
[  563.814290] nvidia: Unknown symbol pci_write_config_dword (err 0)
[  563.814290] nvidia: Unknown symbol kmalloc_caches (err 0)
[  563.814291] nvidia: Unknown symbol cdev_del (err 0)
[  563.814291] nvidia: Unknown symbol __request_region (err 0)
[  563.814292] nvidia: Unknown symbol kernel_write (err 0)
[  563.814292] nvidia: Unknown symbol kmem_cache_destroy (err 0)
[  563.814293] nvidia: Unknown symbol system_wq (err 0)
[  563.814293] nvidia: Unknown symbol acpi_bus_register_driver (err 0)
[  563.814293] nvidia: Unknown symbol __unregister_chrdev (err 0)
[  563.814294] nvidia: Unknown symbol jiffies_to_timespec64 (err 0)

nvidia-installer.log (79.8 KB)

Driver 396.18 works with kernel 4.16 ootb.

Where do I find it? The driver download page gives me the 390.48.