From nobody Thu Jan 15 14:51:01 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 4dsQsL3qwrz6P4TY for ; Thu, 15 Jan 2026 14:51:02 +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 4dsQsK5X64z3Jd0 for ; Thu, 15 Jan 2026 14:51:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768488661; 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=3F4kVXxT9O4XCSvUMMZi8dd3vLvXvl0I4BHPys5gIqk=; b=HrnnnFgMgLxc6xLvu2girI15tSIxeTnyB0Xj1Hq60VVHdzWTq3ZTC80TM3uvb62ybhvX+q sC3thfzrvdAhdgY1Ok1SkvQhGmqkYnxyjNlhLXDKSbEAM6VFZKHKsFGWYslzxmA07T90DQ iUhyiv6R+O+admYtV6OfCaBK6a3LlzS/IWBsLLkPZH/BUtip2jWsL0LzVuudIQJSGbTOB7 7MH/jHMO2I9ITRK8f/Uv1iOpUwkBbHDzVfx2ckgmA7PEEhw44qqZu9yBYMk+wI7gLCdSpd YbeVbET6ASfZ6+zVFBpfPs3ddH300+cUnvo05vVpQlF9LhKIMOhnMD1n1siDAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768488661; 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=3F4kVXxT9O4XCSvUMMZi8dd3vLvXvl0I4BHPys5gIqk=; b=YREaCx73/NkwsSGKukXX8Xl8/P04IhojseVSjz+gy9Xzd3Jh/6FjBod3SCnNBEIgEg4jd4 UnLjhDCI8IEWrlWUVaeUSFejf8uyUZvsaR5SIbwf8rPAMqZqNkjUhC0lHwBL0Bs8zZvAxs DidDTIsv6r1XDoi1yb1YvpaZmFS+NerP/8kzlRt3ntnjpoDK/GdaJsHhHqA58xDeB+UkfF /Uu0sIjjLuF79QY0BiK06buFYQRGMS1LxFuZhj6YOPCyo3oU9QvJlJQRY+29cSR1JZVU10 QKRoteTWqAYSECZ8IAb3lwXzm86WI2nVXCEzqP8gLPhcwItkRepxigo72ExCpA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768488661; a=rsa-sha256; cv=none; b=qcO4WjNxwKqsNddQyvw8EqfSXJFbT/LZSE7PU4mo+1ImAydEZOYBr80SXtq7r83njPmYIA LotgkQCRSdmu5eX3NcqsGk5Os7Gybpvuem19f9QXQCFDDUyTa1FOcCQ8bz8QAaQKcGNWg7 zVbCOX45nGKF/WkP6j/ZDbALSnmNBXV2gTU1coJCi1n6z3u74hHLW9ZVXFJ96FlFcLZoHg h8LdFmMh/pR19t7NHs4WWuTsQ0+8f/Za6+fky1VvNdFiKmU3Z2y9nzdWjZ3mFfFHm83J4+ TgT+XFgX3Pog1UCOsTe8fFICK0a9rRc2jKP5I0Axf62UU63zVthnNUzcnXbVzQ== 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 4dsQsK53W7zYmm for ; Thu, 15 Jan 2026 14:51:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 221de by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 15 Jan 2026 14:51:01 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 2210c15b08b9 - stable/14 - arm64: Support managing features from loader 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2210c15b08b9f70054d4de46a5a8566d395e0abe Auto-Submitted: auto-generated Date: Thu, 15 Jan 2026 14:51:01 +0000 Message-Id: <6968fed5.221de.23055389@gitrepo.freebsd.org> The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=2210c15b08b9f70054d4de46a5a8566d395e0abe commit 2210c15b08b9f70054d4de46a5a8566d395e0abe Author: Andrew Turner AuthorDate: 2025-09-04 14:45:09 +0000 Commit: Andrew Turner CommitDate: 2026-01-14 21:14:12 +0000 arm64: Support managing features from loader Allow the user to enable/disable supported cpu features/errata from a known tunable. This will allow the user to disable features, e.g. to work around broken firmware. It can also be used to enable workarounds for rare errata. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D52358 (cherry picked from commit 4bc68fa98f68211ee7943d77cfc91f60ccb5880d) --- sys/arm64/arm64/cpu_feat.c | 22 +++++++++++++++++++++- sys/arm64/include/cpu_feat.h | 27 ++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/cpu_feat.c b/sys/arm64/arm64/cpu_feat.c index fd1b8429295f..986d5079e980 100644 --- a/sys/arm64/arm64/cpu_feat.c +++ b/sys/arm64/arm64/cpu_feat.c @@ -40,10 +40,13 @@ static cpu_feat_errata_check_fn cpu_feat_check_cb = NULL; void enable_cpu_feat(uint32_t stage) { + char tunable[32]; struct cpu_feat **featp, *feat; uint32_t midr; u_int errata_count, *errata_list; cpu_feat_errata errata_status; + cpu_feat_en check_status; + bool val; MPASS((stage & ~CPU_FEAT_STAGE_MASK) == 0); @@ -60,9 +63,26 @@ enable_cpu_feat(uint32_t stage) PCPU_GET(cpuid) != 0) continue; - if (feat->feat_check != NULL && !feat->feat_check(feat, midr)) + if (feat->feat_check != NULL) continue; + check_status = feat->feat_check(feat, midr); + /* Ignore features that are not present */ + if (check_status == FEAT_ALWAYS_DISABLE) + continue; + + snprintf(tunable, sizeof(tunable), "hw.feat.%s", + feat->feat_name); + if (TUNABLE_BOOL_FETCH(tunable, &val)) { + /* Is the feature disabled by the tunable? */ + if (!val) + continue; + /* If enabled by the tunable then enable it */ + } else if (check_status == FEAT_DEFAULT_DISABLE) { + /* No tunable set and disabled by default */ + continue; + } + /* * Check if the feature has any errata that may need a * workaround applied (or it is to install the workaround for diff --git a/sys/arm64/include/cpu_feat.h b/sys/arm64/include/cpu_feat.h index f62f3e334dc1..6a554b6baedf 100644 --- a/sys/arm64/include/cpu_feat.h +++ b/sys/arm64/include/cpu_feat.h @@ -40,6 +40,31 @@ typedef enum { /* kernel component. */ } cpu_feat_errata; +typedef enum { + /* + * Don't implement the feature or erratum wrokarount, + * e.g. the feature is not implemented or erratum is + * for another CPU. + */ + FEAT_ALWAYS_DISABLE, + + /* + * Disable by default, but allow the user to enable, + * e.g. For a rare erratum with a workaround, Arm + * Category B (rare) or similar. + */ + FEAT_DEFAULT_DISABLE, + + /* + * Enabled by default, bit allow the user to disable, + * e.g. For a common erratum with a workaround, Arm + * Category A or B or similar. + */ + FEAT_DEFAULT_ENABLE, + + /* We could add FEAT_ALWAYS_ENABLE if a need was found. */ +} cpu_feat_en; + #define CPU_FEAT_STAGE_MASK 0x00000001 #define CPU_FEAT_EARLY_BOOT 0x00000000 #define CPU_FEAT_AFTER_DEV 0x00000001 @@ -50,7 +75,7 @@ typedef enum { struct cpu_feat; -typedef bool (cpu_feat_check)(const struct cpu_feat *, u_int); +typedef cpu_feat_en (cpu_feat_check)(const struct cpu_feat *, u_int); typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int, u_int **, u_int *); typedef bool (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata,