Linux KVM/arm64 development list
 help / color / mirror / Atom feed
* [PATCH v3 0/8] arm64: Add Stage-2 MMU and Nested Guest Framework
@ 2026-10-01 15:16 Joey Gouly
  2026-10-01 15:16 ` [PATCH v3 1/8] lib/alloc_page: check for NULL ptr passed to free_pages() Joey Gouly
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Joey Gouly @ 2026-10-01 15:16 UTC (permalink / raw)
  To: kvmarm
  Cc: Jing Zhang, Marc Zyngier, Oliver Upton, Mark Brown, Wei-Lin Chang,
	andrew.jones, Joey Gouly

Hi all,

This is v3 of the guest framework for kvm-unit-tests/arm64, I have confirmation
from Jing that he was ok with me posting v3 on top of his v2 [1].

This series introduces lightweight infrastructure for managing arm64 stage-2
translation tables and running EL1 guests from EL2.

The stage-2 library provides page-table mapping, unmapping and context loading.
The initial implementation is deliberately limited to a 4K granule, 48-bit IPA
space and 8-bit VMIDs.

The series also includes a stage-2 demand-paging test which handles a guest
stage-2 fault by installing the missing mapping and resuming the guest.

The first 2 patches are just preparatory patches and could be merged
earlier.

Changes since v2:
- Fixed free_pages(NULL), ran into a hang and debugged it to this
- Validate the currently supported stage-2 configuration: 4K granules,
  48-bit IPAs and 8-bit VMIDs.
- Store the VTCR_EL2 and VTTBR_EL2 values in the stage-2 mmu.
- Replace s2mmu_enable()/s2mmu_disable() with s2mmu_load(); saving
  of the previous stage-2 context is now handled by the guest world switch.
- Make s2mmu_map() return errors, rather than printing.
- Fix the required barriers for stage-2 TLB invalidation.
- Split guest creation, so that the policy of mapping is in a separate
  identity helper.
- Remove the hardcoded UART mapping from guest creation. This can be added back
  ad-hoc for debugging.
- Move system register state into C, using assembly for GPRs and
  exception vectors.
- Fix the EL1 exception frame so that x29 and x30 are saved and restored
  correctly, make the frame 16-byte aligned, and use generated offsets instead
  of hard-coded values.
- Use the EL12 system-register aliases when accessing guest EL1 state from a
  VHE host.
- Fix the demand-paging test's IPA placement to avoid the identity-mapped guest
  code region and verify the expected data value explicitly.
- Added a new test to test the exception handling.
- Few other small fixes

See the full diff of v3 and v2 at:
  https://gitlab.arm.com/linux-arm/kvm-unit-tests-jg/-/compare/guest_framework_v2..guest_framework_v3

An LLM was used to review the code, and implement the host-state code
and the guest-test.c tests (both were also reviewed by me)

Thanks,
Joey

[1]: https://lore.kernel.org/kvmarm/20260413204630.1149038-1-jingzhangos@google.com/


Jing Zhang (6):
  lib: arm64: Generalize exception vector definitions for EL2 support
  lib: arm64: Add stage2 page table management library
  lib: arm64: Add foundational guest execution framework
  lib: arm64: Add support for guest exit exception handling
  lib: arm64: Add guest-internal exception handling
  arm64: Add Stage-2 MMU demand paging test

Joey Gouly (2):
  lib/alloc_page: check for NULL ptr passed to free_pages()
  arm64: Add basic guest execution tests

 arm/Makefile.arm64         |   5 +
 arm/debug.c                |   6 +-
 arm/gic.c                  |   2 +-
 arm/guest-test.c           | 157 ++++++++++++++
 arm/micro-bench.c          |   4 +-
 arm/mte.c                  |   6 +-
 arm/pl031.c                |   2 +-
 arm/pmu.c                  |   2 +-
 arm/psci.c                 |   2 +-
 arm/selftest.c             |   6 +-
 arm/stage2-mmu-test.c      | 113 +++++++++++
 arm/timer.c                |   6 +-
 lib/alloc_page.c           |   3 +-
 lib/arm64/asm-offsets.c    |  10 +
 lib/arm64/asm/esr.h        |   3 +
 lib/arm64/asm/guest.h      |  99 +++++++++
 lib/arm64/asm/processor.h  |  32 +--
 lib/arm64/asm/stage2_mmu.h |  76 +++++++
 lib/arm64/asm/sysreg.h     |  36 ++++
 lib/arm64/guest.c          | 264 ++++++++++++++++++++++++
 lib/arm64/guest_arch.S     | 223 ++++++++++++++++++++
 lib/arm64/processor.c      |   8 +-
 lib/arm64/stage2_mmu.c     | 406 +++++++++++++++++++++++++++++++++++++
 23 files changed, 1432 insertions(+), 39 deletions(-)
 create mode 100644 arm/guest-test.c
 create mode 100644 arm/stage2-mmu-test.c
 create mode 100644 lib/arm64/asm/guest.h
 create mode 100644 lib/arm64/asm/stage2_mmu.h
 create mode 100644 lib/arm64/guest.c
 create mode 100644 lib/arm64/guest_arch.S
 create mode 100644 lib/arm64/stage2_mmu.c

-- 
2.43.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-10-01 15:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01 15:16 [PATCH v3 0/8] arm64: Add Stage-2 MMU and Nested Guest Framework Joey Gouly
2026-10-01 15:16 ` [PATCH v3 1/8] lib/alloc_page: check for NULL ptr passed to free_pages() Joey Gouly
2026-10-01 15:42   ` Mark Brown
2026-10-01 15:53     ` Joey Gouly
2026-10-01 15:16 ` [PATCH v3 2/8] lib: arm64: Generalize exception vector definitions for EL2 support Joey Gouly
2026-10-01 15:16 ` [PATCH v3 3/8] lib: arm64: Add stage2 page table management library Joey Gouly
2026-10-01 15:16 ` [PATCH v3 4/8] lib: arm64: Add foundational guest execution framework Joey Gouly
2026-10-01 15:16 ` [PATCH v3 5/8] lib: arm64: Add support for guest exit exception handling Joey Gouly
2026-10-01 15:16 ` [PATCH v3 6/8] lib: arm64: Add guest-internal " Joey Gouly
2026-10-01 15:16 ` [PATCH v3 7/8] arm64: Add Stage-2 MMU demand paging test Joey Gouly
2026-10-01 15:16 ` [PATCH v3 8/8] arm64: Add basic guest execution tests Joey Gouly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox