From nobody Thu Jul 23 10:01:23 2026 X-Original-To: dev-commits-src-all@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 4h5RTw2yfTz6lWhj for ; Thu, 23 Jul 2026 10:01:24 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h5RTv2KRcz3X5r for ; Thu, 23 Jul 2026 10:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784800883; 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=b1U1VihqCynrrWdiKCzNWAYyE4JbwuzdiD/6pdV47oI=; b=mqhBIsEUOvnjn1wWIXT4I0RGKBBJd+QCNxPbV7eNLisMfQDPFyUIR3JPcgbtYEbaQu6/Wp VXOK0XWG7g1F496DR2lIKIziB0RTPToyIbiSll5PWfU3/0QvGiJU3H3/4OeJwksKZuEX41 wA/lIwqdsG8WryAd6JY0FbH5AHOtZO4GyOTgLKYUET2X0QAxS2mpWhvpyx70hWOtbZwLmf /cYCTTOhvHqEogQB3cJOxMZxLTWEdOwEEBRYofGop5elAL7RUWAJ8X+wbVmKFjiV/DhBSF fYSyOzPmbAyDWGdq7Bega8Cvbl03TLosATYExfE47QmZzfQYjfI9/y16g1fzCA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784800883; a=rsa-sha256; cv=none; b=JQGjLbOzd7UYeh6dI0laXJetJjs+L2HWNtRzShDOSsqPm66ZtWg3KfFmQGmNRhOKNCG4r2 6vn55O9mRi/fvtr4Z9nwvlH/2fpm9P5elKeqIHSSuqUnDU+gNnaD6WXjuZbMHTnms11URI GOskl9HTEdiDTJNoYgaX/1lBkeAbiKTazv66UM5sdAvfVlrd0W4S4PEU+W72IHyKVowC0f rCimAT0R9AcCEbnZvxQNyaSCivSP4Sguy9TrpFqPm7sa1QCSXb+qh9KeD3HQLoC+0rsak1 haU/MpuQ5IWMUvYaAKzjl16ho+/MXeJUAzerDGDCWGJbbg1FFou0pHjGm37vcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784800883; 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=b1U1VihqCynrrWdiKCzNWAYyE4JbwuzdiD/6pdV47oI=; b=eQysrXdqE5+1FLZl2lZoIv4WXo6fjmzGJhdDh7pFEqM/ra4hFszEN/4SUlLGHoauePQQ6j VVVEDTrXsvK9pa8ftvR5Fpez1Wrhn6dMIJwWFw23k6r93u23UYMT2SSQFVDwIT5prkClpW rEf3yEh+LOYx6WGpk0pdOBFJejVkhNlA98HKSu/NUVFUOeftJkOzRWtLkcg7KJRGyrtqQu oqahlpeAcKpv/zLo/7osnggZnqCfwKCEAGtIw2bHy4PtRuoaeqUvGUlmpsJoD3mi26e+rY Ib5RTEYg7CoXAt5ogVBtZ+zwx4zOYkCChSmmpFmYtKAC6N2sq2mLtdPlZiDwog== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h5RTv1M4Mz10tH for ; Thu, 23 Jul 2026 10:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d49d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 23 Jul 2026 10:01:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 2a3374d999fc - stable/14 - x86/local_apic.c: Fiddle with thermal LVT slot only if supported List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2a3374d999fca981624a97781ef8bfbc404f26f4 Auto-Submitted: auto-generated Date: Thu, 23 Jul 2026 10:01:23 +0000 Message-Id: <6a61e673.3d49d.36053e09@gitrepo.freebsd.org> The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=2a3374d999fca981624a97781ef8bfbc404f26f4 commit 2a3374d999fca981624a97781ef8bfbc404f26f4 Author: Olivier Certner AuthorDate: 2026-07-02 14:26:21 +0000 Commit: Olivier Certner CommitDate: 2026-07-23 09:59:18 +0000 x86/local_apic.c: Fiddle with thermal LVT slot only if supported The thermal LVT slot does not necessarily exist. According to Intel's Software Developers Manual, for Intel processors supporting 64-bit operation (amd64), probably even the earliest ones should have a local APIC with such a slot (the slot was introduced with Pentium 4 and Xeon processors according to the manual, and the 64-bit implementation in some later versions of them). AMD's Architecture Programmer's Manual also seems to imply that all AMD processors supporting amd64 should have the slot too. So this change may not be needed when i386's code is dropped, but it does not hurt to have it, and it might ease possible MFCs. Change the signature of lapic_enable_thermal() so that it can report failure (if there is no local APIC or if there is no thermal LVT slot). Reviewed by: bnovkov, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58086 (cherry picked from commit c18ec05395b36bdd12b0129533a553f27eb9b067) --- sys/x86/include/apicvar.h | 2 +- sys/x86/x86/local_apic.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h index d9957409cfae..9faa3c80e8dc 100644 --- a/sys/x86/include/apicvar.h +++ b/sys/x86/include/apicvar.h @@ -235,7 +235,7 @@ void apic_enable_vector(u_int apic_id, u_int vector); void apic_disable_vector(u_int apic_id, u_int vector); void apic_free_vector(u_int apic_id, u_int vector, u_int irq); void lapic_calibrate_timer(void); -void lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg); +bool lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg); void lapic_disable_thermal(void); int lapic_enable_pmc(void); void lapic_disable_pmc(void); diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 9e979df4167f..7bf13a2355f5 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -803,9 +803,10 @@ lapic_dump(const char* str) printf("\n lint0: 0x%08x lint1: 0x%08x TPR: 0x%08x SVR: 0x%08x\n", lapic_read32(LAPIC_LVT_LINT0), lapic_read32(LAPIC_LVT_LINT1), lapic_read32(LAPIC_TPR), lapic_read32(LAPIC_SVR)); - printf(" timer: 0x%08x therm: 0x%08x err: 0x%08x", - lapic_read32(LAPIC_LVT_TIMER), lapic_read32(LAPIC_LVT_THERMAL), + printf(" timer: 0x%08x err: 0x%08x", lapic_read32(LAPIC_LVT_TIMER), lapic_read32(LAPIC_LVT_ERROR)); + if (maxlvt >= APIC_LVT_THERMAL) + printf(" therm: 0x%08x", lapic_read32(LAPIC_LVT_THERMAL)); if (maxlvt >= APIC_LVT_PMC) printf(" pmc: 0x%08x", lapic_read32(LAPIC_LVT_PCINT)); printf("\n"); @@ -931,8 +932,9 @@ lapic_setup(int boot) lapic_write32(LAPIC_ESR, 0); /* Thermal LVT */ - lapic_write32(LAPIC_LVT_THERMAL, lvt_mode(la, APIC_LVT_THERMAL, - lapic_read32(LAPIC_LVT_THERMAL))); + if (maxlvt >= APIC_LVT_THERMAL) + lapic_write32(LAPIC_LVT_THERMAL, lvt_mode(la, APIC_LVT_THERMAL, + lapic_read32(LAPIC_LVT_THERMAL))); /* Program the CMCI LVT entry if present. */ if (maxlvt >= APIC_LVT_CMCI) { @@ -1662,15 +1664,18 @@ lapic_update_thermal(void *dummy __unused) lapic_read32(LAPIC_LVT_THERMAL))); } -void +bool lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg) { #ifdef DEV_ATPIC /* Fail if the local APIC is not present. */ if (!x2apic_mode && lapic_map == NULL) - return; + return (false); #endif + if (lapic_maxlvt() < APIC_LVT_THERMAL) + return (false); + lapic_thermal_function_arg = func_arg; atomic_store_rel_ptr((uintptr_t *)&lapic_thermal_function, (uintptr_t)func); @@ -1679,6 +1684,8 @@ lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg) MPASS(mp_ncpus == 1 || smp_started); smp_rendezvous(NULL, lapic_update_thermal, NULL, NULL); + + return (true); } void @@ -1690,6 +1697,9 @@ lapic_disable_thermal(void) return; #endif + if (lapic_maxlvt() < APIC_LVT_THERMAL) + return; + lvts[APIC_LVT_THERMAL].lvt_masked = 1; #ifdef SMP