public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
From: Zenghui Yu <zenghui.yu@linux.dev>
To: Oliver Upton <oupton@kernel.org>
Cc: kvmarm@lists.linux.dev, Marc Zyngier <maz@kernel.org>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH v3 15/15] KVM: arm64: selftests: Add test for AT emulation
Date: Tue, 17 Mar 2026 20:51:34 +0800	[thread overview]
Message-ID: <d58819b9-c745-4551-8ea4-e15af3fe63be@linux.dev> (raw)
In-Reply-To: <b951dcfb-0ad1-4d7b-b6ce-d54b272dd9be@linux.dev>

On 2/28/26 5:43 PM, Zenghui Yu wrote:
> Hi Oliver,
> 
> On 11/25/25 3:01 AM, Oliver Upton wrote:
> > +static void handle_sync(struct kvm_vcpu *vcpu, struct ucall *uc)
> > +{
> > +	switch (uc->args[1]) {
> > +	case CLEAR_ACCESS_FLAG:
> > +		/*
> > +		 * Delete + reinstall the memslot to invalidate stage-2
> > +		 * mappings of the stage-1 page tables, forcing KVM to
> > +		 * use the 'slow' AT emulation path.
> 
> Once the guest continues executing instructions, we would get a stage 2
> translation fault (on a S1 PTW) immediately and re-build the stage 2
> mappings for the S1 page tables. Depends on how much we have re-built
> for S1 page tables, the "forcing KVM to use the 'slow' AT emulation
> path" may not always be true.
> 
> I tested it in a QEMU guest (with "-machine virt,virtualization=on \
> -cpu max -accel tcg", so it's essentially a NV2 capable HW!) and it
> failed at the first test_at_insn(S1E2R, expect_fault):
> 
> [root@localhost arm64]# getconf PAGESIZE
> 65536
> [root@localhost arm64]# ./at
> Random seed: 0x6b8b4567
> __vm_create: mode='PA-bits:40,  VA-bits:48,  4K pages' type='0', pages='672'
> ==== Test Assertion Failure ====
>   arm64/at.c:58: (expect_fault) == fault
>   pid=824 tid=824 errno=4 - Interrupted system call
>      1	0x0000000000402d8f: run_test at at.c:137
>      2	0x00000000004020e3: main at at.c:162
>      3	0x0000ffffb07daf3b: ?? ??:0
>      4	0x0000ffffb07db007: ?? ??:0
>      5	0x000000000040222f: _start at ??:?
>   AT S1E2R: expected fault (par: ff00000080000b80)1
> 
> because in my test, the S1 page tables used to translate TEST_ADDR are
> located at
> 
> 	level 0: 0x180000
> 	level 1: 0x181000
> 	level 2: 0x187000
> 	level 3: 0x188000
> 
> All of them had already been re-mapped in stage 2 [*] (in the same 64KB
> physical page) before KVM started to emulate AT S1E2R. The AT_S1E1R
> (fast path) will successfully get the translation result and it's IMP
> DEF that whether an access flag fault will be triggered (QEMU chooses to
> not fault).

Fix myself up: an access flag fault should be taken in this case (with
AF bit is 0 and HA is not enabled). I've just sent a fix to QEMU for
that [*].

Given that we can't force the slow emulation path, we should still avoid
testing the IMP DEF behavior (i.e., TEST_ACCESS_FLAG). I will send a
patch to remove it.

[*] https://lore.kernel.org/r/20260317122517.47627-1-zenghui.yu@linux.dev

Thanks,
Zenghui

  reply	other threads:[~2026-03-17 12:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 19:01 [PATCH v3 00/15] KVM: arm64: nv: Implement FEAT_XNX and FEAT_HAF Oliver Upton
2025-11-24 19:01 ` [PATCH v3 01/15] arm64: Detect FEAT_XNX Oliver Upton
2025-11-24 19:01 ` [PATCH v3 02/15] KVM: arm64: Add support for FEAT_XNX stage-2 permissions Oliver Upton
2025-11-24 19:01 ` [PATCH v3 03/15] KVM: arm64: nv: Forward FEAT_XNX permissions to the shadow stage-2 Oliver Upton
2025-11-24 19:01 ` [PATCH v3 04/15] KVM: arm64: Teach ptdump about FEAT_XNX permissions Oliver Upton
2025-11-25 17:39   ` Nathan Chancellor
2025-11-24 19:01 ` [PATCH v3 05/15] KVM: arm64: nv: Advertise support for FEAT_XNX Oliver Upton
2025-11-24 19:01 ` [PATCH v3 06/15] KVM: arm64: Call helper for reading descriptors directly Oliver Upton
2025-11-24 19:01 ` [PATCH v3 07/15] KVM: arm64: nv: Stop passing vCPU through void ptr in S2 PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 08/15] KVM: arm64: Handle endianness in read helper for emulated PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 09/15] KVM: arm64: nv: Use pgtable definitions in stage-2 walk Oliver Upton
2025-11-24 19:01 ` [PATCH v3 10/15] KVM: arm64: Add helper for swapping guest descriptor Oliver Upton
2025-11-24 19:01 ` [PATCH v3 11/15] KVM: arm64: Propagate PTW errors up to AT emulation Oliver Upton
2025-11-24 19:01 ` [PATCH v3 12/15] KVM: arm64: Implement HW access flag management in stage-1 SW PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 13/15] KVM: arm64: nv: Implement HW access flag management in stage-2 " Oliver Upton
2025-11-24 19:01 ` [PATCH v3 14/15] KVM: arm64: nv: Expose hardware access flag management to NV guests Oliver Upton
2025-11-24 19:01 ` [PATCH v3 15/15] KVM: arm64: selftests: Add test for AT emulation Oliver Upton
2026-02-28  9:43   ` Zenghui Yu
2026-03-17 12:51     ` Zenghui Yu [this message]
2025-11-24 21:25 ` [PATCH v3 00/15] KVM: arm64: nv: Implement FEAT_XNX and FEAT_HAF Marc Zyngier
2025-11-24 22:44 ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d58819b9-c745-4551-8ea4-e15af3fe63be@linux.dev \
    --to=zenghui.yu@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox