Skip to content

arm64: Enable virtio-net and add network scripts #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

otischung
Copy link

@otischung otischung commented Jun 30, 2025

Enable POSIX timers to support ping’s POSIX timer syscalls:

  • CONFIG_POSIX_TIMERS=y in configs/linux-arm64.config

Enable network stack and virtio-net in kernel config:

  • CONFIG_NET, CONFIG_INET, CONFIG_IP_MULTICAST, CONFIG_IP_PNP
  • CONFIG_IP_PNP_DHCP, CONFIG_NETDEVICES, CONFIG_VIRTIO
  • CONFIG_VIRTIO_NET, CONFIG_VIRTIO_RING

Add virtio_net_dev to FDT generation:

  • src/arch/arm64/vm.c: include virtio_net_dev in interrupt-map

Define VIRTIO_NET_IRQ=2 (SPI 34) in src/arch/arm64/desc.h

Add scripts for host and guest network setup:

  • scripts/set-host-bridge.sh to configure TAP bridge and default route
  • scripts/set-guest-route.sh to configure guest static IP and route

Update README.md with new scripts and build instructions

These changes have been validated on both a Raspberry Pi 5 Model B
(Revision 1.0) running Ubuntu 25.10 with Linux kernel 6.14.0 and an
NVIDIA Jetson Orin Nano Developer Kit running JetPack 6.2.1
(L4T 36.4.4) with Linux kernel 5.15.148-tegra.

Copy link

@visitorckw visitorckw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since patch 3 fixes a typo introduced in patch 1 of this PR, please squash patch 3 into patch 1 using git rebase -i to keep the history clean.

otischung added 2 commits July 1, 2025 21:06
Enable POSIX timers to support ping’s POSIX timer syscalls:
- CONFIG_POSIX_TIMERS=y in configs/linux-arm64.config

Enable network stack and virtio-net in kernel config:
- CONFIG_NET, CONFIG_INET, CONFIG_IP_MULTICAST, CONFIG_IP_PNP
- CONFIG_IP_PNP_DHCP, CONFIG_NETDEVICES, CONFIG_VIRTIO
- CONFIG_VIRTIO_NET, CONFIG_VIRTIO_RING, CONFIG_UNIX
- CONFIG_UNIX_SCM, CONFIG_AF_UNIX_OOB

Add virtio_net_dev to FDT generation:
- src/arch/arm64/vm.c: include virtio_net_dev in interrupt-map

Define VIRTIO_NET_IRQ=2 (SPI 34) in src/arch/arm64/desc.h

Add scripts for host and guest network setup:
- scripts/set-host-bridge.sh to configure TAP bridge and default route
- scripts/set-guest-route.sh to configure guest static IP and route

Update README.md with new scripts and build instructions

These changes have been validated on a Raspberry Pi 5 Model B
(Revision 1.0) running Ubuntu 25.10 with Linux kernel version 6.14.0.
The previous URL of The Linux/x86 Boot Protocol returned a 404 error
due to an incorrect origin.
Updated the link to point to the correct resource.

References:
- The Linux/x86 Boot Protocol:
  https://www.kernel.org/doc/html/latest/arch/x86/boot.html
@otischung otischung force-pushed the feat/arm64-support branch from b8bb89c to 60835d6 Compare July 1, 2025 13:14
@otischung
Copy link
Author

Many thanks to @visitorckw.

I rebased the branch, interchanged patches 2 and 3, flagged patch 2 for squashing, and force-pushed the result. Please examine the changes at your convenience.

README.md Outdated
@@ -42,8 +44,63 @@ containing concatenated `bootsect.o + setup.o + misc.o + piggy.o`. `initrd` is t
initial RAM disk image, which is an optional argument.
`disk-image` is the path to disk image which can be mounted as a block device via virtio. For the reference Linux guest, ext4 filesystem is used for disk image.

### Stop Emulator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant to "stop" the emulation. Instead, the operation is dedicated to "exit" from the execution loop.

Comment on lines 78 to 80
CONFIG_UNIX=y
CONFIG_UNIX_SCM=y
CONFIG_AF_UNIX_OOB=y
Copy link
Contributor

@jserv jserv Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm if they are needed or not.

This commit removes the following kernel configuration options in the
ARM64 image:
- CONFIG_UNIX
- CONFIG_UNIX_SCM
- CONFIG_AF_UNIX_OOB

The updated ARM64 kernel image was tested on a Raspberry Pi 5 Model B
(Revision 1.0) running Ubuntu 25.10 with Linux kernel version 6.14.0.
The term “Exit” more accurately reflects that this key sequence
terminates the emulator’s execution loop rather than simply pausing
or stopping it.
@otischung
Copy link
Author

I’ve removed the unneeded ARM64 kernel configs (CONFIG_UNIX, CONFIG_UNIX_SCM, CONFIG_AF_UNIX_OOB) and renamed “Stop Emulator” to “Exit Emulator” in the README to better reflect its behavior. Please take a look and let me know if everything looks good for merge!

@otischung
Copy link
Author

Update

The changes were validated on the NVIDIA Jetson Orin Nano Developer Kit running JetPack 6.2.1 (L4T 36.4.4) with Linux kernel version 5.15.148-tegra. Network functionality within the guest operating system was confirmed to operate correctly.

README.md Outdated
1. Start the kvm-host emulator. Once initialized, the TUN/TAP interface (for example, `tap0`) is visible in the output of `ip a`. The following is sample output from the host:

```shell
❯ ip a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use $ for the command line prompt.

README.md Outdated
2. Execute the shell script `./scripts/set-host-bridge.sh`, which configures a bridge by assigning the default route to 10.0.0.1, integrating the TUN/TAP interface into the bridge, and activating the network interfaces. The following is sample output of `ip a` from the host:

```shell
❯ ip a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Use $.

@jserv jserv changed the title arm64: enable virtio-net and add network scripts arm64: Enable virtio-net and add network scripts Jul 29, 2025
@otischung otischung requested a review from visitorckw July 29, 2025 11:06
Replaced the ❯ prompt symbol with the conventional $ prompt in the
README’s example output for `ip a`, improving consistency and
readability.
@otischung
Copy link
Author

Update

I’ve updated the README example to use the standard $ prompt instead of for the ip a command.

Also, just a heads-up, the change requested by @visitorckw is no longer applicable, as the commit they referenced was removed by a force‑push.

Many thanks to @visitorckw.

I rebased the branch, interchanged patches 2 and 3, flagged patch 2 for squashing, and force-pushed the result. Please examine the changes at your convenience.

Let me know if you’d like any further tweaks. Thanks.

@otischung otischung requested a review from jserv July 30, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants