All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dan Carpenter" <dan@pereq.eu>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 9/9] KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state
Date: Fri, 04 Dec 2026 09:20:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-249490@kernel.org> (raw)
In-Reply-To: <20261204-double_exception_v4-v4-9-523921511673@pereq.eu>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] kvm/arm64: main() silently omits EL2 subtest instead of
  reporting a TAP skip
- [Low] kvm/arm64: unpinned vCPU resets in test_reset() can fail on
  big.LITTLE CPUs
- [Low] kvm/arm64: assert_reg_eq() truncates >8-byte registers in
  failure output
--

commit 864ec7b1b20682adde35519d9d1591ff55326655
Author: Dan Carpenter <dan@pereq.eu>

KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state

This commit adds an arm64 KVM selftest that dirties vCPU state, runs
KVM_ARM_VCPU_INIT, and compares the resulting registers against a freshly
initialized vCPU both with and without EL2.

> diff --git a/tools/testing/selftests/kvm/arm64/vcpu_reset.c b/tools/testing/selftests/kvm/arm64/vcpu_reset.c
> new file mode 100644
> index 0000000000000..dcf5215df8655
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/arm64/vcpu_reset.c

[ ... ]

> +static void assert_reg_eq(u64 id, const u8 *got, const u8 *want, const char *what)
> +{
> +	u64 size = KVM_REG_SIZE(id);
> +	u64 g = 0, w = 0;
> +
> +	if (!memcmp(got, want, size))
> +		return;
> +
> +	memcpy(&g, got, size < 8 ? size : 8);
> +	memcpy(&w, want, size < 8 ? size : 8);
> +	TEST_FAIL("Register 0x%llx is 0x%lx after the reset, %s 0x%lx",
> +		  (unsigned long long)id, (unsigned long)g, what, (unsigned long)w);
> +}

[Severity: Low]
Will assert_reg_eq() print misleading values when a register wider than 8
bytes mismatches?

On arm64, KVM_GET_REG_LIST includes 128-bit FP/SIMD vector registers.
memcmp() checks all size bytes, but memcpy() only copies the low 8 bytes
into g and w, so a mismatch in the upper bytes prints identical got and
expected values.

[ ... ]

> +	ref_vm = create_vcpu(el2, &ref);
> +	vcpu_ioctl(ref, KVM_ARM_VCPU_INIT, &ref->init);
> +	vcpu_run_complete_io(ref);
> +	get_regs(ref, &new);

[ ... ]

> +	vcpu_ioctl(vcpu, KVM_ARM_VCPU_INIT, &vcpu->init);

[Severity: Low]
Can test_reset() fail spuriously on heterogeneous (big.LITTLE) systems if
the test thread migrates between cores between these two KVM_ARM_VCPU_INIT
calls?

In arch/arm64/kvm/sys_regs.c, reset_actlr() and reset_amair_el1() initialize
ACTLR_EL1 and AMAIR_EL1 directly from the current physical CPU's registers.
Pinning the test thread to a single CPU (for example with
sched_setaffinity()) would avoid spurious mismatches in assert_reg_eq().

[ ... ]

> +int main(void)
> +{
> +	bool el2 = test_supports_el2();
> +
> +	ksft_print_header();
> +	ksft_set_plan(el2 ? 2 : 1);
> +
> +	test_reset(false);
> +	ksft_test_result_pass("reset without EL2\n");
> +
> +	if (el2) {
> +		test_reset(true);
> +		ksft_test_result_pass("reset with EL2\n");
> +	}
> +
> +	ksft_finished();
> +}

[Severity: Low]
Should main() report a TAP skip instead of shrinking the plan when
test_supports_el2() returns false?

Right now the EL2 subtest is silently omitted without a skip reason.
Keeping ksft_set_plan(2) and calling ksft_test_result_skip() with a reason
in an else branch reports the missing prerequisite while still exiting with
KSFT_PASS.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-double_exception_v4-v4-0-523921511673@pereq.eu?part=9

      reply	other threads:[~2026-12-04  9:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  8:48 [PATCH v4 0/9] KVM: arm64: Fix kvm_reset_vcpu() and SError handling for nested virt Dan Carpenter
2026-12-04  8:48 ` [PATCH v4 1/9] KVM: arm64: nv: Use a vcpu request to reprogram the PMU Dan Carpenter
2026-12-04  8:48 ` [PATCH v4 2/9] KVM: arm64: Drop an incomplete MMIO access when resetting a vcpu Dan Carpenter
2026-12-04  9:24   ` Steffen Eiden
2026-12-04  8:48 ` [PATCH v4 3/9] KVM: arm64: Reset SP_EL1, ELR_EL1 and SPSR_EL1 " Dan Carpenter
2026-12-04  8:48 ` [PATCH v4 4/9] KVM: arm64: Discard a pending SError " Dan Carpenter
2026-12-04  9:03   ` sashiko-bot
2026-12-04  8:48 ` [PATCH v4 5/9] KVM: arm64: nv: Discard nested SError in kvm_reset_vcpu() Dan Carpenter
2026-12-04  9:03   ` sashiko-bot
2026-12-04  8:48 ` [PATCH v4 6/9] KVM: arm64: nv: Replace a pending SError when injecting a new one Dan Carpenter
2026-12-04  8:48 ` [PATCH v4 7/9] KVM: arm64: nv: Don't deliver a pending SError to the wrong guest Dan Carpenter
2026-12-04  9:17   ` sashiko-bot
2026-12-04  8:48 ` [PATCH v4 8/9] KVM: arm64: nv: Re-inject a stored SError after the exit is handled Dan Carpenter
2026-12-04  9:22   ` sashiko-bot
2026-12-04 14:23     ` Dan Carpenter
2026-12-04  8:48 ` [PATCH v4 9/9] KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state Dan Carpenter
2026-12-04  9:20   ` sashiko-bot [this message]

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-249490@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dan@pereq.eu \
    --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.