Skip to content

add Loongarch init support#627

Open
yzewei wants to merge 3 commits intocontainers:mainfrom
yzewei:loongarch-submit-clean
Open

add Loongarch init support#627
yzewei wants to merge 3 commits intocontainers:mainfrom
yzewei:loongarch-submit-clean

Conversation

@yzewei
Copy link
Copy Markdown
Contributor

@yzewei yzewei commented Apr 13, 2026

What was done

Completed a single-core (1 vCPU) guest VM for LoongArch64:

  1. Completed the basic integration path of LoongArch64 in arch/devices/vmm:
  • LoongArch startup/register initialization, FDT generation, MMIO/interrupt chip integration, memory layout and loading process adaptation.

  • Completed LoongArch branches for critical paths such as builder, vstate, and mmio, ensuring the VM can normally enter the guest and run test cases.

  1. Completed test and runtime chain adaptation:
  • Supported the LoongArch guest-agent running mode on the test side (including runtime dependency handling), and fixed console startup timing issues.

  • Improved relevant test cases under LoongArch.

Tests Passed

Integration Tests (LoongArch, Single Core)

  • configure-vm-1cpu-256MiB

  • configure-vm-1cpu-1GiB

  • vsock-guest-connect

  • tsi-tcp-guest-connect

  • tsi-tcp-guest-listen

  • multiport-console

Unit Tests

  • All unit tests in vmm passed.

Future Improvements

  • SMP (2+ vCPUs): Currently, due to the lack of an upstream version of the interrupt mechanism (IPI) on both the host KVM and guest kernels, startup with 2 vCPUs fails under SMP.

About LoongArch

The LoongArch architecture (LoongArch) is an Instruction Set Architecture (ISA) that has a RISC style.

Documentations:
ISA:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
ABI:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
More docs can be found at:
https://loongson.github.io/LoongArch-Documentation/README-EN.html

yzewei added 2 commits April 13, 2026 16:04
Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
@yzewei yzewei force-pushed the loongarch-submit-clean branch 2 times, most recently from 6cd360d to 03a3ade Compare April 13, 2026 08:24
@jakecorrenti
Copy link
Copy Markdown
Member

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the loongarch64 architecture, encompassing core architecture definitions, EFI system table setup, IOCSR emulation, and a specialized KVM interrupt chip. The implementation integrates LoongArch into the microVM builder and updates libkrun to manage architecture-specific kernel loading and vCPU constraints. Review feedback identifies a critical register mapping error regarding the Linux boot protocol, logic errors in IOCSR mailbox indexing, and the need to manually assert interrupts since irqfd is disabled for this architecture. Additionally, error handling improvements are suggested to replace unwrap() calls and provide more accurate error variants.

Comment thread src/arch/src/loongarch64/linux/regs.rs
Comment thread src/arch/src/loongarch64/linux/iocsr.rs Outdated
Comment thread src/devices/src/legacy/kvmloongarchirqchip.rs
Comment thread src/devices/src/legacy/kvmloongarchirqchip.rs Outdated
Comment thread src/arch/src/loongarch64/mod.rs Outdated
@yzewei yzewei force-pushed the loongarch-submit-clean branch 4 times, most recently from 2742f56 to 53d9e64 Compare April 14, 2026 07:50
@slp slp added the 1.x label Apr 14, 2026
Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
@yzewei yzewei force-pushed the loongarch-submit-clean branch from 53d9e64 to 8829567 Compare April 20, 2026 06:51
@jakecorrenti
Copy link
Copy Markdown
Member

jakecorrenti commented Apr 21, 2026

Hi @yzewei thank you very much for the contribution. I'm working through a thorough review at the moment, but I have a few questions:

  1. What's the best way for me to test this considering I don't have loongarch hardware?
  2. Are you willing to provide some sort of commitment to maintain this architecture? I would like to avoid adding a bunch of code to the repository for an architecture that I don't believe any of us have any knowledge/hardware for if we can't have someone address bugs/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants