From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 1A028315D29 for ; Sat, 6 Dec 2025 00:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981798; cv=none; b=r83Lo4nOTii+hMcg5ECib6WxUSMNqoMxdZ8JWXkc/QdsK6CKGFSl4SanAGVQcNv2GxdB6NOO7XjlJLaHRfJjYXfeREBnNCgWn9C7n9tmNFkdfDLLCmTuW1XjGplugNew8E9uow7FMr6D+tXXjEL3+iCWoHsY5OGvvp9KHl+JfLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981798; c=relaxed/simple; bh=iChR0Rc4BB9WG7gSWIif9Hae1GK7UMbvihwokYDapp8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mrM39+zi56t7dz4BKyGqgf4TK/8zAFzSVrbvy6AisXBJFOtVCdqdBtCkEqg3g8T0ldEwdOiXyllydD0uGDa8pgALYJG0NIB0ubqPBmn2erp2jO/3qaZXS691gjbwgZuOeQKQ4YVPgjw+5anLS1kH9GW5d0jcanmyXu5JudRsWGQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lOPrXEBL; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lOPrXEBL" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-29557f43d56so34959495ad.3 for ; Fri, 05 Dec 2025 16:43:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981796; x=1765586596; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=nDbfRGVCOdB8q8+bSZUn6u1eLIn1JShiu3JRgjwMHyI=; b=lOPrXEBL83pUdariqM2GocB/5ejBWc/nlw4rmkyp1jWkf6Awdd/TqkXzaG+pZXvKvD cKLqLpmlaRe6iB3dltuHVgMY4BeCOypey/1qZlCEYlxShg0Ah5ffDOCgtwGIixizzgGf tK7xOQM2ztbkz0ykcymhY1vSi4bO0uf+5bLmtoMXzXJFtC8GMazrKjTr2MK7/vlgUJ0/ 7LV6UHsMJXuPgvQpbPYA2bdwSEDQc3zIxLNPU1bW42TvlAC8CqPmTNdssq2TeHtDyEc+ VKpFHL7Eml5daGtTDevkQvpJp5w3LA9kxDV4T3pCl3kaAEd58Dkkf0WwJ7KR74WwZujY 5cvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981796; x=1765586596; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nDbfRGVCOdB8q8+bSZUn6u1eLIn1JShiu3JRgjwMHyI=; b=R09ptGYSIpyczed6cxtncDxanTr/lgYjx+7jZKWXL+912k9EI5QAxFEDfwY4JLbHEv 55GwwCc6Kmt+Y4z8KBnohSQ5Qp8iOwkyaNE8ZT95jgfYwW8+dqFEcTnSwwDKTh5Q6Rd0 DENEERP+hAslYuI96LrxztpAOd4XBkMCDesNCPk0yPbcxyz+GIzZxGCUfp68mQC/3xf2 FjKhuaOBKhCR0/hgJKBr2il6b78yF9hnYk3QHXDmtFby8tQWLcXlGVPkDHaRTGtRmXGp IeDHVecm0g5hphRHRROKx3CQU4BwQkzM5ZDorDu4zwv/u7DExDfK8NJ0Qcfoe/StzOWL Wqtg== X-Forwarded-Encrypted: i=1; AJvYcCU2NPRThe+dLqErZOCBx54/vU3Bi4CRdHOt2gFv/RecCcHgwTJYjybEForWwk8Y4X9CsyFj/St3/a1vIBs=@vger.kernel.org X-Gm-Message-State: AOJu0YwTekEaynXefFbXLVvFuOqOKVRRoTKXkE1VP5cL7KK7TRxaV5I6 gTNx1eeiBEB5AXixCt5EjuJ1s3vzG7vDpkdIkVDmefIDICH2ubaqhPu4MJV3awJHv1NwsQga9Vo IaTyFvQ== X-Google-Smtp-Source: AGHT+IHv8VUdThEMuYCTo4CRTZK/X2P2LNU9z0jf1LB7AEYk0QUXaJ8qfyEqkCSAnavX436lQTAj32kbRlw= X-Received: from plhz1.prod.google.com ([2002:a17:902:d9c1:b0:295:fdf4:5ad4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:cecc:b0:297:d4c4:4d99 with SMTP id d9443c01a7336-29df579ea1dmr8987315ad.6.1764981796344; Fri, 05 Dec 2025 16:43:16 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:03 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-2-seanjc@google.com> Subject: [PATCH 1/9] KVM: x86: Drop ASSERT()s on APIC/vCPU being non-NULL From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove ASSERT()s on vCPU and APIC structures being non-NULL in the local APIC code as the DEBUG=3D1 path of ASSERT() ends with BUG(), i.e. isn't meaningfully better for debugging than a NULL pointer dereference. For all intents and purposes, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 1597dd0b0cc6..558adcb67171 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1048,7 +1048,6 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struc= t kvm_lapic *source, struct kvm_lapic *target =3D vcpu->arch.apic; u32 mda =3D kvm_apic_mda(vcpu, dest, source, target); =20 - ASSERT(target); switch (shorthand) { case APIC_DEST_NOSHORT: if (dest_mode =3D=3D APIC_DEST_PHYSICAL) @@ -1607,8 +1606,6 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic) ktime_t remaining, now; s64 ns; =20 - ASSERT(apic !=3D NULL); - /* if initial count is 0, current count should also be 0 */ if (kvm_lapic_get_reg(apic, APIC_TMICT) =3D=3D 0 || apic->lapic_timer.period =3D=3D 0) @@ -3000,8 +2997,6 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic; =20 - ASSERT(vcpu !=3D NULL); - if (!irqchip_in_kernel(vcpu->kvm)) { static_branch_inc(&kvm_has_noapic_vcpu); return 0; --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 E3DF7316184 for ; Sat, 6 Dec 2025 00:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981800; cv=none; b=U8nR9lnV5bIq7V1dwUTuuxAmSvUrOeE1YUIXK9oq35JTi12OIjN1YOtWBWzRG8zoYDuu11cMkXLi15IBDcoM+KABjKBOw8t7D4VB9zu7AY4fHjpi7bKg3J5TpcMLJthS8ivnixHrazDuLc/0X+RoTwr9jpcNKIWzBYzabZXl/qM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981800; c=relaxed/simple; bh=2L2gL97o++f/gm2tCxBBuOlts49MrQmg/0G3RrKqFGI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=udJlv3z+mfuWTNLruQgNKCye9hcskzMBR7yAnllmwr5uA21R4RMoGMVBvgJZxxpn1k68No4WYLUUkn0KJ9EcD6wVtZe90DdgxyMVgceX7/MpQAc+nWge90057eNFGOCTwg8Sl1d256BzKgd+qiyIKQ2dDxARasSvUekDD+jynNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fBO+lDfN; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fBO+lDfN" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7d481452732so4351264b3a.1 for ; Fri, 05 Dec 2025 16:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981798; x=1765586598; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=upYs1KMuqdfjrUFjVx53Z/p9uat0/PpyZSW2MXnW3Lo=; b=fBO+lDfN2BvakO6w0WfhPc/5Y7uUdAYJLm+IUY5AYMew0ggGYaSpzTcadRkqbTV0UX U1/S5NYRF0iz+G2Ou/mGF7u92a3XtQrcv/8ANbZV+aL1pD9EQikIsn/49Oh2XIDUCCsB rgX891MsmGpaqqKk4eiMHXWE0dKFvmEGpgZ1tmdBOP48d7Q912O+94m2pKcCkIjX4vd2 jjoqAMl5oQWthoIKQp8VGtvywQUz2wywjh0cuUP+mT42dzKgOZ/dXDLJa5+xjnR5KPz/ MFKxqBhThPVZgGC0oqO3CsR/kmCdyht0n6tVFXwltbX53Cef6Amdys4uJK3I9nqoHUg4 GlQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981798; x=1765586598; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=upYs1KMuqdfjrUFjVx53Z/p9uat0/PpyZSW2MXnW3Lo=; b=OYGNH77/mWu3p2Y7OvtMgHWCMItFj0Y5zmDBBHS3IjZufPIPUQU7wzm3CQmjInOoTu 3JDngeIHeUJNkGix5ReWGMpXjbURUvUAKnm3SwOO55IvL/5pu35vjWFCBmXE5itdFrnt nKhJieGXol9PMoPvFptcafiN1fkB1DMa0hSaFB9SbrN7gp8BzlEs82zRWJboMLl3WbIa 4vsFTZcZA3guPz8wpbf8TCglfK/ipLRG5wMEpkBU1MEL02oEIrk33FoDwDhjv1YQR554 c4tQ8tNDPOdTzhZOX7EQOmvnchISlPjb/iQZfyhSkp7i+5NMvxDZAMCVl3QvEjhtEt8I 4xYA== X-Forwarded-Encrypted: i=1; AJvYcCWkA6rDQ16+6Z4YGaokBjmZAMIG87X+Azow0THd0RSz+n1VuTfyZaAWlFkXMFcf21hB5TTM8BZkWZb48P8=@vger.kernel.org X-Gm-Message-State: AOJu0YzAV552pmJAvtSmDqgL+pu9k1MGgNyHN4wf+nguyZ3Tf+dWG8Gv r0umcCZP3K+3oaSJrXasnRxk1iQAhSGq7WcRH25P5kCxj0DAuvIjPUGHDMYRbNJT4BU61dtQdBf 9S3AZAQ== X-Google-Smtp-Source: AGHT+IHgSKLoznbT+PBn/5JXieJ/Q/CNe9rxTSrYRb/BtQdSAiY0k616rOq6tNZj6AT6841f3cLU7sFkWdw= X-Received: from pglx8.prod.google.com ([2002:a63:1708:0:b0:bd9:a349:94b2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:12c3:b0:35d:d477:a7ff with SMTP id adf61e73a8af0-36617e834f4mr1014907637.21.1764981798188; Fri, 05 Dec 2025 16:43:18 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:04 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-3-seanjc@google.com> Subject: [PATCH 2/9] KVM: x86: Drop guest/user-triggerable asserts on IRR/ISR vectors From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the ASSERT()s in apic_find_highest_i{r,s}r() that exist to detect illegal vectors (0-15 are reserved and never recognized by the local APIC), as the asserts, if they were ever to be enabled by #defining DEBUG, can be trivially triggered from both the guest and from userspace, and ultimately because the ASSERT()s are useless. In large part due to lack of emulation for the Error Status Register and its "delayed" read semantics, KVM doesn't filter out bad IRQs (IPIs or otherwise) when IRQs are sent or received. Instead, probably by dumb luck on KVM's part, KVM effectively ignores pending illegal vectors in the IRR due vector 0-15 having priority '0', and thus never being higher priority than PPR. As for ISR, a misbehaving userspace could stuff illegal vector bits, but again the end result is mostly benign (aside from userspace likely breaking the VM), as processing illegal vectors "works" and doesn't cause functional problems. Regardless of the safety and correctness of KVM's illegal vector handling, one thing is for certain: the ASSERT()s have done absolutely nothing to help detect such issues since they were added 18+ years ago by commit 97222cc83163 ("KVM: Emulate local APIC in kernel"). For all intents and purposes, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 558adcb67171..785c0352fa0e 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -666,8 +666,6 @@ static inline int apic_search_irr(struct kvm_lapic *api= c) =20 static inline int apic_find_highest_irr(struct kvm_lapic *apic) { - int result; - /* * Note that irr_pending is just a hint. It will be always * true with virtual interrupt delivery enabled. @@ -675,10 +673,7 @@ static inline int apic_find_highest_irr(struct kvm_lap= ic *apic) if (!apic->irr_pending) return -1; =20 - result =3D apic_search_irr(apic); - ASSERT(result =3D=3D -1 || result >=3D 16); - - return result; + return apic_search_irr(apic); } =20 static inline void apic_clear_irr(int vec, struct kvm_lapic *apic) @@ -731,8 +726,6 @@ static inline void apic_set_isr(int vec, struct kvm_lap= ic *apic) =20 static inline int apic_find_highest_isr(struct kvm_lapic *apic) { - int result; - /* * Note that isr_count is always 1, and highest_isr_cache * is always -1, with APIC virtualization enabled. @@ -742,10 +735,7 @@ static inline int apic_find_highest_isr(struct kvm_lap= ic *apic) if (likely(apic->highest_isr_cache !=3D -1)) return apic->highest_isr_cache; =20 - result =3D apic_find_highest_vector(apic->regs + APIC_ISR); - ASSERT(result =3D=3D -1 || result >=3D 16); - - return result; + return apic_find_highest_vector(apic->regs + APIC_ISR); } =20 static inline void apic_clear_isr(int vec, struct kvm_lapic *apic) --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 3425E3168EC for ; Sat, 6 Dec 2025 00:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981802; cv=none; b=HnS12V0DcY5zmY37oALLZ2PTko+q4c0oVaDcEnY3klO3jjkQ4Iw6ZYKNOlRcwzeYSE8PueDnUipa2VCztI78Liri2irvSuQXnFh5NlwPMC6KUiCFixL2VBFcZAtIyN8GUSZNerYAB4j9usb/37RB3xJ7G1r3bVJaUenbFCpB6eA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981802; c=relaxed/simple; bh=Hy74djawqMvSP0jMJOk9BCT2RyW0VOR90fXdslhQje0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XH+O1478GfjFFkLQjCRa4jDUNE4IIPxE4J+dFEhg5i5uFXOYMszXR/aCZTIJzAPraWfA2WPaOS4v3L9lufKpDco1iDg8gcvjqKNFVw7wfwUQJF0PKunnkMhM9Es24Nm5I0xgJv5Y2DLL/xlR6pxkXzRaP9NHbnSUILarJ743U/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZEQSUU8p; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZEQSUU8p" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-34378c914b4so4948079a91.1 for ; Fri, 05 Dec 2025 16:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981800; x=1765586600; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=173K4atzjTV2FLTaLFj0n34rAomBtKCng7OEVaMUqaE=; b=ZEQSUU8pPvE0bONpoXFp4e7swPzQFL1px4v7+bBiSqkY9ZRwDm7UPAr3cuO9nLUtgt 78RR68LA8TU1BjSzryAUfHC83ojmNjgyywt6rtUnfgijqa6x6e/3rE35x1WbvTYMd90a C496YEWBlmTeR2mM2d1CE6cqzYtJvwDBcgs4ziCJ76ro00j+iYlokFnYTPY/h7bo6d88 3JfRmFPaTn7zVC+KEFqyscwWwN7TU439furgNb/QujagsJuN0+04vzigOUADjuAqP1JI uxJBeuheA/AQ9AxwU9b3YPWLyUspW4I6mJ0rnpKPv1jX6AidBfvFSe4hZymppUmycHf9 kYoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981800; x=1765586600; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=173K4atzjTV2FLTaLFj0n34rAomBtKCng7OEVaMUqaE=; b=AdVpqBoC9gHEt4zVGN1BLKz2Tjgl+XyHJtiZQXyeEEzwRZM6gqq+vs/fKMgi/+kxL/ wkepRrPWRBp94A9p5WUk0kF62mpKn+wSVmCrKM8E8TmpQ1Fc4OI3mzxgSj3pu33EEMCS 9ogYZ3QelGNYK9+y31IACVQcgmsNA4DhfUlvBp9IhSJFkYSXn+qJ8mXKugQaGUaEXsbA 3pUyzX0TmL220iYyvUkkp3KHodecFnU/RF4LkUYqNFkS+Qia2ykDoZ5/Ek1S4a2nuDhu Y8gskYCiordgcjaw6ef9/ug0Kc8TNShXrCDKVC/hXMQkuphoF7OehUJ1Ze5eq6nx4+Wm 4iXA== X-Forwarded-Encrypted: i=1; AJvYcCUIlofpf55UfjoO9Me8LEF7EFw8JQv5mS5nze4jyqpq5PImpAnj1n32L0+jhBEam9JUfzGEIl3ZiEOi+qU=@vger.kernel.org X-Gm-Message-State: AOJu0YwLPLGW+jGyOFJ3G8jf76E7Fz/g90tFeMy2XI3xTSFjyn8sUF9w ENlAl/p46RxsOg+IHPVW8xtb+tnaYvmWL2gEj03VjtLjYu42EaCqrt0XtXXn7EpyGeYHDTMH49j Y0ydX1Q== X-Google-Smtp-Source: AGHT+IGTVnpxzGirvoM3sWOHnaYFOdYvPr17LMZTMJrq9eXAIpbGbRw9kPXACGvzABd9IaSIWNihB3yXpFc= X-Received: from pjbhl15.prod.google.com ([2002:a17:90b:134f:b0:340:9a37:91a4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:184e:b0:340:d511:e167 with SMTP id 98e67ed59e1d1-349a23af6bemr710202a91.0.1764981800353; Fri, 05 Dec 2025 16:43:20 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:05 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-4-seanjc@google.com> Subject: [PATCH 3/9] KVM: x86: Drop ASSERT() on I/O APIC EOIs being only for LEVEL_to WARN_ON_ONCE From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove kvm_ioapic_update_eoi_one()'s ASSERT() that the vector's entry is configured to be level-triggered, as KVM intercepts and forward EOIs to the I/O APIC even for edge-triggered IRQs (see kvm_ioapic_scan_entry()), and nothing guarantees the local APIC's TMR register is synchronized with the I/O APIC redirection table, i.e. the @trigger_mode check just out of sight doesn't provide any meaningful protection. Given that roughly half of the historic ASSERT()s are/were guest- and/or user-triggerable, it's safe to assume no one has run meaningful workloads with DEBUG=3D1, i.e. that the ASSERT() has been dead code since it was added 18+ years ago. Opportunistically drop the unnecessary forward declaration of kvm_ioapic_update_eoi_one(). For all intents and purposes, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/ioapic.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 2c2783296aed..e7315b9311d3 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -37,11 +37,6 @@ static int ioapic_service(struct kvm_ioapic *vioapic, int irq, bool line_status); =20 -static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *vcpu, - struct kvm_ioapic *ioapic, - int trigger_mode, - int pin); - static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic) { unsigned long result =3D 0; @@ -564,7 +559,6 @@ static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *= vcpu, kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) return; =20 - ASSERT(ent->fields.trig_mode =3D=3D IOAPIC_LEVEL_TRIG); ent->fields.remote_irr =3D 0; if (!ent->fields.mask && (ioapic->irr & (1 << pin))) { ++ioapic->irq_eoi[pin]; --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 3292E3168E5 for ; Sat, 6 Dec 2025 00:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981805; cv=none; b=E6T3ZnyQRyZ803Cmr0Y0HP9G8AVHUPVqQkLoM/Vbjdu1nwm+lkZQxq2KvyTRmPTGG0UeGjL+DgMEM3vG3O0pySu11jjA5Hm9pRPLGYcXryzB7F0ULQDNVQp+RTWiwTDrjmSpXgH99byo0fXyMoHEwXLG0YrkqCd0GUOFY4IKkIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981805; c=relaxed/simple; bh=r2ovlZRhwODpc4bFG8XgEXKmSauokJzle7yBrk7uvqM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PHuiW/gqy6eFq0tO4X/j0NqwmpM+nYNzeQ/F5XjzJzmpwNDeiPvPbXColKRUO1Nw/PKtYMQOln/imHeuMygdeWpMax/CnzvhGm/GVsFOUy/sN0tq4mN3rw8IU05h9zFmUD6fbUxDc7Df7CfnWjkDWwnmVDWgnBUDve2CJqgBUJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xxKwT0pT; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xxKwT0pT" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3436e9e3569so4609662a91.2 for ; Fri, 05 Dec 2025 16:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981803; x=1765586603; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=u/pAhAueiQpgBzrKR/h8os6IRtJ3jF7T0UFHgX/hns0=; b=xxKwT0pT14Wch/xbwPge7GjVyL2/ErV/Lxzn0XHvjPZB04qmK3XRRgfiI/6kjUnZNE VqeIoPNxH/jkG4SJ7eQO5iPla4aGYUtsJ9Lx395tLzCyizMeZoOpem7VDylaVKYrAe9a uwyOQ2NGcwcGhaRKbH98QOlRorZLei7RTsJpREpKxIKDK/v1akt4d6fwS/7peH4JG+ik q22lvYkDM0EjlEu7lEFBabjouy11lDREqxEDGoSmVWdfEDDb9xAJG4Dc1CV0in+wvz+2 KadTfoUXtPp7F+Mp38AoG7YGTS+u1H5y8/IWOjFdKRM27hYLNY9mf/4fV564s65D7dh9 Gz4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981803; x=1765586603; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u/pAhAueiQpgBzrKR/h8os6IRtJ3jF7T0UFHgX/hns0=; b=L8kIbudsO+kUSlk79sJBz4DJg8IXoUNHXp9ScQYP7FKgDTJAEVpvPwoeWJaOJ80JVg Eq9cYEQ3PESPg9QkEVlojG0jaF/PADErby7edWkaZ3HajWi9sdVwCYn6ewWc35bezYeT K7xb9Wt1SetLfa7svZvf8Uf2cJsZrMGARUbs69j9NS7gDk3JmWwGl9HVAaHAgr590XNo t24dbZOdmLsQMnoMps5g+BsJpg+MaWGI0iDcdwr9/jqnOkCm+Nczsuf1rMUIsX1a1dZj M4JqnM9TXmiZG6LEVayXv33fUM4+w7e45+4/3klv9NvBlM6lsrLPdxx2gXtOqaGU5aQz Rgnw== X-Forwarded-Encrypted: i=1; AJvYcCVxwI65C4CYpwycYInXPtenp5IIul2943mVlA1/63SNiUr7jqoGNRDEjmB/2r3Occa+EkMuUb4tfKOUldo=@vger.kernel.org X-Gm-Message-State: AOJu0YzPDcn427TTShOgLg1SpmNoWnftoaVxeskWt3+v9b2XmgEBCEnO u7xVGqckpeYwd3cThRiwLaio4iK28/NF0iLIemdlPl5sml3inFfHrrSdlIKf8QFsOWxYDSyuTb4 U257/MQ== X-Google-Smtp-Source: AGHT+IHCE7UebBiwXFxTpupxVzVDlk/3MrknX4il2CCrZdx9H59F59NZCM1+BgnfZN/7hx58J5GaTzyvpqI= X-Received: from pjp3.prod.google.com ([2002:a17:90b:55c3:b0:343:af64:f654]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1e53:b0:330:6d5e:f17b with SMTP id 98e67ed59e1d1-349a25bd8ebmr669682a91.21.1764981803494; Fri, 05 Dec 2025 16:43:23 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:06 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-5-seanjc@google.com> Subject: [PATCH 4/9] KVM: x86: Drop guest-triggerable ASSERT()s on I/O APIC access alignment From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the asserts on the guest-controlled address being 16-byte aligned when emulating I/O APIC accesses, as the ASSERT()s are guest-triggerable and ultimately pointless since KVM requires exact register matches, i.e. will ultimately ignore unaligned accesses anyways. Drop the ASSERT() definition itself now that all users are gone. For all intents and purposes, no functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/ioapic.c | 4 ---- arch/x86/kvm/ioapic.h | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index e7315b9311d3..955c781ba623 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -618,8 +618,6 @@ static int ioapic_mmio_read(struct kvm_vcpu *vcpu, stru= ct kvm_io_device *this, if (!ioapic_in_range(ioapic, addr)) return -EOPNOTSUPP; =20 - ASSERT(!(addr & 0xf)); /* check alignment */ - addr &=3D 0xff; spin_lock(&ioapic->lock); switch (addr) { @@ -660,8 +658,6 @@ static int ioapic_mmio_write(struct kvm_vcpu *vcpu, str= uct kvm_io_device *this, if (!ioapic_in_range(ioapic, addr)) return -EOPNOTSUPP; =20 - ASSERT(!(addr & 0xf)); /* check alignment */ - switch (len) { case 8: case 4: diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index bf28dbc11ff6..913016acbbd5 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -104,19 +104,6 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm,= int irq, void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned p= in, bool mask); =20 -#ifdef DEBUG -#define ASSERT(x) \ -do { \ - if (!(x)) { \ - printk(KERN_EMERG "assertion failed %s: %d: %s\n", \ - __FILE__, __LINE__, #x); \ - BUG(); \ - } \ -} while (0) -#else -#define ASSERT(x) do { } while (0) -#endif - static inline int ioapic_in_kernel(struct kvm *kvm) { return irqchip_full(kvm); --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 BD40E30F53B for ; Sat, 6 Dec 2025 00:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981807; cv=none; b=sJCgV+401LiE0sz4Dsq/hVWi/BoA+VtzD0au9qjBPpAje06Fau9/l4qU8D6npCpRo7aiv8etD7vLrMOEDqQlk3bVMMKLtbTftJBXZtaFgomza6WJO7HqgHeQAPYlj4z9RJWDCU//VPtn+EHg61C0p/1GHn/MtovMEr/sfHPtlaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981807; c=relaxed/simple; bh=pbeH8LNWRQpzMlEyGGkl5S+63BtJtdh0+VAu1sigjKY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o6LwEEVV8s7LXoZxpIEWGgcSEM//qDVGDbRMs7+7cA8y61BZqCm55W6GwBiUMX1+wEpUiRdxx52+xP+NZv4vGGmCe3/P3qyjlPxGkWwWYAB8EbAqc+HhmZpefV3hrAIwbwrIcrP19hrzIpZYjXSU3OV/nFUlyn8/trp0j/yPe0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rZWn5fP9; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rZWn5fP9" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7b9c91b814cso6697810b3a.2 for ; Fri, 05 Dec 2025 16:43:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981805; x=1765586605; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=YksvQLfy9DrR8CZlxz8+Z/GImZx6Zf2V5Uv3+ubIzfc=; b=rZWn5fP9SV/PkLnb1sbdUUP7MBnwS9xWa2YKO1qrrnrtpQ9R5u2+hl+vfaqCz0IHL5 kwYRX5XY5qLoT6rcR33nd/VBzU5JtnHuRZnAq2pZM38HhCr/rr3WkAMOX0SPFcf6340Q lcCJJlTOXQnSsIFnqDCZPWVweSkIWfsWsKWFiWxWCU4q2XNeVN46WhpZN6CUMw2cm+5/ eJI4arhDi/07QjCkotMRebPe1wprogVHNgd6g10+ICFoNRdP8Tv9WMNY5bVIsQfz+Lak mPwp88jkxpkby7tg7TUaLlZhM0cRhJaTdcGAucYMEMiH/kDfrfPhXUHSrhdGsistCZrk 9Rbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981805; x=1765586605; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YksvQLfy9DrR8CZlxz8+Z/GImZx6Zf2V5Uv3+ubIzfc=; b=PleIEEPfnQIf8hRSsnunmPsM3TKwodWz9omDkNiBXH+oGbU7BbSKEYiJ4OHAYGpgjN nneC4D5BwQw/qCHvUUMZBjdiwfID3tNefAKyahFfDni8d1HjYyjuex/ZvwApz1+i0Azk M19ebNFAvhlOQn6wXePMEPX3G4uA3888CGTkc0OG98L8Lo85Jy94zyNLj6ozGnkigK2S ijIpw4e2i601s8RNqEaC7pHbS7QBQY19Lr2ittGlrRtfqzEbPZJLjn60WPvFVqlsVPUt u9TLS4e3B4DmuIYQeqxDRPLX4VabynsV6KG7ce+tIYTkQqN5jz97D2sJdBSv/MQHM76k s/9g== X-Forwarded-Encrypted: i=1; AJvYcCVDFLT/22ZILHatU0+eHZOxsMh0ADLaFkn0gnvs3tJeGYP6IKlGD81YIk6fSIXPH9GCN68ihpjPjn9AdcQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxru77wJ6srY2Xhz4pNzGD964hCBC6w/7L3+Yu4Uox/reWDBpxr NjZ7tHCiH816A/yVBY9OhA2Ffd78AUU/msN6cIDK7mxHDPQqboVCZT/Qp2HepzBdU5TuRISI28S xx9LnRA== X-Google-Smtp-Source: AGHT+IFGmCgdoD3o05gboaUqgsQyf8ofZu37EtjQefmfWM4sVLelG6+BNA+RyWO2uLV8uFYufmr7arrMW5I= X-Received: from pfbei18.prod.google.com ([2002:a05:6a00:80d2:b0:76b:f0d4:ac71]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:849:b0:7e8:450c:618b with SMTP id d2e1a72fcca58-7e8c6dabd9emr791597b3a.34.1764981805043; Fri, 05 Dec 2025 16:43:25 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:07 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-6-seanjc@google.com> Subject: [PATCH 5/9] KVM: x86: Drop MAX_NR_RESERVED_IOAPIC_PINS, use KVM_MAX_IRQ_ROUTES directly From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Directly use KVM_MAX_IRQ_ROUTES when checking the number of routes being defined by userspace when creating a split IRQCHIP. The restriction has nothing to do with the I/O APIC, e.g. most modern userspace usage is for routing MSIs. Breaking the unnecessary dependency on the I/O APIC will allow burying all of ioapic.h behind CONFIG_KVM_IOAPIC=3Dy. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/ioapic.h | 1 - arch/x86/kvm/x86.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index 913016acbbd5..ad238a6e63dc 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -10,7 +10,6 @@ struct kvm; struct kvm_vcpu; =20 #define IOAPIC_NUM_PINS KVM_IOAPIC_NUM_PINS -#define MAX_NR_RESERVED_IOAPIC_PINS KVM_MAX_IRQ_ROUTES #define IOAPIC_VERSION_ID 0x11 /* IOAPIC version */ #define IOAPIC_EDGE_TRIG 0 #define IOAPIC_LEVEL_TRIG 1 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0c6d899d53dd..f582dac9ea0c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6717,7 +6717,7 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, case KVM_CAP_SPLIT_IRQCHIP: { mutex_lock(&kvm->lock); r =3D -EINVAL; - if (cap->args[0] > MAX_NR_RESERVED_IOAPIC_PINS) + if (cap->args[0] > KVM_MAX_IRQ_ROUTES) goto split_irqchip_unlock; r =3D -EEXIST; if (irqchip_in_kernel(kvm)) --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 B11F43191CC for ; Sat, 6 Dec 2025 00:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981809; cv=none; b=ERE8Zr1gcc+Tx+rKC5/CSnwExJrtG5ZBTjBs2kwZojQAGBlV94WGE1mj8lYGx8JKdMMe2CI//uRUqSAsyebX9kmf1cpEnhLmDUAzUd9w5TpUrp/2uNfn1JqexZsrlsU+94Jm81mbiO495soZUUK5CLu2CD0BXmckq4R0M/vhd40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981809; c=relaxed/simple; bh=7p3g1ZBu6FRv8reQiyKaecx8NldkmeS5zcA0Xq5dM4c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rHLEiSiB+HgL1/sQVwR/x+k3VLPDBdVbgv0vJe+FCE/aUux+G0/FK5XH5rnNOsyLVQwBWnUXe94Zygdk1UGRNqpiPhyhBVYSALr9u2Dxux8tQFkNW05si+/JlxOuSxFDDLqqkPMTfhIMSwA3RKoT9kukGiEBltuot+SWBi7jul8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=0Wecf8hX; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="0Wecf8hX" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3437f0760daso5076882a91.1 for ; Fri, 05 Dec 2025 16:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981807; x=1765586607; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=NmqBiS6+SwZn9pTwZnUkN7lJ7KmnizD8AtO5bpATROo=; b=0Wecf8hX6IHV2t0od8eLoOuHaC2EZTJDmvnE1uQvflCpfCbB9MskPem/XUyBc5kRmu H26SMWSjas6FGiHHpi82u2V+U8kCiuNLZ1ypI3b1AY5PHecpY8mm5ee0CBqdyZz4AX0c HmRH6fCnlrabHnKl1L7KMpDaONdzEYheFxAanpxhGh634JDb1sCo+UFwDdE1He+vfY8k UJGlZKJKKvuDkI5U/MgWQ4aoBP0LdtZl4pq1mEGx7Mn4F53F/zlHDnhNFsRjzLovYW5L RhZgFpXgBcnWHy6SRs+aVZRWBlyw12TBLdtjGIXS8zQKXYpcZZwulTgdh8eDlWH0ICxt yvOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981807; x=1765586607; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NmqBiS6+SwZn9pTwZnUkN7lJ7KmnizD8AtO5bpATROo=; b=URRuTkxZMQL0T6VM+7DgsncCJxpFcKLVZGQe+7TQ/tvqyViW0VkqvFXhOn9DMTa29n s/bA31TqAtzdWUb01EzIlfr8HoX+vc79E4H8JJTwUjcUJuzAdRv5cauQrKMLAOrmiYN3 +n/CbEedtAXWv8apmjy94FCtWEA6IqtDFO98zBJL3+n9D1RItsaekWkha7c9IT+0higQ bQdRvBARkyhP1TTiF/vfJKkfYZtCmB4srWGaqtABDhcfeDQEm7B19fk7PhzD1ilMp1aj IVRIVH6A1SEIEWQRhtbE4znwWVI4Az4SMBT3DbZlr7KaACrrPoDX0l9ZJokNHXRlt+n2 07sw== X-Forwarded-Encrypted: i=1; AJvYcCWRO+vICL/6Ah6aAX8cxlfWppU9etiUxMuMSba1etsJImEqqnly+Jkyjgc40fn1S+tOqXQDZo6UPMrqDwk=@vger.kernel.org X-Gm-Message-State: AOJu0YwFxUP47N5y6SG8RYMXFBMVp1UAC++4W5/4oy4ENhjbivKNQP0/ dKBQd3+cBhqFd0xSjlSgZRRXBxA4NnEV4yR87eTywvIpe3B6hxgo0QReKNZ8t9kGqLelcn+dKSC uYaFqug== X-Google-Smtp-Source: AGHT+IGY1NBM2XOWhkiUixcmdJOoH12DnU1T1AFPCYObwsdq9fJeRfBiMmXZxfkhELZV1wZDo8kMuXCtULc= X-Received: from pjrx5.prod.google.com ([2002:a17:90a:bc85:b0:33b:ca21:e3e7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1a8b:b0:343:f509:aa4a with SMTP id 98e67ed59e1d1-349a260a9d0mr673218a91.36.1764981806998; Fri, 05 Dec 2025 16:43:26 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:08 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-7-seanjc@google.com> Subject: [PATCH 6/9] KVM: x86: Add a wrapper to handle common case of IRQ delivery without dest_map From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Turn kvm_irq_delivery_to_apic() into a wrapper that passes NULL for the @dest_map param, as only the ugly I/O APIC RTC hackery needs to know which vCPUs received the IRQ. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/hyperv.c | 2 +- arch/x86/kvm/ioapic.c | 6 +++--- arch/x86/kvm/irq.c | 4 ++-- arch/x86/kvm/lapic.c | 23 ++++++++++++++++------- arch/x86/kvm/lapic.h | 16 ++++++++++++---- arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/xen.c | 2 +- 7 files changed, 36 insertions(+), 19 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index de92292eb1f5..49bf744ca8e3 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -492,7 +492,7 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *syni= c, u32 sint) irq.vector =3D vector; irq.level =3D 1; =20 - ret =3D kvm_irq_delivery_to_apic(vcpu->kvm, vcpu->arch.apic, &irq, NULL); + ret =3D kvm_irq_delivery_to_apic(vcpu->kvm, vcpu->arch.apic, &irq); trace_kvm_hv_synic_set_irq(vcpu->vcpu_id, sint, irq.vector, ret); return ret; } diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 955c781ba623..4b49f9728362 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -485,11 +485,11 @@ static int ioapic_service(struct kvm_ioapic *ioapic, = int irq, bool line_status) * if rtc_irq_check_coalesced returns false). */ BUG_ON(ioapic->rtc_status.pending_eoi !=3D 0); - ret =3D kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, - &ioapic->rtc_status.dest_map); + ret =3D __kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, + &ioapic->rtc_status.dest_map); ioapic->rtc_status.pending_eoi =3D (ret < 0 ? 0 : ret); } else - ret =3D kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL); + ret =3D kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe); =20 if (ret && irqe.trig_mode =3D=3D IOAPIC_LEVEL_TRIG) entry->fields.remote_irr =3D 1; diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index 7cc8950005b6..a52115441c07 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c @@ -235,7 +235,7 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, =20 kvm_msi_to_lapic_irq(kvm, e, &irq); =20 - return kvm_irq_delivery_to_apic(kvm, NULL, &irq, NULL); + return kvm_irq_delivery_to_apic(kvm, NULL, &irq); } =20 int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e, @@ -258,7 +258,7 @@ int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_rou= ting_entry *e, =20 kvm_msi_to_lapic_irq(kvm, e, &irq); =20 - if (kvm_irq_delivery_to_apic_fast(kvm, NULL, &irq, &r, NULL)) + if (kvm_irq_delivery_to_apic_fast(kvm, NULL, &irq, &r)) return r; break; =20 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 785c0352fa0e..769facb27d3d 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1175,8 +1175,9 @@ static inline bool kvm_apic_map_get_dest_lapic(struct= kvm *kvm, return true; } =20 -bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, int *r, struct dest_map *dest_map) +static bool __kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_la= pic *src, + struct kvm_lapic_irq *irq, int *r, + struct dest_map *dest_map) { struct kvm_apic_map *map; unsigned long bitmap; @@ -1212,6 +1213,13 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, = struct kvm_lapic *src, return ret; } =20 + +bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, + struct kvm_lapic_irq *irq, int *r) +{ + return __kvm_irq_delivery_to_apic_fast(kvm, src, irq, r, NULL); +} + /* * This routine tries to handle interrupts in posted mode, here is how * it deals with different cases: @@ -1283,15 +1291,16 @@ bool kvm_intr_is_single_vcpu(struct kvm *kvm, struc= t kvm_lapic_irq *irq, } EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_intr_is_single_vcpu); =20 -int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, struct dest_map *dest_map) +int __kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, + struct kvm_lapic_irq *irq, + struct dest_map *dest_map) { int r =3D -1; struct kvm_vcpu *vcpu, *lowest =3D NULL; unsigned long i, dest_vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)]; unsigned int dest_vcpus =3D 0; =20 - if (kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, dest_map)) + if (__kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, dest_map)) return r; =20 if (irq->dest_mode =3D=3D APIC_DEST_PHYSICAL && @@ -1587,7 +1596,7 @@ void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 ic= r_low, u32 icr_high) =20 trace_kvm_apic_ipi(icr_low, irq.dest_id); =20 - kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq, NULL); + kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq); } EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_apic_send_ipi); =20 @@ -2556,7 +2565,7 @@ static int __kvm_x2apic_icr_write(struct kvm_lapic *a= pic, u64 data, bool fast) kvm_icr_to_lapic_irq(apic, (u32)data, (u32)(data >> 32), &irq); =20 if (!kvm_irq_delivery_to_apic_fast(apic->vcpu->kvm, apic, &irq, - &ignored, NULL)) + &ignored)) return -EWOULDBLOCK; =20 trace_kvm_apic_ipi((u32)data, irq.dest_id); diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 282b9b7da98c..901c05a5ac60 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -117,10 +117,18 @@ int kvm_alloc_apic_access_page(struct kvm *kvm); void kvm_inhibit_apic_access_page(struct kvm_vcpu *vcpu); =20 bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, int *r, struct dest_map *dest_map); -int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, - struct dest_map *dest_map); + struct kvm_lapic_irq *irq, int *r); +int __kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, + struct kvm_lapic_irq *irq, + struct dest_map *dest_map); + +static inline int kvm_irq_delivery_to_apic(struct kvm *kvm, + struct kvm_lapic *src, + struct kvm_lapic_irq *irq) +{ + return __kvm_irq_delivery_to_apic(kvm, src, irq, NULL); +} + void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 icr_low, u32 icr_high); =20 int kvm_apic_set_base(struct kvm_vcpu *vcpu, u64 value, bool host_initiate= d); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f582dac9ea0c..bf8059179edb 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10245,7 +10245,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, int= apicid) .dest_id =3D apicid, }; =20 - kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL); + kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq); } =20 bool kvm_apicv_activated(struct kvm *kvm) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index d6b2a665b499..28eeb1b2a16c 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -626,7 +626,7 @@ void kvm_xen_inject_vcpu_vector(struct kvm_vcpu *v) irq.delivery_mode =3D APIC_DM_FIXED; irq.level =3D 1; =20 - kvm_irq_delivery_to_apic(v->kvm, NULL, &irq, NULL); + kvm_irq_delivery_to_apic(v->kvm, NULL, &irq); } =20 /* --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 EA54531961B for ; Sat, 6 Dec 2025 00:43:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981813; cv=none; b=HSUIVYWwehJzYPloM1Z6p5M4WmMAXhzvulUQdhSpwLuUAj5G95DanV70xgahrJW5KK50cwlb3sfG7LkKHIE4Dx31Hai9fykV5BEp5CWXxR7Z1tAuakCbCFUDXcZxFICWUUjTnrhgSqoPHn7QpNHXm3Z5UVuIGOAhglMPJxoOiGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981813; c=relaxed/simple; bh=0GMlepk5J3ka1U9kVqIcu6b3l8f5stdI7eG+wGPYhvo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Lu9u00W6Caqe6NE7sKRNeSZA2kmtrglmOQnsQga9iyhUFjyrEufZ//cSdAEVUrGQIx9pY7oHtEu4oWnm6D31HBT5GCPVflDUnsIUaaoM9QOx0VMmoFHacicG7wFCcrBe1OCT9ZHL0z8dvZwErN2oU57qQ2hNd5JAfr/E+q8vOys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Xomvszyy; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Xomvszyy" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7bad1cef9bcso5155332b3a.1 for ; Fri, 05 Dec 2025 16:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981809; x=1765586609; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=FSL4bypVJAYNju9c3VWi1yEjMMlrNBcwT+8KbaMOsjM=; b=XomvszyymPWDOunGSmXaUy1gLwXdAk8OrmBkdN9qhM9k/IdhKAowdFW4l85WUFvf3n E/BV6zqNh3VTXoCKNhKYlZs4+LRjmp/Vv/aYrSLtzmEftIHHTtQce2FMr7aNGwWRYypp AJz5douDazgEdnXnThV+nLVrEAtuAYStCdB6QZtNN0V4m8GtWW7ewQkJZ2FgpGneED0O f6a50qhnWLpPjcBjKm7gcpzpjY36PXTfsIiVQQlNB+ZCER8HWKZdMrXQ+xdDmKC9GE7w ikjw4WUjtJIEMDwFjVkm45r500u4XWO/KIvLoPmzj3ggFIVxcxns2aPYePyFLsimCETg gAUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981809; x=1765586609; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FSL4bypVJAYNju9c3VWi1yEjMMlrNBcwT+8KbaMOsjM=; b=GgRlOo5fMZsYz3d9IwduMujRZFxZWflPQ6EwgSqrnN2TH+Q/EVcFmXAV5oAfit1+d6 YVDQ5WD2akeIqmFBd9TRUvFapwM/BJgRCiL5J/HnMOeHeaLhYbb4rLQd4Bn2Gz2P2qiC aWbCgNGjYBZYxCpwehFqVuV3BUXdN3nBJqKqolLzdQ2unWHmyFk0VcvqojTH2re21bu6 PCxRWjxqJfrvuowSPqlhh88jVAr0u8uAvULhy3w1H8KFnzsMQlmusRqxTm9+2nn4Lmlr 5xtnq9x+6PxX0e8e9TBMg3uZ1Nrwdck62uEb3dOyBX6SOw3VVWDi/1A9XKr7lnVXn02h 3bLQ== X-Forwarded-Encrypted: i=1; AJvYcCU+7OIrcarxkUG1X/KZy0tQ8wLM32/U5KbLp5nTzxK+f+/3/lFVSUd37ErzB6PQPbORY5xtef2aXOCnOTY=@vger.kernel.org X-Gm-Message-State: AOJu0Yzxbek7xOETUkwzIcIPMFdhEJL3fROQBKjd1C5PHRfwR4mt3c6z 5IRtJjeiz3yFEKjshURCBmCKbjzZK39r+zO2bK680/QWoWYsjmbutOo4SOFtrezix8BM1akIae2 e7inz4A== X-Google-Smtp-Source: AGHT+IGV66CYDTsYUINlpwHFrVLWFlpZRohRkTuK6c5ypaJuCWDBEbI1RF8SRREhYV4AYY97PwaqpI+KuIw= X-Received: from pfbna23.prod.google.com ([2002:a05:6a00:3e17:b0:793:b157:af51]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3e14:b0:7e8:4433:8fb3 with SMTP id d2e1a72fcca58-7e8c6c9d722mr904909b3a.59.1764981809149; Fri, 05 Dec 2025 16:43:29 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:09 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-8-seanjc@google.com> Subject: [PATCH 7/9] KVM: x86: Fold "struct dest_map" into "struct rtc_status" From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop "struct dest_map" and fold its members into its one and only user, "struct rtc_status". Tracking "pending" EOIs and associated vCPUs is very much a hack for legacy RTC behavior, and should never be needed for other IRQ delivery. In addition to making it more obvious why KVM tracks target vCPUs, this will allow burying the "struct rtc_status" definition behind CONFIG_KVM_IOAPIC=3Dy, which in turn will make it even harder for KVM to misuse the structure. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/ioapic.c | 29 ++++++++++++++--------------- arch/x86/kvm/ioapic.h | 10 +++------- arch/x86/kvm/lapic.c | 28 ++++++++++++++-------------- arch/x86/kvm/lapic.h | 6 +++--- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 4b49f9728362..9a99d01b111c 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -77,7 +77,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioap= ic *ioapic) static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) { ioapic->rtc_status.pending_eoi =3D 0; - bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_IDS); + bitmap_zero(ioapic->rtc_status.map, KVM_MAX_VCPU_IDS); } =20 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic); @@ -92,7 +92,7 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm= _vcpu *vcpu) { bool new_val, old_val; struct kvm_ioapic *ioapic =3D vcpu->kvm->arch.vioapic; - struct dest_map *dest_map =3D &ioapic->rtc_status.dest_map; + struct rtc_status *status =3D &ioapic->rtc_status; union kvm_ioapic_redirect_entry *e; =20 e =3D &ioapic->redirtbl[RTC_GSI]; @@ -102,17 +102,17 @@ static void __rtc_irq_eoi_tracking_restore_one(struct= kvm_vcpu *vcpu) return; =20 new_val =3D kvm_apic_pending_eoi(vcpu, e->fields.vector); - old_val =3D test_bit(vcpu->vcpu_id, dest_map->map); + old_val =3D test_bit(vcpu->vcpu_id, status->map); =20 if (new_val =3D=3D old_val) return; =20 if (new_val) { - __set_bit(vcpu->vcpu_id, dest_map->map); - dest_map->vectors[vcpu->vcpu_id] =3D e->fields.vector; + __set_bit(vcpu->vcpu_id, status->map); + status->vectors[vcpu->vcpu_id] =3D e->fields.vector; ioapic->rtc_status.pending_eoi++; } else { - __clear_bit(vcpu->vcpu_id, dest_map->map); + __clear_bit(vcpu->vcpu_id, status->map); ioapic->rtc_status.pending_eoi--; rtc_status_pending_eoi_check_valid(ioapic); } @@ -143,13 +143,12 @@ static void kvm_rtc_eoi_tracking_restore_all(struct k= vm_ioapic *ioapic) static void rtc_irq_eoi(struct kvm_ioapic *ioapic, struct kvm_vcpu *vcpu, int vector) { - struct dest_map *dest_map =3D &ioapic->rtc_status.dest_map; + struct rtc_status *status =3D &ioapic->rtc_status; =20 /* RTC special handling */ - if (test_bit(vcpu->vcpu_id, dest_map->map) && - (vector =3D=3D dest_map->vectors[vcpu->vcpu_id]) && - (test_and_clear_bit(vcpu->vcpu_id, - ioapic->rtc_status.dest_map.map))) { + if (test_bit(vcpu->vcpu_id, status->map) && + (vector =3D=3D status->vectors[vcpu->vcpu_id]) && + (test_and_clear_bit(vcpu->vcpu_id, status->map))) { --ioapic->rtc_status.pending_eoi; rtc_status_pending_eoi_check_valid(ioapic); } @@ -260,15 +259,15 @@ static void kvm_ioapic_inject_all(struct kvm_ioapic *= ioapic, unsigned long irr) void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, ulong *ioapic_handled_ve= ctors) { struct kvm_ioapic *ioapic =3D vcpu->kvm->arch.vioapic; - struct dest_map *dest_map =3D &ioapic->rtc_status.dest_map; + struct rtc_status *status =3D &ioapic->rtc_status; union kvm_ioapic_redirect_entry *e; int index; =20 spin_lock(&ioapic->lock); =20 /* Make sure we see any missing RTC EOI */ - if (test_bit(vcpu->vcpu_id, dest_map->map)) - __set_bit(dest_map->vectors[vcpu->vcpu_id], + if (test_bit(vcpu->vcpu_id, status->map)) + __set_bit(status->vectors[vcpu->vcpu_id], ioapic_handled_vectors); =20 for (index =3D 0; index < IOAPIC_NUM_PINS; index++) { @@ -486,7 +485,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, in= t irq, bool line_status) */ BUG_ON(ioapic->rtc_status.pending_eoi !=3D 0); ret =3D __kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, - &ioapic->rtc_status.dest_map); + &ioapic->rtc_status); ioapic->rtc_status.pending_eoi =3D (ret < 0 ? 0 : ret); } else ret =3D kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe); diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index ad238a6e63dc..868ed593a5c9 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -36,7 +36,9 @@ struct kvm_vcpu; =20 #define RTC_GSI 8 =20 -struct dest_map { +struct rtc_status { + int pending_eoi; + /* vcpu bitmap where IRQ has been sent */ DECLARE_BITMAP(map, KVM_MAX_VCPU_IDS); =20 @@ -47,12 +49,6 @@ struct dest_map { u8 vectors[KVM_MAX_VCPU_IDS]; }; =20 - -struct rtc_status { - int pending_eoi; - struct dest_map dest_map; -}; - union kvm_ioapic_redirect_entry { u64 bits; struct { diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 769facb27d3d..0a44765aba12 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -784,15 +784,15 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_lapic_find_highest= _irr); =20 static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, int vector, int level, int trig_mode, - struct dest_map *dest_map); + struct rtc_status *rtc_status); =20 int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, - struct dest_map *dest_map) + struct rtc_status *rtc_status) { struct kvm_lapic *apic =3D vcpu->arch.apic; =20 return __apic_accept_irq(apic, irq->delivery_mode, irq->vector, - irq->level, irq->trig_mode, dest_map); + irq->level, irq->trig_mode, rtc_status); } =20 static int __pv_send_ipi(unsigned long *ipi_bitmap, struct kvm_apic_map *m= ap, @@ -1177,7 +1177,7 @@ static inline bool kvm_apic_map_get_dest_lapic(struct= kvm *kvm, =20 static bool __kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_la= pic *src, struct kvm_lapic_irq *irq, int *r, - struct dest_map *dest_map) + struct rtc_status *rtc_status) { struct kvm_apic_map *map; unsigned long bitmap; @@ -1192,7 +1192,7 @@ static bool __kvm_irq_delivery_to_apic_fast(struct kv= m *kvm, struct kvm_lapic *s *r =3D 0; return true; } - *r =3D kvm_apic_set_irq(src->vcpu, irq, dest_map); + *r =3D kvm_apic_set_irq(src->vcpu, irq, rtc_status); return true; } =20 @@ -1205,7 +1205,7 @@ static bool __kvm_irq_delivery_to_apic_fast(struct kv= m *kvm, struct kvm_lapic *s for_each_set_bit(i, &bitmap, 16) { if (!dst[i]) continue; - *r +=3D kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map); + *r +=3D kvm_apic_set_irq(dst[i]->vcpu, irq, rtc_status); } } =20 @@ -1293,14 +1293,14 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_intr_is_single_v= cpu); =20 int __kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, struct kvm_lapic_irq *irq, - struct dest_map *dest_map) + struct rtc_status *rtc_status) { int r =3D -1; struct kvm_vcpu *vcpu, *lowest =3D NULL; unsigned long i, dest_vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)]; unsigned int dest_vcpus =3D 0; =20 - if (__kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, dest_map)) + if (__kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, rtc_status)) return r; =20 if (irq->dest_mode =3D=3D APIC_DEST_PHYSICAL && @@ -1322,7 +1322,7 @@ int __kvm_irq_delivery_to_apic(struct kvm *kvm, struc= t kvm_lapic *src, if (!kvm_lowest_prio_delivery(irq)) { if (r < 0) r =3D 0; - r +=3D kvm_apic_set_irq(vcpu, irq, dest_map); + r +=3D kvm_apic_set_irq(vcpu, irq, rtc_status); } else if (kvm_apic_sw_enabled(vcpu->arch.apic)) { if (!vector_hashing_enabled) { if (!lowest) @@ -1344,7 +1344,7 @@ int __kvm_irq_delivery_to_apic(struct kvm *kvm, struc= t kvm_lapic *src, } =20 if (lowest) - r =3D kvm_apic_set_irq(lowest, irq, dest_map); + r =3D kvm_apic_set_irq(lowest, irq, rtc_status); =20 return r; } @@ -1355,7 +1355,7 @@ int __kvm_irq_delivery_to_apic(struct kvm *kvm, struc= t kvm_lapic *src, */ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, int vector, int level, int trig_mode, - struct dest_map *dest_map) + struct rtc_status *rtc_status) { int result =3D 0; struct kvm_vcpu *vcpu =3D apic->vcpu; @@ -1376,9 +1376,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, = int delivery_mode, =20 result =3D 1; =20 - if (dest_map) { - __set_bit(vcpu->vcpu_id, dest_map->map); - dest_map->vectors[vcpu->vcpu_id] =3D vector; + if (rtc_status) { + __set_bit(vcpu->vcpu_id, rtc_status->map); + rtc_status->vectors[vcpu->vcpu_id] =3D vector; } =20 if (apic_test_vector(vector, apic->regs + APIC_TMR) !=3D !!trig_mode) { diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 901c05a5ac60..71c80fa020e0 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -88,7 +88,7 @@ struct kvm_lapic { int nr_lvt_entries; }; =20 -struct dest_map; +struct rtc_status; =20 int kvm_create_lapic(struct kvm_vcpu *vcpu); void kvm_free_lapic(struct kvm_vcpu *vcpu); @@ -110,7 +110,7 @@ bool __kvm_apic_update_irr(unsigned long *pir, void *re= gs, int *max_irr); bool kvm_apic_update_irr(struct kvm_vcpu *vcpu, unsigned long *pir, int *m= ax_irr); void kvm_apic_update_ppr(struct kvm_vcpu *vcpu); int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, - struct dest_map *dest_map); + struct rtc_status *rtc_status); int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type); void kvm_apic_update_apicv(struct kvm_vcpu *vcpu); int kvm_alloc_apic_access_page(struct kvm *kvm); @@ -120,7 +120,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, str= uct kvm_lapic *src, struct kvm_lapic_irq *irq, int *r); int __kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, struct kvm_lapic_irq *irq, - struct dest_map *dest_map); + struct rtc_status *rtc_status); =20 static inline int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 046CF30F552 for ; Sat, 6 Dec 2025 00:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981813; cv=none; b=GMXPjppWqEzESUD7EOxIpHoQS0mZgfWF5O79TnXXjiRDpKk57MpLK9fJI3+3/XAHE7WTqpCc0ujvfB70+nKxmGk4+NFnc0NE5THVlCL2vFebYFBB+BOI8ly8FtDWRCcrpkWSkUD+fzXci1C6x33cbpv5H2B+F3rTb2RPeUx90h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981813; c=relaxed/simple; bh=D8YNs0jhQxmKrlLqzsIgpVcygIjolyUDJAk5r4FS0BA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rr6o2EwzP5FdpQ3f4pQ42bChJa99a4DQgpm5+rLc+OKzIWbyWG2rlyPixjLlDYMYS8G8i/xzIa+Kr1LTH7pRev42Zng9fDOCbYXYk0GsisVd3QvxzqBVIcQA+BohDPDD45EuaYjs5KORNH5wcxMhDLR/8U3Pe3Gt2KFIWid4JVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lm00pY5J; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lm00pY5J" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3436d81a532so4732833a91.3 for ; Fri, 05 Dec 2025 16:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981811; x=1765586611; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=0M5Fh7g4g+vMHY3O01HjRrVVFkeqJ1Xqgz9TEiQY1Wo=; b=lm00pY5Jkajb5fv+9ENc7//wgow4/lOb6T9fX+cfkLOyDMY1XUe6yP+xGrzIGq++v9 Rd44ogZfdmP+fjcslt6A5m6zrVZNiYlWPGOxu77ov9ghPApSK8HbARcTgdQ868DnHmwu IQt2uElEXgSggdIi0UeUh3MThcKLcXClhktBmuH6Ou5WFXgu3+G8oxennMxQ10qG2ARY vtYSbFAKFiyxfXm5omxhdui8+vjoaSJMIXRH/gaNyRwPqc53uU64PL8NmXyUU9ewxKZp r+mkYOWz5Zp6zc2JtQ54qgOh5I5KLFVlCN8bLsu4ZM8+kfaPFcUHgRBjyfjGZbB7HOwO V48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981811; x=1765586611; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0M5Fh7g4g+vMHY3O01HjRrVVFkeqJ1Xqgz9TEiQY1Wo=; b=aQmsUteUEuFBzPq1U3a8T9op2AQfOVzFrn8ATNTe9gjho/IAJEvxBVV21VrhNM+FRG R2pifnZ1bCNx0iJ/Ueq6Te1VDbFlGGR1eifuY43gAKm7BUPP5CqjqIvO/3jO51r8TB4J LZI7npALUK+Z4soa9/CyXe6YFUa/SFQOrMlKYEZU2ALLAj3WznfG9Ta6gSE5/eEqWaji xAWq2o/S3Deqv7V/mj13Dch0qI9n5pY6EHhxwExT1/djJd++ij7Jv8Bp3xztfXWJwuez qplZKEF8F/aa0C3+uLEp5Wib3CvFqxWrFijhsGlyDnDW8KnsNYISpzmr7A3YW+JFeY8h j1ag== X-Forwarded-Encrypted: i=1; AJvYcCVtn0lgySfWUWw+BhoqtP2BEY+bhI8WKeqytIyDaw8iX4RlxK/suSLJUvfbtLDBRwSifiGaBMs2J2D49Tc=@vger.kernel.org X-Gm-Message-State: AOJu0YzaIcM4igMpwOhur3nil8EMsJiNeeL0KxyEGhChTbwurJ4UJHUZ llHjHLTe5ui5llG0fg8OxpgqZe6gtR4xACowbVaYQR+ggVPhvWcIbKqhJc+J2/72b917WFiRw4C czgTTTw== X-Google-Smtp-Source: AGHT+IGlL8/b1FRD3bhiv9p0K1W8yDjW0JkM8vQ36QdvszBI5wd93UySoZ1QCSk/ibL5UW+HM3nqArHB2qk= X-Received: from pjwt13.prod.google.com ([2002:a17:90a:d14d:b0:33b:52d6:e13e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c12:b0:340:ad5e:c3 with SMTP id 98e67ed59e1d1-349a24cc0eemr697918a91.1.1764981811179; Fri, 05 Dec 2025 16:43:31 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:10 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-9-seanjc@google.com> Subject: [PATCH 8/9] KVM: x86: Bury ioapic.h definitions behind CONFIG_KVM_IOAPIC From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that almost everything in ioapic.h is used only by code guarded by CONFIG_KVM_IOAPIC=3Dy, bury (almost) the entire thing behind the Kconfig. Signed-off-by: Sean Christopherson --- arch/x86/kvm/ioapic.h | 14 +++++++++----- arch/x86/kvm/lapic.c | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index 868ed593a5c9..3dadae093690 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -6,6 +6,8 @@ #include #include "irq.h" =20 +#ifdef CONFIG_KVM_IOAPIC + struct kvm; struct kvm_vcpu; =20 @@ -99,11 +101,6 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, = int irq, void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned p= in, bool mask); =20 -static inline int ioapic_in_kernel(struct kvm *kvm) -{ - return irqchip_full(kvm); -} - void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu); void kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, int vector, int trigger_mode); @@ -116,6 +113,13 @@ void kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic= _state *state); void kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, ulong *ioapic_handled_vectors); +#endif /* CONFIG_KVM_IOAPIC */ + +static inline int ioapic_in_kernel(struct kvm *kvm) +{ + return irqchip_full(kvm); +} + void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu, ulong *ioapic_handled_vectors); void kvm_scan_ioapic_irq(struct kvm_vcpu *vcpu, u32 dest_id, u16 dest_mode, diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 0a44765aba12..78c39341b2a5 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1376,10 +1376,12 @@ static int __apic_accept_irq(struct kvm_lapic *apic= , int delivery_mode, =20 result =3D 1; =20 +#ifdef CONFIG_KVM_IOAPIC if (rtc_status) { __set_bit(vcpu->vcpu_id, rtc_status->map); rtc_status->vectors[vcpu->vcpu_id] =3D vector; } +#endif =20 if (apic_test_vector(vector, apic->regs + APIC_TMR) !=3D !!trig_mode) { if (trig_mode) --=20 2.52.0.223.gf5cc29aaa4-goog From nobody Sun Feb 8 06:51:18 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 8EAE53115BC for ; Sat, 6 Dec 2025 00:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981815; cv=none; b=LLSckq/hsfYaELwsLDWfaep2D5PzfE/p+a+Rr/PCo7J+jMvjn0RcTiLrRZnbhYU1lnvxn0V0ugyBKctGU4sh64LYwwti+Dz782E1m5x0zPvvMhu7/7Eoc7I0pIQyUK2VC5TW0AiDiYV3U9455XPHY+G0M4EH5eoO750fteuYjw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764981815; c=relaxed/simple; bh=PweGGT8dcZgxuINZD4eC15xtjEWtlEQ43EHnvSh8rlk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lhz0KzV8Z9QdiMFQBzQu7gtIUj5ZcfBVcygDGldT8HcsoEJxkDHlA9kp+F0HZEZJlwd0LNoD+iHVlhsPbDbvYcym+1hjSxrl3MXK3lv2puPl0b+G4guiYOfzqpG6a2Q3n8TTz0T4QTZF7aYxcwJKG9nxg1iYFPEWPcxO/gJ/oLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qDPc6Aiq; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qDPc6Aiq" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-340c07119bfso5073946a91.2 for ; Fri, 05 Dec 2025 16:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764981813; x=1765586613; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=iwA/2R3/erTvUP5/JcSpQX87XH1JoU7paa3KDPV68VY=; b=qDPc6AiqBsKhp8XvxLYfKlnbI1FMzih3kqr2bgYOLFShA7nnnf0zKIYXhXLFAaBrKA DpjJA9gMHrcu2bjh+o66drac0w4h42QHYls++T+ADIoC3wPiLXRC1vDAB6vENVDTkt4/ 5eoHkttIOTwdWCUUzm8yF12O8ucA8+p+jkijaSnVCPAH4jnbzM8bBzQpgQ3Z7qdnvMto jc+Shmb3OEq72heedOO48YAGn1jTwJJPJ//JD8qHZstETb1rp9Fx26A4qaNpNIvpx1rb Rl7cGHYR7sDuqsmqugL6/gvYOwhDRMvGh3MFvyiGx2zdz58RBZkBwGJeySYkImr0HGaj 1iGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764981813; x=1765586613; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iwA/2R3/erTvUP5/JcSpQX87XH1JoU7paa3KDPV68VY=; b=mRsAo2bMC1w31WXzKRMgYg8Bd+LX3Y5nTBLM3ZsX3h44rJLvSzCczGrs1gP2ixAQAZ GWbpJiILTRtyhx0mIKJ5mxHeWfB0zFbEk9VHvi3O2ystuwtlslehzAJE6k3XKkw19RdS fKhyAw+NASIOhhDgcLCJyHdmcvRl2V9dLT6vJKbO6xsadYDtHLx4DFf53xGwvPbdpplZ +3Wmgr4nGhT8VB0VliYPa4m/mKLX9sDO5i0PVT20u7ozqLaDF1U+Qb+AHXn2EGhEbhWs zdW1SzGfycFLXM/w5UZ/VUCVfD0JUWsCKd7F2rS+R6weyn0sFBn6dAqAZk3uZaiUPh1P BCVQ== X-Forwarded-Encrypted: i=1; AJvYcCW3BT8lRHqbaSce4g+1d/pMoxbDDsOM49vYySx2rXL99ov6lE4u9kTu4C0/rQwPaZvtbXnxqjpSRVI8ls8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywxhv+FFjpQl0/TYMsxRyTT3jPhtBvqtShaArjvnWYqvnD2mgb/ NBa8FlVTn11Ic65YWh1SK8I759WIpUpf0ifg5xg1qoP8g0TjA3ZvXjLK/608coDdQnNK/3637KO LxPLZWQ== X-Google-Smtp-Source: AGHT+IF1wlLw5tKP2MahScWnqNYKosVf7VJShq5yWFU+gWkqFVQfBU7CnHJcvzoWX84E13Jq/9xcqgql1Os= X-Received: from pjbhl15.prod.google.com ([2002:a17:90b:134f:b0:340:9a37:91a4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:164d:b0:340:48f2:5e2d with SMTP id 98e67ed59e1d1-349a24e3b3emr720458a91.9.1764981812967; Fri, 05 Dec 2025 16:43:32 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 5 Dec 2025 16:43:11 -0800 In-Reply-To: <20251206004311.479939-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251206004311.479939-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206004311.479939-10-seanjc@google.com> Subject: [PATCH 9/9] KVM: x86: Hide KVM_IRQCHIP_KERNEL behind CONFIG_KVM_IOAPIC=y From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enumerate KVM_IRQCHIP_KERNEL if and only if support for an in-kernel I/O APIC is enabled, as all usage is likewise guarded by CONFIG_KVM_IOAPIC=3Dy. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index 5a3bfa293e8b..8a979c389bc0 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1222,7 +1222,9 @@ struct kvm_xen { =20 enum kvm_irqchip_mode { KVM_IRQCHIP_NONE, +#ifdef CONFIG_KVM_IOAPIC KVM_IRQCHIP_KERNEL, /* created with KVM_CREATE_IRQCHIP */ +#endif KVM_IRQCHIP_SPLIT, /* created with KVM_CAP_SPLIT_IRQCHIP */ }; =20 --=20 2.52.0.223.gf5cc29aaa4-goog