From nobody Mon Jan 19 16:20:49 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dvwg55jgCz6P1Zd for ; Mon, 19 Jan 2026 16:20:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dvwg50WYqz3xnk for ; Mon, 19 Jan 2026 16:20:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768839649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xC9hYirVVMIh6xTPYvfTEx5NxynJHn2QI6Xd5UjmwFM=; b=Y2RzELve1WSJFyv8hTars41mQup5rLdjOhRo+ue9/4G9RiqHVyt9FbUM5ocKcaTAB0/+GB SA1GrP9mudJvRE7D7yySBOshvWTQjnz8VczgC8Fx9mybPvDYXhoyVSKabJEMHouG8Wx+t8 LcIDYRcaeZ5jwMSTwVqEk+A7dhyAxPuS1g6baZbFxtLf0DNnYpx2DoTv1XRPFnBPp9CP2j etfyzXAYK+H5Ia7JE+bm4qcU4rOh1j1bV3cjLJ39UETNZpH1qjhe9oAqGCTSmb0TKCwu82 BaeQAOkoRA/yHDERePlAuK0EOSL8hOx8SdLzPw+aFcvcJvfNAiVsNceAQRHT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768839649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xC9hYirVVMIh6xTPYvfTEx5NxynJHn2QI6Xd5UjmwFM=; b=HE1vSW69yCd1NcwJtgt5Oq8whjekQsMEKDr32QSJgBaT0IrDKJ88SAGTp4cmEePCe8uYaq pheFxi51I/dyhTqASAvidBgRzosCS8egfaTcz19qkSmZMJnYbG2+letLsFukbRbQzzD0fH N5YwZV8UWrJXhhDFozkAJ9KV75uNFa+tGyG2uyJKJDGqiBZss5/ayEhOzuWy53l+P4DHUK xXjkGZ5ILCR9Dqdz8ke8cOLy7Q2XqKMWA+8GObN3zoZTfz3Lm0L9RqS3jxGbZEZSWvmrAo oPl9L6YRjhadRW5639pd3RhgcwJ1hjhDwMdqWqXzcwNJpWvXdYYlGaoBd0cOQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768839649; a=rsa-sha256; cv=none; b=jjNlLZoqpl3QIr9qpZeOzu10XtwpD0MU3CZDyTAWwysKFdElFM4qjjO9oB0vdN65EnZPKd 0zXHcAAjkYf3yb/rRV78OxnXiuHS+k9XeirLOD3oUsuHoKbMU2oZaf6IwSXqZqIBncmX7k 31+IC1+/iXgThT2DZUlvKb7Nrs4Uy2+ONumAYdE1aIm/t4Aw0gIo10f2OPCbFQYOL8Nl2j heZ6/K0964PTxZClNZ7F9x/uOgdXg7ISMfqXdUWSLfvR14B9+9aMYTiSOKl9yqMhAUSU3n NvXxMiho3VUu3uQlehRTDqovwTJCmsRwlRlYsAilNu1KHOrVW7hWfro72ZCTsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dvwg505h8zfwX for ; Mon, 19 Jan 2026 16:20:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33d19 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 19 Jan 2026 16:20:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 709a53c8b20b - main - x86/local_apic.c: Properly calculate the number of LVT entries List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 709a53c8b20b5770f7e2f117d4799b5617479976 Auto-Submitted: auto-generated Date: Mon, 19 Jan 2026 16:20:49 +0000 Message-Id: <696e59e1.33d19.4d981373@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=709a53c8b20b5770f7e2f117d4799b5617479976 commit 709a53c8b20b5770f7e2f117d4799b5617479976 Author: Konstantin Belousov AuthorDate: 2026-01-19 11:55:36 +0000 Commit: Konstantin Belousov CommitDate: 2026-01-19 16:20:37 +0000 x86/local_apic.c: Properly calculate the number of LVT entries First, the CMCI entry index is APIC_LVT_MAX, so it was excluded unconditionall [1]. Second, the number of entries is reported by the version register, and we must not access past the last reported entry. Reported by: olivier [1] Fixes: 11f954b021a1aadde1d03d40ed5d6b529e14da98 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54773 --- sys/x86/include/apicreg.h | 7 ++++++- sys/x86/x86/local_apic.c | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/x86/include/apicreg.h b/sys/x86/include/apicreg.h index 1252647fbab3..4cc9cabdad9e 100644 --- a/sys/x86/include/apicreg.h +++ b/sys/x86/include/apicreg.h @@ -439,7 +439,12 @@ typedef struct IOAPIC ioapic_t; #define APIC_EXTF_SEIO_CAP 0x00000002 #define APIC_EXTF_IER_CAP 0x00000001 -/* LVT table indices */ +/* + * LVT table indices. + * Must be ordered following the appearance of the LVT entries in + * series the LAPIC versions, which is reported by LAPIC_VERSION + * MAXLVT field. + */ #define APIC_LVT_LINT0 0 #define APIC_LVT_LINT1 1 #define APIC_LVT_TIMER 2 diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 68f42c9eed0b..b444142d5481 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -819,9 +819,12 @@ lapic_early_mask_vec(const struct lvt *l) static void lapic_early_mask_vecs(void) { - int elvt_count, i; + int elvt_count, lvts_count, i; + uint32_t version; - for (i = 0; i < APIC_LVT_MAX; i++) + version = lapic_read32(LAPIC_VERSION); + lvts_count = min(nitems(lvts), lapic_maxlvt(version) + 1); + for (i = 0; i < lvts_count; i++) lapic_early_mask_vec(&lvts[i]); elvt_count = amd_read_elvt_count();