From nobody Mon Sep 28 03:42:23 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9077F286D5D for ; Thu, 27 Aug 2026 04:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787805962; cv=none; b=RmjNsvw5wydtdHYuYZxTl+vsn4ZSIeHAH0SIriwIj/ltVZG/zFc4uyvY5s30FaCePyrlUHS/gu8nyaPwGFC39yuVIa5L4996ogmjH+Tj6RHAnMY059VIZLlBJnTRfVBcMtSdH3ptSyJnjcw76fh0Z7Imrkavgb3x+lvAhX5AsOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787805962; c=relaxed/simple; bh=7nneyVx7k7xrEDZv0nl9gc2vrg8v2b/keKLgPkrNOU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJXnTis+uzVhm7ydvOcPlDkOm6ph84rGx8ULOn2MtF/wWLH/lH7bXbZj86XpBllU/u3Qq5UXaTEkGg4pqgbHeQw/5Iw3mgyHbeFoKnPxkNGjTf70G6RoFlXiva55Ofusp9OLLv0Yhw3czKp172ZdMzUts9/9xblS6XA6ww+L72s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l05uRgsm; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l05uRgsm" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2d049069377so21451935ad.0 for ; Wed, 26 Aug 2026 21:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787805961; x=1788410761; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sEzr0jYee/fARbmWPhLxuBfGYBmn4khYyL4pUGs2CjQ=; b=l05uRgsmde9ziZiAkR6xFPVmo4ark2OKWExizHJnevSQOVY2ICmzWawhuGbPRqc1yd WHjxRTs/y7LMZessUhYFfzwIph9RNVbwhG/mG0+nPQQhW9939gtWxDMi7ZnnwmIjmgGa 99jzK5dESXfDDVCFOreehCxYLsBV+NYJFG8s79kKDkegL0BYixLoBiExyT1CEKjY+lcK bXYH6cBkt+q88cXbQF94F0WVkk7BFyc3mgX1EYrQ33QqdP5m/RhZgbx//DZ8qpDHHl8i Lm45d5Bv3MkKC1awjRxzYrogY8av99bOlkBcRuGD24nNU6XUtEGvfowlaEiAQnaIF+TD uQ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787805961; x=1788410761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sEzr0jYee/fARbmWPhLxuBfGYBmn4khYyL4pUGs2CjQ=; b=T05hEIVeQu/DaozPdkeV1SZwfq2KeZejQXpRGLol6yTXYaqLSLAxkQu1FqpkQwrCui xwzhBKwj0Tae9bUM+UAxB2MXf/j7tczAq0f5yzkgBg9mde6OT+mQQzZHjvYPD+D9xrkv LY/8zTvgSu1rI+yUxAJaGsdLTYpfle5AduVvQFsNzw6i9lRTdKSCrD+SXyTKV6ihCN0e nih+viE+Ppsh8qApxg0R/3GjhvtWwncjo0D05YpqaiQJuE9lZfwHtSFxFzS2U0Y1r9wV A6svmX/np1DHgKDnr6BTK+zwKhFgg78hWwGF3yjEoqz1KDCuvKhG7WvWjbep96xgWeST /YLQ== X-Forwarded-Encrypted: i=1; AHgh+RqPUlhx/PzUazhbb7S3twWUDWS4NkDP8Yr6Kb4pG73aG0LOpFzHD/W1N29zUm/I7skF7Vr/EyMNixZfrCY=@vger.kernel.org X-Gm-Message-State: AFuF++kSUKr+8RDttyRG47rkFgVF799piq7N/K4fB9kYUNK/zH7xouf5 9U8WuQOS9NxlEm/wSt3+bch+SSlTQnXDEAQz5b0X2PPbJQAedBH96eED X-Gm-Gg: AR+sD11y8i+03ubLtzakmTjSwrD5mTB9RaV19ryRnGmFaARqE7NWvW7oQkXMdBSTkuF HUZlRBh1kQxFp3Zdw6QiQxz0HkS1RO7qpPcXHvUnUuTYfVxeGgmjT2nCLVq4V0ngGLLOzftlJy0 m9mUKGbzVJPxrSAY+awZDFswL8AJEwaWqThM0ya2ChHZQnzbeC5azea4SiiI3AACkNClbnjCZ8C pdjIbFh+bH3nbKBuMfN0o6Um3/kuLPsHFv6VqojjwA6ucXlAIieSr0Y6U1+FMK2UeZNRydwKa8R yJ+K87AkVsZqfT1mOVcb7QDRRWWYd8jXQ9huJa/DFQSSROQMDWckpkq5IvjHUi7+sb6FWldEz4i 5NDak0mkgSxer833uLLAYe4GC6Q5KmBFR9k3MM1RDPWPH0ZEjBEw2ULPKhATRaSkSl5O9NDkWFE DZGGIKqxAEMSPJcB0kfPlROMwNvSmV4Hmyd65Z2zlWCkZl0XqXRpSDRzYj7Vm28DLX2KVn/APpF HmK5bu+rHU= X-Received: by 2002:a17:903:320e:b0:2c8:2808:3ec9 with SMTP id d9443c01a7336-2d707beaf8fmr248904825ad.12.1787805960656; Wed, 26 Aug 2026 21:46:00 -0700 (PDT) Received: from volcano9f8e-host.amd.com ([165.204.217.251]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3285a5f96efsm2270583eec.11.2026.08.26.21.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 21:46:00 -0700 (PDT) From: Hemanth Selam To: seanjc@google.com, pbonzini@redhat.com, shuah@kernel.org Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] KVM: selftests: Add a helper to read a vCPU's APIC ID Date: Thu, 27 Aug 2026 10:15:33 +0530 Message-ID: <20260827044534.2900285-2-hemanth.selam@gmail.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260827044534.2900285-1-hemanth.selam@gmail.com> References: <20260827044534.2900285-1-hemanth.selam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reading a vCPU's APIC ID from the host means open coding KVM_GET_LAPIC and picking the field out of the register block, which several tests already do. Add a helper next to the other APIC definitions so that a test that needs to target a vCPU, e.g. to send it an IPI, can just ask for its ID. Handle both APIC modes, since where KVM reports the ID depends on the mode and, for x2APIC, on whether userspace enabled KVM_X2APIC_API_USE_32BIT_IDS: read APIC_ID for xAPIC, where the guest can rename itself, and use the vCPU ID for x2APIC, which KVM keeps equal to it. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam --- .../testing/selftests/kvm/include/x86/apic.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86/apic.h b/tools/testing= /selftests/kvm/include/x86/apic.h index 31887bdc3d6c..df8815bd57af 100644 --- a/tools/testing/selftests/kvm/include/x86/apic.h +++ b/tools/testing/selftests/kvm/include/x86/apic.h @@ -79,6 +79,26 @@ void apic_disable(void); void xapic_enable(void); void x2apic_enable(void); =20 +/* + * Reads the APIC ID of a vCPU from the host, e.g. to target an IPI at it. + * + * In xAPIC mode the guest can change its own ID, so read it back from KVM, + * where it lives in bits 31:24 of APIC_ID. In x2APIC mode KVM ties the I= D to + * the vCPU ID, and reports it in APIC_ID either as-is or shifted left by = 24 + * depending on KVM_X2APIC_API_USE_32BIT_IDS, so use the vCPU ID instead of + * having to know which format the VM opted into. + */ +static inline u32 vcpu_get_apic_id(struct kvm_vcpu *vcpu) +{ + struct kvm_lapic_state lapic; + + if (vcpu_get_msr(vcpu, MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD) + return vcpu->id; + + vcpu_ioctl(vcpu, KVM_GET_LAPIC, &lapic); + return GET_APIC_ID_FIELD(*(u32 *)&lapic.regs[APIC_ID]); +} + static inline u32 get_bsp_flag(void) { return rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_BSP; --=20 2.43.7 From nobody Mon Sep 28 03:42:23 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F28D390CBF for ; Thu, 27 Aug 2026 04:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787805965; cv=none; b=FtWfBpLM7t7u8hG56mOOAoIEjyX8FsVw5Cno5pegM7Dt2FYIcv/6jtcGtJ0XcWM0itbSXQn3m5KxHnwN0Slcw/QfP/F0rOBhAOPcwNa/rXUOn4YikQvn5D1f2a9+iCAYdDLeXE3ZFZ4DSKK0j63VEwjGASrXguJnM1/j5j/etKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787805965; c=relaxed/simple; bh=wni/gdqNYjH6EHVDgouLtJx3/7zkJMxUoU3e/kmIOy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mFMrqOXxM1KZbNIfEWQ5HtjnPk2K8Yc6zeib6wvuQB70l9WK0JE+G+W3KuikCahGaG8xjKuAd33xB+vedFwtQlLj7rD9bLbv50qq7m46v9HxogXIOjm4IhY72euedgkXvvTs7LlZQy1UrId9epP+t7LmXBPHgTKHYLBrMCOqbZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MC79qChj; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MC79qChj" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-3964e480f76so2340890a91.1 for ; Wed, 26 Aug 2026 21:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787805963; x=1788410763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=d1I+EG9o+WscjAZPY2e61wmmiFBvV5FXVeqxFAMLmVA=; b=MC79qChj8tH2tSEjzIAUeKlw0q72ksBE1n7gLZNyQa/pXJbvTmLBCrUyDaWLE4ALqu bnV8NTgnjqnryheGjT6QYK7eEaI9u0oo6k2g0B1MgUgoix939iUAuLbL3ef6NM2QhVb2 BzN+vyD3H1iS9qS3rZfxNJhQL/SiEgoLLlvrlsIDwDkMknyUOuCIiXR+h9p6Q3eWhPJg kiX3EdyFAdKJcuzYqnUmcr+e1hr+KIjM3jdj9t8Lx/wDv/LsAt9UVx7jJNj6HNcgBTjO zkOgh1BQgnfTT4mmZGo33N7F1A+ScFGG4B0TWLW33j3VsrXNhYpr4pFp7ZowzEuSwpnp eIGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787805963; x=1788410763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=d1I+EG9o+WscjAZPY2e61wmmiFBvV5FXVeqxFAMLmVA=; b=fHDweUwzYC5hV+yd3silHTuWjZKKifinI0z/DC3Yod2VhGdyK8uqcwdOmy0UVZ7wTr rTJtcX3cD1GFpmAL/hQJFCjf0MZWmmj6vXFXqqoCFPPz8E2u78ClkNEsUvXTn+5anted fkLcpKH3p4l+5pvAGZIpMh3RNgYEJ2VQLP6uw6Kmt0KIZ3ghrntUHXE/JQrQP0B69gwr hOp5sunuzixMp2/V+xAy2rzzseNGXFAErfxD4nRUImch2g+HSuzyZcFoVigcI5V23U1C 1/mJMDPteY5NHC1bvzVxj/jEMlP5JlngK3XCy/Z6Ms7ehxvJljXpyQrnV4JTap33pCKN 5Ing== X-Forwarded-Encrypted: i=1; AHgh+Rrk0qIO8pLKLRwnBzr9U8hp6KQknxcAOwQU2wZBo6KGKLo+2qsqSz+irPI7W2I2MGSZKskkW/YTN1/VF1c=@vger.kernel.org X-Gm-Message-State: AFuF++mKjZrQ1G0EKWVobgJ06G+080Xo1ahhC3Y6+6udGYzBdTVCJOTF 3Y6SUCCoiXQNZJg4xJOLAKhjDHmpZM4NpYlqUHZZY8bgZ7C2XVzDzZVs X-Gm-Gg: AR+sD12zUivW+5XNoUgu5bdjpMy+XMZwd5c3UQ30Tgt5iwF8pVW4QJwSIxpwWLUUotf LHqB5Y18PDgPy1D8kML0oqva37NJrRiyaxB02w/n9ueL910FAVE17oWMVfrENGR8ZLRacFW8cRD dUE9LBEc1GRIb3URf98eK3pQ2GXFyM8AsOTU5KCNJO7AL6zGWXYx1VfOO/SoT/3B9ScvbOyRuFH n4H3SSmwtxoSZkHyKTRQ/nRO55wgWw4L7uIZCwSzbjG9CVodDvXRxRuDdM+Vz0M4K+VSg0c+ElT r5NJUwU1blNeR2MxQc1L7Zaum+9z4FH7SEI/EMipUj5tlKugSbOiYGHCrEwcdKnVP7+iiiKZoQs HdCyyq4Y7E1pcGieEz1UdGxRPaW0W3OwSiSYBExvaT+eUAmIfOOhp9zf0LoKmx9unUszVp+Ecr3 AweJj4xgE6XWXAm7osMTBCW7r6zcxlhjMrdl9je24TVARwYCjZCPuxe3o+ap1zcjrwL6aIKU09y Ew7XYoO0Jro X-Received: by 2002:a17:90a:d44c:b0:396:5f7f:52f5 with SMTP id 98e67ed59e1d1-3966d366aa3mr25418355a91.3.1787805963458; Wed, 26 Aug 2026 21:46:03 -0700 (PDT) Received: from volcano9f8e-host.amd.com ([165.204.217.251]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3285a5f96efsm2270583eec.11.2026.08.26.21.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 21:46:03 -0700 (PDT) From: Hemanth Selam To: seanjc@google.com, pbonzini@redhat.com, shuah@kernel.org Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] KVM: selftests: Test the PV_UNHALT feature, not just its CPUID bit Date: Thu, 27 Aug 2026 10:15:34 +0530 Message-ID: <20260827044534.2900285-3-hemanth.selam@gmail.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260827044534.2900285-1-hemanth.selam@gmail.com> References: <20260827044534.2900285-1-hemanth.selam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" test_pv_unhalt() only checks that KVM clears KVM_FEATURE_PV_UNHALT from guest CPUID when HLT-exiting is disabled. The feature itself has never been exercised, hence the FIXME. Add a two vCPU test for it. One vCPU halts with interrupts disabled, so nothing except the KVM_HC_KICK_CPU issued by the other can resume it: KVM delivers the kick as APIC_DM_REMRD, which sets pv_unhalted and makes the vCPU runnable without injecting an interrupt. Reaching the instruction after HLT is therefore proof that the kick arrived. Give the halting vCPU a non-zero APIC ID, so that a kick aimed at the wrong vCPU fails the test instead of hitting the halter by chance, and enable its APIC as a guest using PV spinlocks would, since KVM only routes the kick once the vCPU's APIC is in the map. Wait for the halter's halt_exits to tick before kicking so that the kick lands on a vCPU that has actually halted, and bound the wait so a vCPU that never halts fails the test instead of hanging it. The kicking vCPU runs with KVM_CAP_ENFORCE_PV_FEATURE_CPUID enabled and PV_UNHALT advertised, so that KVM services the hypercall because the feature is exposed rather than because enforcement is off. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam --- tools/testing/selftests/kvm/x86/kvm_pv_test.c | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86/kvm_pv_test.c b/tools/testing/= selftests/kvm/x86/kvm_pv_test.c index 8ed5fa635021..120d08ac25ce 100644 --- a/tools/testing/selftests/kvm/x86/kvm_pv_test.c +++ b/tools/testing/selftests/kvm/x86/kvm_pv_test.c @@ -6,8 +6,10 @@ */ #include #include +#include #include =20 +#include "apic.h" #include "test_util.h" #include "kvm_util.h" #include "processor.h" @@ -193,7 +195,99 @@ static void test_pv_unhalt(void) TEST_ASSERT(!vcpu_cpuid_has(vcpu, X86_FEATURE_KVM_PV_UNHALT), "PV_UNHALT set in guest CPUID when HLT-exiting is disabled"); =20 - /* FIXME: actually test KVM_FEATURE_PV_UNHALT feature */ + kvm_vm_free(vm); +} + +static void pv_unhalt_halter_guest_code(void) +{ + /* + * Enable the local APIC, as a guest that uses PV spinlocks would. KVM + * only routes the kick to this vCPU once its APIC is in the map. + */ + xapic_enable(); + + /* + * Interrupts are disabled, so nothing except the KVM_HC_KICK_CPU from + * the other vCPU can end the halt, i.e. reaching GUEST_DONE() proves + * the kick was delivered. + */ + asm volatile("cli; hlt"); + + GUEST_DONE(); +} + +static void pv_unhalt_kicker_guest_code(u32 halter_apic_id) +{ + /* KVM takes flags in a0 and the APIC ID to kick in a1. */ + GUEST_ASSERT_EQ(kvm_hypercall(KVM_HC_KICK_CPU, 0, halter_apic_id, 0, 0), = 0); + GUEST_DONE(); +} + +static void run_guest_to_done(struct kvm_vcpu *vcpu) +{ + struct ucall uc; + u64 cmd; + + vcpu_run(vcpu); + TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO); + + cmd =3D get_ucall(vcpu, &uc); + if (cmd =3D=3D UCALL_ABORT) + REPORT_GUEST_ASSERT(uc); + TEST_ASSERT_EQ(cmd, UCALL_DONE); +} + +static void *pv_unhalt_halter_thread(void *vcpu) +{ + run_guest_to_done(vcpu); + return NULL; +} + +static void test_pv_unhalt_kick(void) +{ + struct kvm_vcpu *halter, *kicker; + struct timespec start; + struct kvm_vm *vm; + pthread_t thread; + int r; + + pr_info("testing KVM_HC_KICK_CPU\n"); + + /* + * Give the halter a non-zero APIC ID, so that a kick sent to the wrong + * vCPU fails the test instead of hitting the halter by chance. + */ + vm =3D vm_create_with_one_vcpu(&kicker, pv_unhalt_kicker_guest_code); + halter =3D vm_vcpu_add(vm, 1, pv_unhalt_halter_guest_code); + virt_pg_map(vm, APIC_DEFAULT_GPA, APIC_DEFAULT_GPA); + + /* + * Enforce the PV CPUID so that KVM services the hypercall because + * PV_UNHALT is advertised to the kicker, and not because enforcement + * is off. KVM advertises PV_UNHALT by default while HLT-exiting is + * enabled; set it explicitly so that the test keeps testing the + * feature if that ever changes. + */ + vcpu_enable_cap(kicker, KVM_CAP_ENFORCE_PV_FEATURE_CPUID, 1); + vcpu_set_cpuid_feature(kicker, X86_FEATURE_KVM_PV_UNHALT); + vcpu_args_set(kicker, 1, vcpu_get_apic_id(halter)); + + r =3D pthread_create(&thread, NULL, pv_unhalt_halter_thread, halter); + TEST_ASSERT(!r, "pthread_create halter failed, error=3D%d", r); + + /* Kick only once the halter has taken its HLT exit. */ + clock_gettime(CLOCK_MONOTONIC, &start); + while (!vcpu_get_stat(halter, halt_exits)) { + TEST_ASSERT(timespec_elapsed(start).tv_sec < 10, + "vCPU never halted"); + usleep(100); + } + + run_guest_to_done(kicker); + + /* Nothing except the kick can get the halter to GUEST_DONE(). */ + r =3D pthread_join(thread, NULL); + TEST_ASSERT(!r, "pthread_join halter failed, error=3D%d", r); =20 kvm_vm_free(vm); } @@ -215,4 +309,5 @@ int main(void) kvm_vm_free(vm); =20 test_pv_unhalt(); + test_pv_unhalt_kick(); } --=20 2.43.7