From nobody Tue Feb 10 04:12:35 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 F203032252E for ; Thu, 13 Nov 2025 20:51:19 +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=1763067081; cv=none; b=jHeIqWPhQAXnYFe+pfee4pGXlmmUA5YEAB43t3N5nijUTEz/S6IJKtNXkrGPEiF7XG0jV5b7rFYeD0cpShhMzWMJMzDunPQRfN/ExAEEfad2atu6HsdCr4MpemTRdHqebrW38lDMmGzFAxseQ1QwpnTXYW2ahl9qK76tkqJvw4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763067081; c=relaxed/simple; bh=Vf3uSzJxbcyxYL4gFf/C72FnMzhTr6uR25r04d1TBGk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ktIluuWWe/sh8w+/4FSUImr7cNIp2KUgBmrSLjs88xwnc3qQsTosYuX+UjmYcef5WA607RCWaM9padZCQdvf7/WY32X1fntDjcqG2a8bvX4gGUUdI7lwDC7sk2nSwZBsu/H702M9SjW/x8vswbyku+cUG6nsl2TZIHyemPiVuD8= 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=Vz1ZpVCY; 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="Vz1ZpVCY" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-340bb1bf12aso3055509a91.1 for ; Thu, 13 Nov 2025 12:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763067079; x=1763671879; 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=2S2xbMUFn2UUxymTDK244231LhDPBAgc++LRYyMCXcc=; b=Vz1ZpVCYl0ehQREEva6QHDlVEj5Xg2fQWza5UDiQvcgVvhzOccsEthXq3sEVyN81kR lMwhoiyUKrfFWTE93cXVwEv6XCc/8jHrMKtknNlV7mybCof0RzoqLWuZcPNelBZxTLVc huxrhHEovC7uPzFtTp4IHXqKqcR307iD3aAi+Ci+egxFmQa4hI2SV/a2EdH+UCprYUz4 o6rNDEeLnsmxFOHh0W0mdReC/bu4qbTP2Q6b/ZKN3htN3/Tgb4rZPFtpztBGcgx+TPb0 Wb5VR3uLsFGScxRox92adUk5MlCOFGKjV8Nu7wBMfpueWghxwEuPQrFggX2CP3TJxoyL Az7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763067079; x=1763671879; 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=2S2xbMUFn2UUxymTDK244231LhDPBAgc++LRYyMCXcc=; b=wijys/WBapwveIzrusdd0hqV71eknMrJchEmQYn+OLekluLR/aQB4+jiGnjb7WWbvR tnNCRqJAyzer2awjJHX3svHdPZJ6+eEXlP0ADLBrGrZz63MaBufMOaajQq12Ind+8qwV cs4ENWNjDuGZob+/XWDxdlyOuOQagLojf96z9vnharf9VV1E/qRkjrWRlJa2vHosNBKc VgMq7OrjAC90ax+2AtxGkeUm9SiDXAVyut1YXIRz78G869HVSAo7SAEAz5XeqljtW2An Pm2l49H2/80PgrzNTA1+cV7HEqv2phzL2O6b36kQlqCkzrAO9oR/MI+2Q4E0oW8gRiPc wCSw== X-Forwarded-Encrypted: i=1; AJvYcCW6L+TIv+zv97IkuIAtwBUR7yORB0FPWuIwzOXX4un42Ph53vCKSfDc/CeqeOSrvwFxwn/FHVEynvNyUXA=@vger.kernel.org X-Gm-Message-State: AOJu0YzyTJRocj9NkKtuQCzWzyt6Fd4H0RNZOFb3cfjDUYuDg1JCErJ7 /arwPnsAM3Yu4GgTMuUiwptIgB8jK/d42fvm22NzGQbzAlw7moN+7LNJSiEMgef2Ilcs+2JvC9o /bc8GIg== X-Google-Smtp-Source: AGHT+IGVAzpCiBUlqayaEcwV9yPwrMMcLoBK/HBvd8DKQ/dh06UxA07ygYJfrejiXAPWfmyV/Ib0nnpELwY= X-Received: from pfbhh7.prod.google.com ([2002:a05:6a00:8687:b0:77f:5efe:2d71]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:33a1:b0:34f:99ce:4c48 with SMTP id adf61e73a8af0-35ba1d9acd7mr1276932637.42.1763067079096; Thu, 13 Nov 2025 12:51:19 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 13 Nov 2025 12:51:11 -0800 In-Reply-To: <20251113205114.1647493-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: <20251113205114.1647493-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251113205114.1647493-2-seanjc@google.com> Subject: [PATCH v6 1/4] KVM: x86: WARN if hrtimer callback for periodic APIC timer fires with period=0 From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, fuqiang wang Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" WARN and don't restart the hrtimer if KVM's callback runs with the guest's APIC timer in periodic mode but with a period of '0', as not advancing the hrtimer's deadline would put the CPU into an infinite loop of hrtimer events. Observing a period of '0' should be impossible, even when the hrtimer is running on a different CPU than the vCPU, as KVM is supposed to cancel the hrtimer before changing (or zeroing) the period, e.g. when switching from periodic to one-shot. Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 0ae7f913d782..78b74ba17592 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2970,7 +2970,7 @@ static enum hrtimer_restart apic_timer_fn(struct hrti= mer *data) =20 apic_timer_expired(apic, true); =20 - if (lapic_is_periodic(apic)) { + if (lapic_is_periodic(apic) && !WARN_ON_ONCE(!apic->lapic_timer.period)) { advance_periodic_target_expiration(apic); hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); return HRTIMER_RESTART; --=20 2.52.0.rc1.455.g30608eb744-goog