en.wikipedia.org/wiki/Long_mode
2 corrections found
With a computer running UEFI, the UEFI firmware (except CSM and legacy Option ROM), any UEFI boot loader, and the operating system kernel all run in Long mode.
UEFI on x86 is not always 64-bit long mode. Both 32-bit and 64-bit UEFI implementations exist, so UEFI firmware and loaders do not universally run in long mode.
Full reasoning
This sentence overgeneralizes x86 UEFI.
On x86, UEFI exists in both 32-bit (IA-32) and 64-bit (x64) forms. Microsoft’s UEFI FAQ explicitly says: “Microsoft does support both 32 and 64 bit UEFI” and that the OS bitness must match the firmware bitness. That directly contradicts the claim that UEFI firmware and “any UEFI boot loader” all run in long mode.
The Linux kernel documentation also documents booting a 64-bit kernel from 32-bit EFI: protocol 2.13 added support for “booting a 64-bit kernel from 32-bit EFI.” That is further evidence that a UEFI environment on x86 is not inherently long mode.
So the accurate version is narrower: x64 UEFI firmware and x64 UEFI applications run in the x64 UEFI execution environment, but UEFI in general is not synonymous with long mode, because IA-32 UEFI implementations also exist. On systems using IA-32 UEFI, firmware and boot loaders run in 32-bit mode, not long mode; and if a 32-bit OS is booted, its kernel is not in long mode either.
3 sources
- Firmware WEG FAQ - Windows drivers | Microsoft Learn
Microsoft does support both 32 and 64 bit UEFI. The bitness of the OS and the UEFI firmware must match.
- 1. The Linux/x86 Boot Protocol - The Linux Kernel documentation
Protocol 2.13 (Kernel 3.14) Support 32- and 64-bit flags being set in xloadflags to support booting a 64-bit kernel from 32-bit EFI.
- Unified Extensible Firmware Interface (UEFI) Specification 2.11
An application written to this specification may alter the processor execution mode, but the UEFI image must ensure firmware boot services and runtime services are executed with the prescribed execution environment.
Attempting to use addresses falling outside this range will cause a general protection fault.
Non-canonical addresses do not always raise a general-protection fault. Stack references with a non-canonical address raise a stack-segment fault (#SS), not #GP.
Full reasoning
This sentence is too absolute.
In x86-64 long mode, addresses outside the canonical range are invalid, but the resulting exception is not always a general-protection fault. Intel’s Software Developer’s Manual states that in 64-bit mode:
#SS(0)occurs if a memory address referencing the SS segment is in a non-canonical form.#GP(0)occurs if the memory address is in a non-canonical form otherwise.
AMD’s manual says the same thing in different words: a stack reference using a non-canonical address causes #SS, while other non-canonical-address cases can cause #GP.
So the statement is inaccurate because it says all such attempts cause a general-protection fault. A more accurate phrasing would be that using a non-canonical address causes an exception such as #GP or, for stack references, #SS.
2 sources
- Intel® 64 and IA-32 Architectures Software Developer's Manual, Combined Volumes: 1, 2, 3, and 4
64-Bit Mode Exceptions: #SS(0) If a memory address referencing the SS segment is in a non-canonical form. #GP(0) If the memory address is in a non-canonical form.
- AMD64 Architecture Programmer’s Manual, Volume 2: System Programming
Table 8-5 lists “Stack reference using a non-canonical address” under #SS, while Table 8-6 lists non-canonical-address cases under #GP.