Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v9 04/16] KVM: arm64: selftests: Test SET_NR_COUNTERS after first run
Date: Mon, 20 Jul 2026 06:08:57 +0000	[thread overview]
Message-ID: <20260720060858.5AEB11F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260720-hybrid-v9-4-2b713ca1b5dc@rsg.ci.i.u-tokyo.ac.jp>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The test ignores the guest's exit state and `ucall` status after executing `vcpu_run()`.
--

--- Patch [4]: [PATCH v9 04/16] KVM: arm64: selftests: Test SET_NR_COUNTERS after first run ---
commit 0382d3a32df9349f988ca69c7b11c92e61c3d384
Author: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

KVM: arm64: selftests: Test SET_NR_COUNTERS after first run

This commit adds a regression test that runs one vCPU and then tries to change
the VM-scoped PMU counter count through an idle sibling to verify that
SET_NR_COUNTERS fails with EBUSY once any vCPU has run.

> diff --git a/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c b/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c
> index 22223395969e0..3b5bb421f401b 100644
> --- a/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c
> +++ b/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c

[ ... ]

> @@ -622,6 +627,37 @@ static bool kvm_supports_nr_counters_attr(void)
>  	return supported;
>  }
>  
> +static void test_set_nr_counters_after_vcpu_run(void)
> +{
> +	struct kvm_vcpu *running_vcpu, *stopped_vcpu;
> +	unsigned int nr_counters = 0;
> +	struct kvm_vcpu_init init;
> +	struct kvm_vm *vm;
> +	int ret;
> +	u64 irq = 23;
> +
> +	vm = vm_create(2);
> +	vm_ioctl(vm, KVM_ARM_PREFERRED_TARGET, &init);
> +	init.features[0] |= BIT(KVM_ARM_VCPU_PMU_V3);
> +	running_vcpu = aarch64_vcpu_add(vm, 0, &init, guest_code_done);
> +	stopped_vcpu = aarch64_vcpu_add(vm, 1, &init, guest_code_done);
> +	kvm_arch_vm_finalize_vcpus(vm);
> +
> +	vcpu_device_attr_set(running_vcpu, KVM_ARM_VCPU_PMU_V3_CTRL,
> +			     KVM_ARM_VCPU_PMU_V3_IRQ, &irq);
> +	vcpu_device_attr_set(running_vcpu, KVM_ARM_VCPU_PMU_V3_CTRL,
> +			     KVM_ARM_VCPU_PMU_V3_INIT, NULL);
> +	vcpu_run(running_vcpu);

[Severity: Medium]
Does this code need to check the guest's exit state and ucall payload?

If the guest payload crashes or hits an unexpected exception, this will silently
ignore the failure and proceed. Since the test only checks for an EBUSY error on
the subsequent ioctl (which will still be returned because the vCPU has been
run), the test will pass despite the guest crash, potentially masking 
virtualization bugs.

> +
> +	ret = __vcpu_device_attr_set(stopped_vcpu, KVM_ARM_VCPU_PMU_V3_CTRL,
> +				     KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS,
> +				     &nr_counters);
> +	TEST_ASSERT(ret == -1 && errno == EBUSY,
> +		    KVM_IOCTL_ERROR(KVM_SET_DEVICE_ATTR, ret));
> +
> +	kvm_vm_free(vm);
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-hybrid-v9-0-2b713ca1b5dc@rsg.ci.i.u-tokyo.ac.jp?part=4

  reply	other threads:[~2026-07-20  6:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  5:37 [PATCH v9 00/16] KVM: arm64: PMU: Use multiple host PMUs Akihiko Odaki
2026-07-20  5:37 ` [PATCH v9 01/16] KVM: arm64: Serialize repeated vCPU initialization Akihiko Odaki
2026-07-20  5:37 ` [PATCH v9 02/16] KVM: arm64: PMU: Stop updating MDCR_EL2.HPMN Akihiko Odaki
2026-07-20  5:58   ` sashiko-bot
2026-07-20  5:37 ` [PATCH v9 03/16] KVM: arm64: PMU: Freeze counter count after first run Akihiko Odaki
2026-07-20  5:37 ` [PATCH v9 04/16] KVM: arm64: selftests: Test SET_NR_COUNTERS " Akihiko Odaki
2026-07-20  6:08   ` sashiko-bot [this message]
2026-07-20  5:37 ` [PATCH v9 05/16] KVM: arm64: PMU: Keep implemented counter mask EL-independent Akihiko Odaki
2026-07-20  5:53   ` sashiko-bot
2026-07-20  5:38 ` [PATCH v9 06/16] KVM: arm64: PMU: Recreate events after MDCR_EL2 changes Akihiko Odaki
2026-07-20  5:57   ` sashiko-bot
2026-07-20  5:38 ` [PATCH v9 07/16] tools headers: Use u* types for bitfield helpers Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 08/16] KVM: arm64: selftests: Cover PMU state in MDCR_EL2 Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 09/16] arm64: errata: Require Apple IMPDEF PMUv3 traps on all CPUs Akihiko Odaki
2026-07-20  6:01   ` sashiko-bot
2026-07-20  5:38 ` [PATCH v9 10/16] KVM: arm64: Don't clear vcpu->cpu in kvm_arch_vcpu_put() Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 11/16] KVM: arm64: PMU: Protect the list of PMUs with RCU Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 12/16] KVM: arm64: PMU: Pass the pPMU to kvm_map_pmu_event() Akihiko Odaki
2026-07-20  6:03   ` sashiko-bot
2026-07-20  5:38 ` [PATCH v9 13/16] KVM: arm64: PMU: Pass the target CPU to kvm_pmu_probe_armpmu() Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 14/16] KVM: arm64: PMU: Implement fixed-counters-only emulation Akihiko Odaki
2026-07-20  6:17   ` sashiko-bot
2026-07-20  5:38 ` [PATCH v9 15/16] KVM: arm64: PMU: Introduce FIXED_COUNTERS_ONLY Akihiko Odaki
2026-07-20  5:38 ` [PATCH v9 16/16] KVM: arm64: selftests: Test PMU_V3_FIXED_COUNTERS_ONLY Akihiko Odaki

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=20260720060858.5AEB11F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox