From nobody Mon Nov 20 19:04:32 2023 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 4SYxl52C61z51jn9; Mon, 20 Nov 2023 19:04:33 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SYxl51BL8z3Nvk; Mon, 20 Nov 2023 19:04:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700507073; 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=Cf6/uq7gsSRK7Yn0mJqvPcUl+Hr3BVzcACpEDIXoqyo=; b=QfMMUvdQ+mv+XCEd7XgFKuH+sFJ0yyonImQm0tOYu70kTNfjzNqmlzRZSwkhNkzoLcyK97 79aGTrEqE249TKrh5uKJyAXASNXGbCcE6chNO39FH6CWTCaJ4UCjBAexSuMIHfP6vO8cxc UBZsvMPFUVAsk58wbitrHP+yyUgaBHTl/RwD5xTc24jzS4k7VMqdWwyGs1/K2gmfI4C67p +UQV1BZ8zNMVtytbHQq+eMd/kW8pkKDMeC8aC8C1HVapkp1Jcfynfk+37AowgnP2rUAuwN w4PRBov4ii6U00R5FvSKDLwuuwJJGbb3NAe1RwGkFL3p5L1ijsy3fimh0z1cMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700507073; 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=Cf6/uq7gsSRK7Yn0mJqvPcUl+Hr3BVzcACpEDIXoqyo=; b=op82wk3fs5/7kImyh406fPdBCdo2QWYLKPff5tm4chXgMAhXiArNvktTZDrJlddD/BEjgT mBz9O4CFuDYpOJlanPr/6gb84RESymyiwYFlxHmYJHY5Ihy4krMHoTNtbtUIuxuDrFGqf5 Ax5R6Ym5l4LDOpOmSJ+/gu4DH3y1ABRLeV8/EH+7t47edx9Z9HeSMKHNP+v8y/XwEkHorr A4jWRAUlTs8fN1EdL3FaR1SmdFtqnZ5dvcZDiCR7iwQIMTzEwiG5lHYy8knWr4Yqu/IqPs y/qiXHkXqL+1qLJIAfu7gE4L+VQdofBBePcl52TOWyLZkNwxWav1+iin1FysYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700507073; a=rsa-sha256; cv=none; b=Xqz3V6m7I1SZSsCvjS3CWBgASbmRs1uQAL8K2/0lGoEqJqTjsGh/FG8LXD7joIdDWcU+Qe jqu3mnVnyzX8G5+0bgXh58bD49ZiipkWzpHEoHQ7p0ecn4eW851pnqJcTdzUUjZuwO8/Ce Mr4otvVUiCFw5SpZj/kmo3AlCxwSkO+mhpN7vn4HpKaFRGJWb2JPs91Sr54F6U7E6YfIuV spH9uwSMgBPpJYvr/aoY1AZVxQf8IzBPKvPYZXXofiUNpJLHehHxkJU08OrhE7VK70Wost XLdfEAm1rBGRAnroPj4LSQQhsJ/X5fgnFNyYih28LisP+4mpIYGSysX7it30kQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SYxl5028qz13rr; Mon, 20 Nov 2023 19:04:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AKJ4W04091378; Mon, 20 Nov 2023 19:04:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AKJ4WZL091375; Mon, 20 Nov 2023 19:04:32 GMT (envelope-from git) Date: Mon, 20 Nov 2023 19:04:32 GMT Message-Id: <202311201904.3AKJ4WZL091375@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "R. Christian McDonald" Subject: git: e0f3dc82727f - main - loader: improve lua ACPI detection and handling 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0f3dc82727f236b0bea495d8a4d6e6dc630854d Auto-Submitted: auto-generated The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=e0f3dc82727f236b0bea495d8a4d6e6dc630854d commit e0f3dc82727f236b0bea495d8a4d6e6dc630854d Author: R. Christian McDonald AuthorDate: 2023-11-20 17:13:08 +0000 Commit: R. Christian McDonald CommitDate: 2023-11-20 19:03:59 +0000 loader: improve lua ACPI detection and handling This is a follow-up patch to https://reviews.freebsd.org/D42459 that modifies the loader lua to use the correct loader variables for determining ACPI availability. This also fixes a bug where ACPI can be inadvertently disabled when setting System Defaults at the loader menu. Reviewed by: imp, kevans Approved by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42483 --- stand/lua/core.lua | 39 +++++++++++++++------------------------ stand/lua/core.lua.8 | 24 ++++++++++-------------- stand/lua/menu.lua | 2 +- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/stand/lua/core.lua b/stand/lua/core.lua index 8a481ee0b782..718783309687 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -32,6 +32,7 @@ local hook = require("hook") local core = {} +local default_acpi = false local default_safe_mode = false local default_single_user = false local default_verbose = false @@ -46,20 +47,14 @@ local function composeLoaderCmd(cmd_name, argstr) end local function recordDefaults() - -- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386, - -- it will generally be set upon execution of the kernel. Because of - -- this, we can't (or don't really want to) detect/disable ACPI on !i386 - -- reliably. Just set it enabled if we detect it and leave well enough - -- alone if we don't. - local boot_acpi = core.isSystem386() and core.getACPIPresent(false) local boot_single = loader.getenv("boot_single") or "no" local boot_verbose = loader.getenv("boot_verbose") or "no" + + default_acpi = core.getACPI() default_single_user = boot_single:lower() ~= "no" default_verbose = boot_verbose:lower() ~= "no" - if boot_acpi then - core.setACPI(true) - end + core.setACPI(default_acpi) core.setSingleUser(default_single_user) core.setVerbose(default_verbose) end @@ -137,18 +132,18 @@ function core.setSingleUser(single_user) core.su = single_user end -function core.getACPIPresent(checking_system_defaults) - local c = loader.getenv("hint.acpi.0.rsdp") +function core.hasACPI() + return loader.getenv("acpi.rsdp") ~= nil +end - if c ~= nil then - if checking_system_defaults then - return true - end - -- Otherwise, respect disabled if it's set - c = loader.getenv("hint.acpi.0.disabled") - return c == nil or tonumber(c) ~= 1 +function core.getACPI() + if not core.hasACPI() then + return false end - return false + + -- Otherwise, respect disabled if it's set + local c = loader.getenv("hint.acpi.0.disabled") + return c == nil or tonumber(c) ~= 1 end function core.setACPI(acpi) @@ -358,7 +353,7 @@ function core.loadEntropy() end function core.setDefaults() - core.setACPI(core.getACPIPresent(true)) + core.setACPI(default_acpi) core.setSafeMode(default_safe_mode) core.setSingleUser(default_single_user) core.setVerbose(default_verbose) @@ -441,10 +436,6 @@ function core.isSerialBoot() return false end -function core.isSystem386() - return loader.machine_arch == "i386" -end - -- Is the menu skipped in the environment in which we've booted? function core.isMenuSkipped() return string.lower(loader.getenv("beastie_disable") or "") == "yes" diff --git a/stand/lua/core.lua.8 b/stand/lua/core.lua.8 index 39ae2166d442..61eab6fe24f6 100644 --- a/stand/lua/core.lua.8 +++ b/stand/lua/core.lua.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 21, 2018 +.Dd November 20, 2023 .Dt CORE.LUA 8 .Os .Sh NAME @@ -90,7 +90,7 @@ constants. .Ss Exported functions The following functions are exported from .Nm : -.Bl -tag -width core.getACPIPresent -offset indent +.Bl -tag -width core.setSingleUser -offset indent .It Fn core.setVerbose verbose Sets or unsets .Ev boot_verbose . @@ -103,15 +103,14 @@ Sets or unsets If .Fa singleUser is omitted, toggle the current single user setting. -.It Fn core.getACPIPresent checkingSystemDefaults -Check whether ACPI is present. -This will only be accurate for i386-compatible loaders, including non-UEFI -loaders on amd64 systems. -If -.Fa checkingSystemDefaults -is true, ignore the current value of -.Ev hint.acpi.0.disabled . -Otherwise, return true only if ACPI is both present and not disabled. +.It Fn core.getACPI +Return true if ACPI is both present and not explicitly disabled by +.Ev hints.acpi.0.disabled . +.It Fn core.hasACPI +Checks whether ACPI support is present. +This requires the loader to probe the system and set +.Ev acpi.rsdp +early before starting the interpreter. .It Fn core.setACPI acpi Sets or unsets .Ev acpi_load , @@ -202,9 +201,6 @@ This checks .Ev boot_serial , and .Ev boot_multicons . -.It Fn core.isSystem386 -Returns true if this bootloader was compiled as an i386 binary. -This generally applies to i386 loaders as well as non-UEFI loaders on amd64. .It Fn core.deepCopyTable tbl Recursively deep copies .Fa tbl diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index 7da03ad9e673..4a948acf8241 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -176,7 +176,7 @@ menu.boot_options = { -- acpi { entry_type = core.MENU_ENTRY, - visible = core.isSystem386, + visible = core.hasACPI, name = function() return OnOff(color.highlight("A") .. "CPI :", core.acpi)