"poweroff" does not automatically power off the system when EFI is used. Instead, the machine just halts buts remains running. I tested this with VirtualBox EFI guests (FreeBSD 14.0-RELEASE) using ICH9 chipset; the issue is reproducible and occurs always. https://forums.freebsd.org/threads/efi-virtualbox-computer-non-stop-after-successful-shutdown-of-freebsd.84856/ suggests to change sysctl hw.efi.poweroff=0, which is 1 by default. This indeed fixes the issue.
Created attachment 248895 [details] Screenshot after "poweroff"
nornetpp@burgsteinfurt:~ $ uname -a FreeBSD burgsteinfurt.openstack 14.0-RELEASE-p5 FreeBSD 14.0-RELEASE-p5 #0: Tue Feb 13 23:37:36 UTC 2024 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 nornetpp@burgsteinfurt:~ $ sysctl hw.acpi hw.acpi.acline: 1 hw.acpi.battery.info_expire: 5 hw.acpi.battery.units: 1 hw.acpi.battery.state: 0 hw.acpi.battery.rate: 0 hw.acpi.battery.time: -1 hw.acpi.battery.life: 100 hw.acpi.cpu.cx_lowest: C1 hw.acpi.cpu.cppc_notify: 1 hw.acpi.reset_video: 0 hw.acpi.handle_reboot: 1 hw.acpi.disable_on_reboot: 0 hw.acpi.verbose: 0 hw.acpi.s4bios: 0 hw.acpi.sleep_delay: 1 hw.acpi.suspend_state: NONE hw.acpi.standby_state: NONE hw.acpi.lid_switch_state: NONE hw.acpi.sleep_button_state: NONE hw.acpi.power_button_state: S5 hw.acpi.supported_sleep_state: S5 nornetpp@burgsteinfurt:~ $ sudo sysctl hw.efi hw.efi.poweroff: 1 (This is the default setting => the issue occurs in this case)
The issue is reproducible with a FreeBSD 13.2 machine as well.
This may be already addressed by e4ab361e53945a6c3e9d68c5e5ffc11de40a35f2 in main and MFC-ed to 14-stable. Can you try latest main or stable? See https://cgit.freebsd.org/src/commit/sys/kern/kern_shutdown.c?id=e4ab361e53945a6c3e9d68c5e5ffc11de40a35f2
I tried 14.0-STABLE (202040229, i.e. the currently latest ISO available: https://download.freebsd.org/snapshots/amd64/amd64/ISO-IMAGES/14.0/FreeBSD-14.0-STABLE-amd64-20240229-d19769300126-266911-disc1.iso): hw.efi.poweroff=1 (the default) => no success, the machine remains running. hw.efi.poweroff=0 => the machine shuts down as intended.
What is a value of hw.acpi.handle_reboot? Added avg@, may be he can help.
hw.acpi.handle_reboot: 1
Seems it is virtualbox-specific. I'll test it under bhyve and hyper-v and report it back.
When hw.efi.poweroff=1, EFI shutdown routine is invoked much earlier than ACPI, so ACPI has no play. It seems that the system hangs in the EFI routine instead of powering off. So it must be a problem with the EFI implementation or something like that. FreeBSD EFI shutdown code is extremely simple: if ((howto & RB_POWEROFF) != 0 && efi_poweroff) (void)efi_reset_system(EFI_RESET_SHUTDOWN);
I cannot reproduce it with latest current and stable under both bhyve and hyper-v. So apparently avg@ is right.
While the issue occurs under VirtualBox, it does not occur under Proxmox. That is, under Proxmox, "poweroff" works fine with the default setting hw.efi.poweroff=1. This reproducibly fails under VirtualBox. Proxmox is using OVMF UEFI firmware. VirtualBox seems to use this as well, but may be with some differences.
I created a bug ticket for VirtualBox: https://www.virtualbox.org/ticket/22021
On Fri Mar 8 14:17:54 2024 UTC, thomas.dreibholz@gmail.com wrote: > I created a bug ticket for VirtualBox: https://www.virtualbox.org/ticket/22021 Thomas, can this FreeBSD bug be closed?
The bug is very likely an issue of VirtualBox. But may be FreeBSD could check whether the EFI shutdown call failed to shut down the system, to perform a fallback solution? This could possibly also help in case of problematic EFI implementations on other systems. Alternatively, it may be helpful to document the VirtualBox behaviour somewhere, to that users just set hw.efi.poweroff=0 as work-around.
(In reply to Thomas Dreibholz from comment #14) I think port's pkg-message is a right place.
FreeBSD is the guest system in VirtualBox. It does not have any VirtualBox guest utilities port installed when the issue occurs. I only tried Linux as VirtualBox host, yet. I useful place for some documentation around VirtualBox and hw.efi.poweroff may be https://docs.freebsd.org/en/books/handbook/virtualization/#virtualization-guest-virtualbox .
Maybe add to <https://wiki.freebsd.org/VirtualBox> in the meantime.
I ran into this issue on actual hardware. The motherboard is an Asus M5A99FX Pro 2.0, running an AMD FX-8350. I'm running Xigmanas 13.3.0.5 - Hesterion (revision 10153), which is based on FreeBSD 13.3-RELEASE-p4. It is an older board, and it was the first implementation of UEFI that I had ever run across. Since the ICH9 seems to be an older chipset and Virtualbox is using that, maybe older version of UEFI is what is causing this? I was able to verify that the workaround of sysctl hw.efi.poweroff=0 solved the problem in this case as well.