[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250906184324.89974-1-hsukrut3@gmail.com>
Date: Sat, 6 Sep 2025 20:43:20 +0200
From: Sukrut Heroorkar <hsukrut3@...il.com>
To:
Cc: skhan@...uxfoundation.org,
david.hunter.linux@...il.com,
Sukrut Heroorkar <hsukrut3@...il.com>,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Shuah Khan <shuah@...nel.org>,
kvm@...r.kernel.org (open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)),
linux-kselftest@...r.kernel.org (open list:KERNEL SELFTEST FRAMEWORK),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] selftests/kvm: Use vcpus count instead of hardcoded 0xff in test_icr
Replace the hardcoded 0xff in test_icr() with the actual number of vcpus
created for the vm. This address the existing TODO and keeps the test
correct if it is ever run with multiple vcpus.
Signed-off-by: Sukrut Heroorkar <hsukrut3@...il.com>
---
tools/testing/selftests/kvm/x86/xapic_state_test.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/x86/xapic_state_test.c b/tools/testing/selftests/kvm/x86/xapic_state_test.c
index fdebff1165c7..4af36682503e 100644
--- a/tools/testing/selftests/kvm/x86/xapic_state_test.c
+++ b/tools/testing/selftests/kvm/x86/xapic_state_test.c
@@ -56,6 +56,17 @@ static void x2apic_guest_code(void)
} while (1);
}
+static unsigned int vm_nr_vcpus(struct kvm_vm *vm)
+{
+ struct kvm_vcpu *vcpu;
+ unsigned int count = 0;
+
+ list_for_each_entry(vcpu, &vm->vcpus, list)
+ count++;
+
+ return count;
+}
+
static void ____test_icr(struct xapic_vcpu *x, uint64_t val)
{
struct kvm_vcpu *vcpu = x->vcpu;
@@ -124,7 +135,7 @@ static void test_icr(struct xapic_vcpu *x)
* vCPUs, not vcpu.id + 1. Arbitrarily use vector 0xff.
*/
icr = APIC_INT_ASSERT | 0xff;
- for (i = 0; i < 0xff; i++) {
+ for (i = 0; i < vm_nr_vcpus(vcpu->vm); i++) {
if (i == vcpu->id)
continue;
for (j = 0; j < 8; j++)
--
2.43.0
Powered by blists - more mailing lists