Xen: Our hypervisor now runs on Raspberry Pi 4 – but Pi's quirks made life tricky

In porting the Xen hypervisor to Raspberry Pi 4 for IoT and industrial projects, developers met unexpected problems.

Lockdown surge for Raspberry Pi sales

Buyers of the 64-bit Raspberry Pi 4 now have a new software toy to play with, thanks to the Xen Project porting its hypervisor to the popular single-board computer. 

As The Register reports, the idea to port Xen to Raspberry Pi 4 won the support of George Dunlap, chairman of the Xen Project's Advisory Board, who discovered that 40% of the roughly 600,000 Raspberry Pi devices sold each month since March are to businesses working on IoT projects and industrial applications. 

The technical hurdles crossed to bring Xen to Raspberry Pi 4 are detailed in a blogpost on The Linux Foundation Projects' website by Stefano Stabellini, tech lead of US semiconductor outfit Xilinx and creator of Xen on Arm, and Roman Shaposhnik, creator of the Edge Virtualization Engine, or Project EVE. 

SEE: Research: Why Industrial IoT deployments are on the rise (TechRepublic Premium)

Addressing quirks of the Raspberry Pi 4 has required the creation of several Xen patches and even patches coming in the soon-to-be-released Linux kernel version 5.9. 

The most significant of these issues is that the Raspberry Pi 4, rather uniquely, has different physical addresses from DMA addresses, which required an address translation solution.  

DMA addresses are used to program devices and could be different from physical addresses but aren't different on most 64-bit Arm, Arm and x86 devices. That caused a problem for the Xen subsystem in Linux.  

"In practice, none of the x86, Arm, and Arm64 platforms where Xen could run had DMA addresses different from physical addresses. The Xen subsystem in Linux is exploiting the DMA/physical address duality for its own address translations. It uses it to convert physical addresses, as seen by the guest, to physical addresses, as seen by Xen," the pair of software engineers explain. 

"To our surprise and astonishment, the Raspberry Pi 4 was the very first platform to have physical addresses different from DMA addresses, causing the Xen subsystem in Linux to break. It wasn't easy to narrow down the issue. Once we understood the problem, a dozen patches later, we had full support for handling DMA/physical address conversions in Linux."

The Linux patches are in master and will be available in Linux 5.9, the pair write.

"With the Xen and Linux patches applied, Xen and Dom0 work flawlessly. Once Linux 5.9 is out, we will have Xen working on RPi4 out of the box."

The other oddity they discovered was that the Raspberry Pi 4 only allows for memory allocations below 1GB.

"This lower-than-1GB limitation is uncommon, but now that it is fixed, it is just going to work," the pair write. A patch that fixes it is now present in Xen 4.14.

SEE: Programming languages: Developers reveal what they love and loathe, and what pays best

The pair have prepared a tutorial explaining how to set up and configure a TFTP server to get Xen up and running. Users also need to download the appropriate UBoot binary for RPi4. Links to the tutorial are contained within the blogpost linked to above. 

For developers interested in building rugged computers or devices used in the field, the pair also recommend using the Project EVE operating system, which supports running edge containers on computers and devices deployed in the field, such as IoT gateways, industrial PCs, or general-purpose ruggedized computers. 

More on Raspberry Pi and single-board computers

  • Raspberry Pi: Banana Pi maker touts this new rival board with Amlogic chip and 4GB RAM  
  • Raspberry Pi 4 faces $59 Rock Pi 4C challenger with dual display output  
  • Raspberry Pi: Now computer-vision apps get boost with Khronos OpenVX API  
  • New Raspberry Pi OS update: First 8GB Pi 4, now you get these latest features  
  • New Raspberry Pi 4: 8GB RAM model out now for $75 – plus you get a new 64-bit OS  
  • New Raspberry Pi 4 update beta lets you boot from a USB mass storage device  
  • Raspberry Pi reveals this new $50 high-quality Pi camera with interchangeable lenses  
  • Raspberry Pi alternative: New Odroid-C4 undercuts 4GB Raspberry Pi 4 by $5  
  • Raspberry Pi sales jump: Here's why the tiny computer's in demand in coronavirus crisis  
  • Raspberry Pi 4's big price cut: 2GB model gets massive birthday reduction  
  • Raspberry Pi's Raspbian gets new features: File manager, Thonny Python IDE updates  
  • Raspberry Pi 4 graphics win: Open-source Vulkan driver support is coming  
  • Raspberry Pi gets MIT's Scratch 3 programming language for Raspbian  
  • Raspberry Pi 4 and Raspbian Buster: Hands-On   
  • Raspberry Pi 4 won't work with some power cables due to its USB-C design flaw
  • Raspberry Pi 4 Model B is out: Faster CPU, GPU, dual-screen 4K, up to 4GB for $55
  • Raspberry Pi users: You got Pi 4, now new Raspbian takes Windows 10, iOS design cues
  • What are the best Raspberry Pi alternatives? Everything you need to know about Pi rivals
  • What is the Raspberry Pi 4 Model B? A closer look at the new board and what it can do TechRepublic
  • Raspberry Pi 4 Model B review: This board really can replace your PC TechRepublic
  • Raspberry Pi 4 : This thing is a PC, says board's creator Eben Upton TechRepublic
  • New Raspberry Pi add-on: Now you can monitor air pollution indoors and out
  • Raspberry Pi: A cheat sheet TechRepublic  
  • Google includes a Raspberry Pi in a DIY smart speaker kit CNET