From: sashiko-bot@kernel.org
To: "Jia He" <justin.he@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
"Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 3/4] KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults
Date: Thu, 03 Dec 2026 11:16:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-247660@kernel.org> (raw)
In-Reply-To: <20261203105805.165749-4-justin.he@arm.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] KVM: arm64: selftests: missing vGICv3 and NV=0 check via
test_supports_el2()
- [Low] KVM: arm64: selftests: vcpu_get_stat() in TEST_ASSERT() can
clobber errno
- [Low] KVM: arm64: selftests: nv_vncr_abort omits kselftest TAP
reporting wrappers
- [Low] KVM: arm64: selftests: empty sigalrm_handler() mishandles EINTR
and timeout
--
commit 417636aa268598b9f55088e6899197d6effa3e67
Author: Jia He <justin.he@arm.com>
KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults
This commit adds an arm64 KVM selftest that enters a nested EL2 context
with HCR_EL2.{NV,NV2} and TCR_EL2.HA set, reads VTTBR_EL2 through the VNCR
page, and verifies KVM's handling of writable and read-only translation
tables with the access flag set or clear.
> diff --git a/tools/testing/selftests/kvm/arm64/nv_vncr_abort.c b/tools/testing/selftests/kvm/arm64/nv_vncr_abort.c
> new file mode 100644
> index 0000000000000..0279a9990d28a
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/arm64/nv_vncr_abort.c
[ ... ]
> +static void sigalrm_handler(int sig)
> +{
> +}
[ ... ]
> + alarm(TIMEOUT_SEC);
> + ret = __vcpu_run(vcpu);
> + alarm(0);
[Severity: Low]
Can an unrelated signal cause a false timeout here, or can a lost SIGALRM
leave __vcpu_run() hung indefinitely?
sigalrm_handler() does not record SIGALRM delivery, and __vcpu_run() is not
retried on EINTR, so any unrelated signal triggers a false timeout failure.
Conversely, if the one-shot alarm fires before KVM_RUN entry, the empty
handler consumes it and __vcpu_run() can block with no timer armed.
Recording SIGALRM in a volatile sig_atomic_t flag, retrying __vcpu_run()
while that flag is clear, and checking it around entry (or using a periodic
ITIMER_REAL) would handle both cases.
> + TEST_ASSERT(!ret || errno != EINTR,
> + "%s: vCPU made no progress in %ds (%lu exits)",
> + mode_name[mode], TIMEOUT_SEC, vcpu_get_stat(vcpu, exits));
> + TEST_ASSERT(!ret, KVM_IOCTL_ERROR(KVM_RUN, ret));
[Severity: Low]
Could vcpu_get_stat(vcpu, exits) clobber errno before it is checked here?
TEST_ASSERT() expands to a function call, so vcpu_get_stat() runs on every
call in unspecified order relative to errno != EINTR, and before the next
TEST_ASSERT() reads errno. On first use, kvm_get_stat() calls calloc() and
pread(), which may overwrite errno and corrupt the failure diagnostic.
Saving errno immediately after __vcpu_run() and only calling vcpu_get_stat()
in the timeout failure branch avoids this and skips the stats lookup on
passing runs.
[ ... ]
> + TEST_REQUIRE(kvm_check_cap(KVM_CAP_ARM_EL2));
[Severity: Medium]
Should this use test_supports_el2() instead of checking KVM_CAP_ARM_EL2
directly?
KVM_CAP_ARM_EL2 does not check for vGICv3 support, so on hosts without
vGICv3 kvm_arch_vm_post_create() leaves vm->arch.has_gic false and the first
KVM_RUN fails with -EAGAIN in kvm_vcpu_first_run_init() ->
kvm_vgic_vcpu_nv_init() -> kvm_vgic_set_owner() instead of skipping.
Using test_supports_el2() also respects the NV=0 environment override used
by other arm64 nested virtualization selftests.
> + TEST_ASSERT(!sigaction(SIGALRM, &sa, NULL), "sigaction failed");
> +
> + run_test(RW_PT_AF_CLEAR);
> + run_test(RO_PT_AF_SET);
> + run_test(RO_PT_AF_CLEAR);
> +
> + return 0;
> +}
[Severity: Low]
This isn't a bug, but the test prints pass lines with pr_info() in
run_test() and returns 0 directly from main() instead of using the kselftest
TAP wrappers.
Checking prerequisites before calling ksft_print_header() and
ksft_set_plan(), then reporting each case with ksft_test_result_pass() and
ending with ksft_finished(), would match kselftest conventions and sibling
arm64 KVM selftests.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203105805.165749-1-justin.he@arm.com?part=3
next prev parent reply other threads:[~2026-12-03 11:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 10:58 [PATCH v4 0/4] KVM: arm64: nv: VNCR page mapping fixes Jia He
2026-12-03 10:58 ` [PATCH v4 1/4] KVM: arm64: nv: Locate the VNCR page in the host page from its PA Jia He
2026-12-03 10:58 ` [PATCH v4 2/4] KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF Jia He
2026-12-03 10:58 ` [PATCH v4 3/4] KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults Jia He
2026-12-03 11:16 ` sashiko-bot [this message]
2026-12-04 1:46 ` Justin He
2026-12-04 9:12 ` Marc Zyngier
2026-12-04 9:51 ` Justin He
2026-12-03 10:58 ` [PATCH v4 4/4] KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory Jia He
2026-12-03 11:16 ` sashiko-bot
2026-12-04 2:59 ` Justin He
2026-12-04 10:24 ` Marc Zyngier
2026-12-04 11:34 ` Justin He
2026-12-04 16:31 ` Marc Zyngier
2026-12-05 1:32 ` Justin He
2026-12-05 9:32 ` Marc Zyngier
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=sashiko-outbox-247660@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=justin.he@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.