Re: [PATCH v2] KVM: arm64: selftests: Test VNCR translation invalidation

From: Fuad Tabba

Date: Fri Oct 23 2026 - 04:21:45 EST


Hi Itaru,

On Thu, 22 Oct 2026 09:11:18 +0100, Itaru Kitayama
<itaru.kitayama@xxxxxxxxxxx> wrote:
> Add a standalone KVM selftest that checks VNCR accesses after L1
> updates its stage-1 mapping and issues a TLBI.

Could you add a sentence on what this guards? KVM caches L1's
translation of VNCR_EL2 and has to drop it when L1 invalidates that
mapping, in kvm_handle_s1e2_tlbi().

[...]
> diff --git a/tools/testing/selftests/kvm/arm64/nv_vncr_tlbi_test.c b/tools/testing/selftests/kvm/arm64/nv_vncr_tlbi_test.c
[...]
> +static void handle_l2_hvc(struct ex_regs *regs)
[...]
> + case 2:
> + /* Check invalidation again, with the mapping reversed. */
> + GUEST_ASSERT_EQ(regs->regs[0], WRITE_A);
> + GUEST_ASSERT_EQ(READ_ONCE(*cfg.slot_a), WRITE_A_AGAIN);
> + GUEST_ASSERT_EQ(READ_ONCE(*cfg.slot_b), WRITE_B);
> +
> + GUEST_DONE();
> + default:

Could you add a break here? GUEST_DONE() isn't noreturn, so this falls
through into default:.

[...]
> +int main(void)
[...]
> + case UCALL_DONE:
> + pr_info("PASS: VNCR accesses followed A -> B -> A mappings; "
> + "inactive backing slots remained unchanged\n");

Could you align the second line of the string under the first?

I ran it on QEMU with kvm-arm.mode=nested and it passes. With the VNCR
invalidation in kvm_handle_s1e2_tlbi() disabled, it fails at the round
1 check, so it catches the bug it's meant to.

Tested-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>

With the issues above fixed:
Reviewed-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>

Cheers,
/fuad