How to install virtualbox on a computer with a linux-mainline kernel

Follow this procedure and you will be fine:

  • yay linux-mainline to build the newest kernel from kernel.org (see article) – install also the linux-mainline-headers!
  • sudo pacman -S virtualbox
  • sudo pacman -S virtualbox-host-dkms
  • update-grub
  • reboot