Hi Oliver,

On Fri, May 29, 2026 at 02:38:53PM +0100, Wei-Lin Chang wrote:
> Hi Oliver,
> 
> On Tue, May 19, 2026 at 02:31:09PM -0700, Oliver Upton wrote:
> > Hi Wei-Lin,
> > 
> > Thank you very much for the series.
> > 
> > I haven't had time to read through much of this yet, but I noticed
> > Itaru's comment about leaving stage-1 translation disabled for the L2.
> > 
> > Since selftests expects things like atomics to work we will definitely
> > need the stage-1 MMU to be enabled w/ Normal mappings (this was broken
> > in the past [*]). I wonder if we can (ab)use the pre-existing stage-1
> > tables that the selftests library creates on behalf of the L1. After all,
> > L1 and L2 are both effectively in the same virtual address space.
> > 
> > [*] 
> > https://lore.kernel.org/kvmarm/[email protected]/
> 
> Thanks for the pointer, I see, only inner/outer shareable, write-back
> normal memory guarantees atomics to work. Interestingly, treating the
> atomic instruction as a NOP is one of the permitted outcomes if other
> memory attributes are used...
> 
> However, the L2s in this series aren't using atomic instructions, and
> right now for the current organization of this series, the L1 guest
> hypervisor infrastructure is in lib/ for future NV selftests to share L2
> creation code, but L2 code are entirely per selftest. This means other
> selftest L2s can reuse the L1 stage-1 tables themselves if the implicit
> memory attributes that comes from MMU being off is not desired.
> 
> Sorry if that sounded defensive, I am not opposed to always reusing the
> L1 stage-1 tables in L2, just wanted to make sure the point gets across.
> 
> Always reusing L1 stage-1 tables in L2 allows L2 access to lib/ (which
> should be helpful for testing recursive NV), and L1-L2 code sharing
> intra-selftest. OTOH things are a bit simpler with MMU off in this case
> with testing the shadow stage2.
> 
> What do you think?

Gentle ping on this :)
Would love to hear what you think.

Thanks,
Wei-Lin Chang

> 
> Thanks,
> Wei-Lin Chang
> 
> > 
> > Thanks,
> > Oliver
> > 
> > On Sat, May 16, 2026 at 07:29:54PM +0100, Wei-Lin Chang wrote:
> > > Hi,
> > > 
> > > This is v3 of adding basic support for running nested guests (L2) in
> > > kselftest. This time a framework for enabling stage-2 in the guest is
> > > added, including the s2_mmu struct, s2 translation control setup, and
> > > a stage-2 page table generator. Similar to L2 vCPU management, all
> > > stage-2 work is done in the guest instead of userspace.
> > > 
> > > An additional shadow_stage2 test is added which leverages the framework
> > > to run L2 with stage-2 enabled.
> > > 
> > > * Changes from v2 [1]:
> > > 
> > >   - Update vm_paddr_t to gpa_t, vm_vaddr_t to gva_t.
> > > 
> > >   - Added framework for enabling stage-2 in the guest.
> > > 
> > >   - Added shadow_stage2 test.
> > > 
> > > Thanks!
> > > 
> > > [1]: 
> > > https://lore.kernel.org/kvmarm/[email protected]/
> > > 
> > > Wei-Lin Chang (9):
> > >   KVM: arm64: selftests: Add GPR save/restore functions for NV
> > >   KVM: arm64: selftests: Add helpers for guest hypervisors
> > >   KVM: arm64: selftests: Add hello_nested basic NV selftest
> > >   KVM: arm64: selftests: Enhance hello_nested test
> > >   KVM: arm64: selftests: Add shadow_stage2 test
> > >   KVM: arm64: selftests: shadow_stage2: Allocate L2 stack from dedicated
> > >     pool
> > >   KVM: arm64: selftests: shadow_stage2: Check supported stage-2 granule
> > >     size
> > >   KVM: arm64: selftests: Add infrastructure for using stage-2 in guest
> > >   KVM: arm64: selftests: shadow_stage2: Turn on stage-2 translation for
> > >     the nested guest
> > > 
> > >  tools/testing/selftests/kvm/Makefile.kvm      |   5 +
> > >  .../selftests/kvm/arm64/hello_nested.c        | 134 +++++++++
> > >  .../selftests/kvm/arm64/shadow_stage2.c       | 165 +++++++++++
> > >  .../selftests/kvm/include/arm64/nested.h      |  85 ++++++
> > >  tools/testing/selftests/kvm/lib/arm64/entry.S | 137 +++++++++
> > >  .../selftests/kvm/lib/arm64/hyp-entry.S       |  77 +++++
> > >  .../testing/selftests/kvm/lib/arm64/nested.c  | 264 ++++++++++++++++++
> > >  7 files changed, 867 insertions(+)
> > >  create mode 100644 tools/testing/selftests/kvm/arm64/hello_nested.c
> > >  create mode 100644 tools/testing/selftests/kvm/arm64/shadow_stage2.c
> > >  create mode 100644 tools/testing/selftests/kvm/include/arm64/nested.h
> > >  create mode 100644 tools/testing/selftests/kvm/lib/arm64/entry.S
> > >  create mode 100644 tools/testing/selftests/kvm/lib/arm64/hyp-entry.S
> > >  create mode 100644 tools/testing/selftests/kvm/lib/arm64/nested.c
> > > 
> > > -- 
> > > 2.43.0
> > > 
> > > 

Reply via email to