From nobody Fri Jul 10 15:30:39 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 4gxbPq4FJRz6lJG3 for ; Fri, 10 Jul 2026 15:30:39 +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 4gxbPq2K5xz46H4 for ; Fri, 10 Jul 2026 15:30:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783697439; 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=LO2ROiu74JlC7GR+DLovVF9oBWAlPxgokpVSQgRpDxk=; b=OWEapeoUU6emBxsKvBgCHreN4NwfQ0w/CGUJL79VlUtFvvTc8a+QiQdfHAczPoPAZHjDoy b15uURFLFpQOE+ajLOqRfCaenJ1mxVRNA51JoE0scicNiyQBMrF3T1qnZRWVbD9XE1AnpO 5dHAr8ecETQXnVuUIskYGERmexggyj/WWcXUZ6mLYIxRPWzI8u9LxmAUZLa2C4iNHTQ1jn zgA5FvEnZLXQs0cYwwyZhxVz08UPMvc1zjwYLFMV4cjjY1h5M9VQOQYBfSk3wzy6d/m5q/ 0HIZ27sPbbZF9KR4ypVyjWJVOov+u6gNI3eFRDuEeV6MEzcib1SSSPWXJYDXPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783697439; a=rsa-sha256; cv=none; b=CW6h8lKO9P4a8x0XeX23KgLC2i8CWr/gwXuzQQquivYCefeqFNs39/v2OBuAxsLfuWkxaA m4GcYAcEArlG9tmbaUVaPMjOXmbOdlb5F9Owa5I4HlPcFgyU3e03MyZ3NbyAQBomcjLZLp n68SM6DRZPBIO/XrnnaU97EngQFILctmL3r/NfIFc5laX93nodtUDCBPVC522LqyI2orVn bDQlRFMKSXrS5tOCc0lRxgOGoi8Zf65dn7SKagIDEkp8fK5vAMtwh2QQ0ZYLvlseDBP9f1 Ogntt053zLW0sVP3LqD6bE3czwBBjyLoVG1iTix8CP17cRXdzRedTpHvZVlpXw== 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=1783697439; 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=LO2ROiu74JlC7GR+DLovVF9oBWAlPxgokpVSQgRpDxk=; b=X5D5qin7L0TMFcvwkBla+QEThCMf4Qc0f+ECrMR7sy7m6/5ALWp7Al9PkdvkHUZI9krgah jsU3tk8AIxabdG/7YwWdDQhtxYeo2vc7Kni8yigaTDe40jANLVM7frLtifS38gqsca4Nsi 8LmMQZgrys8GQOU6V0rxlR0abDIJrPTV9t8TiiQCfBRA0wmLHNOn8gA8AqYLH0rqrj0Spp R3A2c7eXqvTFSodqdGXQUiuQ4Nq+5t1BwawQbONJCwKWQDrdXVB2oVcjQorda10pKiwAIB SfoL+nUJVnjH5B1kJrn/oCYNDceR8m9dbf9u202pva7g8bZQF6e+9NNTtgI43w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gxbPq1KtXz10Tv for ; Fri, 10 Jul 2026 15:30:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3494b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 10 Jul 2026 15:30:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: c18ec05395b3 - main - 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/main X-Git-Reftype: branch X-Git-Commit: c18ec05395b36bdd12b0129533a553f27eb9b067 Auto-Submitted: auto-generated Date: Fri, 10 Jul 2026 15:30:39 +0000 Message-Id: <6a51101f.3494b.14d56633@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=c18ec05395b36bdd12b0129533a553f27eb9b067 commit c18ec05395b36bdd12b0129533a553f27eb9b067 Author: Olivier Certner AuthorDate: 2026-07-02 14:26:21 +0000 Commit: Olivier Certner CommitDate: 2026-07-10 15:29:49 +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 --- 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 54ea5bc655e5..10dbc50a981b 100644 --- a/sys/x86/include/apicvar.h +++ b/sys/x86/include/apicvar.h @@ -236,7 +236,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_pcint(void); void lapic_disable_pcint(void); diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 73ddf9115e4c..aceb9a229c4f 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -807,9 +807,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"); @@ -935,8 +936,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) { @@ -1663,15 +1665,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); @@ -1680,6 +1685,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 @@ -1691,6 +1698,9 @@ lapic_disable_thermal(void) return; #endif + if (lapic_maxlvt() < APIC_LVT_THERMAL) + return; + lvts[APIC_LVT_THERMAL].lvt_masked = 1; #ifdef SMP