From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1979B378D9A for ; Mon, 23 Feb 2026 22:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771884080; cv=none; b=qnNCqoEhYya4JJ6SkwImBwywUxgRroiYnQBRE4vsexIAHQX/m4C0GP8H4R5JKymTjaC+34h0TT+4pQ/tUcoLFdJJX+6jDZdVlTMbfgaldo3rvWnFoCL2SLINlTULZtbq8KdJfjjHf/SZWrj5InABqnzHebByoxuaU0EeDQedWVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771884080; c=relaxed/simple; bh=zWF+NCtRpADOtervza2C6aEMKwILmnR5dL4511kYPCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pa3urPuzpOQVFBTvsbuxiGp0oPJaqYlWYU8zvh8TDE/7TfVmVxZyxRJKN+tPAEs3Sr9r6YswHtZN2P2j/yjXO1mqYB1e+dr2KU+gLQ5lTYWxZ/dYKJcMnHwUgPj6ecUNJ3RujNKsAFGTfvafQrxtduRUvwnFXFiHaB/D1R2kjL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=wUj0KcU2; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="wUj0KcU2" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1771884075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dQ83U9m/a2e/Ppu23P+Ba2u8ukzma9Tyb85B1ba0jL0=; b=wUj0KcU2u3twEozHnhtzONURKNXsZg1wa54+uqk7M1Cb+Q5UBE10EcRoFAf45Ri3Lh1KYe A0u38NwuJltTJJ1ig+ZCqoet3V276pYKLIMbW2QhjeRhpQSuIzidujmWXPCC89Fok6WTHK dgGazTdMymJtpd7kYAdK0Ee26PC7J3k= From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche , Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org Subject: [PATCH 01/62] kvm: Make pi_enable_wakeup_handler() easier to analyze Date: Mon, 23 Feb 2026 14:00:01 -0800 Message-ID: <20260223220102.2158611-2-bart.vanassche@linux.dev> In-Reply-To: <20260223220102.2158611-1-bart.vanassche@linux.dev> References: <20260223220102.2158611-1-bart.vanassche@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Bart Van Assche The Clang thread-safety analyzer does not support comparing expressions that use per_cpu(). Hence introduce a new local variable to capture the address of a per-cpu spinlock. This patch prepares for enabling the Clang thread-safety analyzer. Cc: Sean Christopherson Cc: Paolo Bonzini Cc: kvm@vger.kernel.org Signed-off-by: Bart Van Assche --- arch/x86/kvm/vmx/posted_intr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 4a6d9a17da23..f8711b7b85a8 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -164,6 +164,7 @@ static void pi_enable_wakeup_handler(struct kvm_vcpu *vcpu) struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); struct vcpu_vt *vt = to_vt(vcpu); struct pi_desc old, new; + raw_spinlock_t *wakeup_lock; lockdep_assert_irqs_disabled(); @@ -179,11 +180,11 @@ static void pi_enable_wakeup_handler(struct kvm_vcpu *vcpu) * entirety of the sched_out critical section, i.e. the wakeup handler * can't run while the scheduler locks are held. */ - raw_spin_lock_nested(&per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu), - PI_LOCK_SCHED_OUT); + wakeup_lock = &per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu); + raw_spin_lock_nested(wakeup_lock, PI_LOCK_SCHED_OUT); list_add_tail(&vt->pi_wakeup_list, &per_cpu(wakeup_vcpus_on_cpu, vcpu->cpu)); - raw_spin_unlock(&per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu)); + raw_spin_unlock(wakeup_lock); WARN(pi_test_sn(pi_desc), "PI descriptor SN field set before blocking");