Enable padlock and viadrm on NetBSD

In case you have a board with VIA CPU supporting padlock security engine and VIA (Chrome) integrated graphics,  NetBSD generic kernel doesn’t support them by default. Because of this, I was building the custom NetBSD kernel manually for many years by uncommenting one of these lines in GENERIC configuration:

#padlock0 at cpu0 # VIA PadLock

# DRMUMS drivers
#viadrmums* at drm?
or
#viadrm* at drm? # VIA DRM driver

* viadrmums driver is preferred over viadrm one, because it is newer and more stable  compared to viadrm.  Actually viadrm is already removed from the current branch, however it still available in NetBSD 8 release, thus may still confuse unaware users…

There is an easier option to load them though. Starting NetBSD 6 dynamic kernel modules were introduced in the system. This presentation has a nice introduction on how to use and develop them. Both padlock and viadrmums modules are already provided by the NetBSD. In order to load them these lines need to be added to /boot.cfg file:

# load padlock module
load=padlock
# load VIA DRM UMS driver and required dependencies
load=drmkms_linux
load=drmkms
load=drmkms_pci
load=viadrmums

If everything went OK, these (or similar) lines should be present  in system’s dmesg after reboot:

padlock0 at cpu0: VIA PadLock
padlock0: RNG ACE

viadrmums0 at vga0drm: Supports vblank timestamp caching Rev 2 (21.10.2013).

There is one small caveat though, prior NetBSD 8 release above configuration would still likely end up with “bootinfo too big” error during the boot process (if all mentioned modules are enabled at the same time and rndseed /var/db/entropy-file is used, which is default behavior). This was solved with the following commit (bootloader needs to be updated),  NetBSD 8 successfully loads all modules and boot process doesn’t fail. Custom kernel is not required anymore, it just takes few additional lines in the boot configuration file.