Lua Scripting Support Being Added To NetBSD Kernel

Written by Michael Larabel in BSD on 14 February 2013 at 09:24 AM EST. 19 Comments
BSD
Support for the Lua scripting language is being added to the NetBSD kernel so that it's possible to interact with the BSD kernel's various subsystems using this popular scripting language. With a Lua interpreter being added to the kernel, it's even possible to extend the kernel's subsystems in this scripting language.

Support for NetBSD kernel scripting using Lua has been an ongoing project that dates back to 2010 with the "Lunatik" project originating from that year's Google Summer of Code. The original work involved porting a Lua scripting language interpreter into the NetBSD kernel, a kernel programming interface that supports extending kernel subsystems in Lua, and a interface exposed to user-space for loading Lua scripts inside the kernel. This will certainly spark mixed views on a scripting language for the kernel, aside from security concerns.

From the 2010 work there's a few more details within the SourceForge Luakern project, but is since outdated. Earlier this month at FOSDEM 2013, Marc Balmer talked about Lua for the NetBSD kernel.

The "Lua in the kernel" project fell into an unmaintained state in 2012, but is being revived and will actually be merged. For those not familiar with the Lua programming language, it's a scripting language that's extensible, written in ISO C, and has a fairly straightforward C API. Lua has found itself widely adopted from being used within the VLC Media Player to video games as the scripting language to the Apache HTTP server. Now support is heading into the NetBSD kernel for Lua.

Marc Balmer is a long-time *BSD developer and is the founder of the Swiss-based Micro Systems. His slides about his FOSDEM 2013 presentation of Lua going into the kernel can now be found on FOSDEM.org while embedded below are some of the most interesting points.

Among the expressed ideas for users with Lua in the NetBSD kernel is that "modifying software written in C is hard for users", with this scripting language there's the power for users to better modify and extend their systems, and users can explore the system in an easy way.

For developers, Lua allows for rapid application development approach to driver and kernel developer, modifying the system behavior in real-time, and configuration of kernel sub-systems through the scripts.

Rather than Lua, other language possibilities were Python and Java. Python is not difficult to integrate with C but has problems with being a huge library, memory consumption, and difficult object mapping. Java is easy to write but also poses problems with object mapping and memory might be an issue, but it's worked out before for driver development.

The 2010 GSoC project proved that the Lua virtual machine can run in the NetBSD kernel and the necessary infrastructure was added to the kernel. Support for Lua in the NetBSD kernel is soon to be merged to NetBSD "-current" and it should be part of NetBSD 7. Within the NetBSD user-land has already been Lua scripting support.

When running Lua code in the kernel it ends up being all in one address space and is accessible to all the same memory, but there are locking issues.

A look at how Lua integrates into the NetBSD kernel.

Fortunately, some security features for Lua code in the NetBSD kernel are being worked through.

It will be interesting to see if Lua scripting in the NetBSD kernel ends up being used much or if it is a feature just used as a toy and research. The release of NetBSD 7.0 is likely still more than one year away, but we'll keep monitoring the space of Lua scripting in the NetBSD kernel.

Read more of the Phoronix FOSDEM 2013 coverage.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week