History log of /haiku/src/system/boot/platform/bios_ia32/long.cpp
Revision Date Author Comments
# ef894353 16-Sep-2022 David Karoly <karolyd577@gmail.com>

boot/x86: unify KERNEL_LOAD_ADDRESS for BIOS and EFI

Change-Id: Ia3157c7c0908698da94c1aa85cb6366fb00fb7f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5670
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 235aa994 17-Dec-2021 David Karoly <karolyd577@gmail.com>

boot: rework 32-bit/64-bit kernel load base selection

Change-Id: I0aed05c0ef2ff1a162581e4f988bf24ed1e521e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4816
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 1f8a8d2b 02-Oct-2020 Jérôme Duval <jerome.duval@gmail.com>

boot/bios_ia32: basic support la57 aka 5-level paging for x86_64 kernels

la57 kernel support is required. we simply add a 5th level and enable the cr4
feature. the safemode option "256tb_memory_limit" is named after the 4gb one,
but the current support is limited to 512GB as before (this can be later extended).

Change-Id: I922774473c4a6112a0e4ff74162285ad58aa53af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3552
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# 11f8b65a 20-Feb-2020 Jérôme Duval <jerome.duval@gmail.com>

boot_loader: load intel microcode update data file

Previous version of the patch was broken by the EFI refactoring.

Change-Id: I6dd125100b22b2461c531bfd8f81b3dd28e2b751
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2409
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 6f857fa9 23-Mar-2020 waddlesplash <waddlesplash@gmail.com>

Revert "boot_loader: load intel microcode update data file"

This reverts commit a7320593242cc0863fc909c1a32dbd255384d7dd.

It broke the build on most boot platforms (including EFI.)


# a7320593 20-Feb-2020 Jérôme Duval <jerome.duval@gmail.com>

boot_loader: load intel microcode update data file

Change-Id: I323a57cc0b1f05ad7b60b6a141d068a3e618ee4d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2263
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# e9922e77 22-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Fix wrong size of gBootGDT on x86_64.

The BOOT_GDT_SEGMENT_COUNT was based on USER_DATA_SEGMENT on both
x86 and x86_64. However, on x86_64 the order of the segments is
different, leading to a too small gBootGDT array. Move the define to
the arch specific headers so they can be setup correctly in either case.
Also add a STATIC_ASSERT() to check that the descriptors fit into the
array.

Pointed out by CID 1210898.


# b41f2810 06-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: enable sse early

Enable SSE as a part of the "preparation of the environment to run any
C or C++ code" in the entry points of stage2 bootloader.

SSE2 is going to be used by memset() and memcpy().

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# b52b1047 11-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: convert address of previous_debug_output

Together with the previous commit should fix #10535.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# c343f75d 11-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: call debug_cleanup() before preparing mmu data

long_mmu_init() prepares initial paging structures for 64 bit kernel.
Once that function completes bootloader cannot allocate any memory
that needs to be passed to the kernel.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# 527da4ca 27-Jan-2014 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Separate bootloader and kernel GDT and IDT logic

From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.


# 611376fe 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Let each CPU have its own GDT


# 4110b730 01-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Add support for CPUID sub-leaves

Some CPUID leaves may contain one or more sub-leaves accessed by setting
ECX to an appropriate value.


# e818b970 03-Jul-2013 Alex Smith <alex@alex-smith.me.uk>

Call debug_cleanup() before converting kernel_args to 64-bit addresses, fixes #9842.

In debug_cleanup(), if the debug syslog buffer is disabled (the default when
KDEBUG_LEVEL is 0), then a new buffer is allocated with kernel_args_malloc().
This is done after kernel_args addresses have been converted to 64-bit, so
the address the kernel gets will be 32-bit, resulting in the page fault seen
in #9842. Fixed by moving the call to debug_cleanup() to before
convert_kernel_args().


# 9f629ef3 17-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Rename KERNEL_LOAD_BASE_64BIT to KERNEL_LOAD_BASE_64_BIT for consistency.


# 59ae45c1 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed commpage for x86_64.

Since the commpage is at a kernel address, changed 64-bit paging code
to match x86's behaviour of allowing user-accessible mappings to be
created in the kernel portion of the address space. This is also
required by some drivers.


# 76a1175d 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support for SMP on x86_64.

No major changes to the kernel: just compiled in arch_smp.cpp and fixed the
IDT load in arch_cpu_init_percpu to use the correct limit for x86_64 (uses
sizeof(interrupt_descriptor)). In the boot loader, changed smp_boot_other_cpus
to construct a temporary GDT and get the page directory address from CR3, as
what's in kernel_args will be 64-bit stuff and will not work to switch the
CPUs into 32-bit mode in the trampoline code. Refactored 64-bit kernel entry
code to not use the stack after disabling paging, as the secondary CPUs are
given a 32-bit virtual stack address by the SMP trampoline code which will
no longer work.


# 93cba1da 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed a bug resulting from a mistake in the boot 64-bit paging setup.

This was an interesting bug to find. Was getting spurious triple faults
in the slab allocator. The problem was that the boot paging setup code
was mapping all page tables it created into the virtual address space,
but in the kernel no areas were being created to cover them, so during
arch_vm_init_end() the pages for them ended up being freed and then
overwritten later on. Fixed by unmapping page tables after populating
them in long_mmu_init().


# 15feb603 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 0da10c8b 05-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Some fixes to the long mode switch code.

* Wasn't storing the fixed virtual address of the PML4 in kernel_args.
* After switching to long mode, reload GDTR with the virtual address of
the GDT. This was working fine until now because the physical address
was identity mapped, but broke as soon as I removed the identity
mapping.


# a8f85e6e 04-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Removed accidently left in debug message.


# e70dd7e0 04-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Map all physical memory in the long mode paging setup.

Since x86_64 has such a large virtual address space all available physical
memory can be mapped in to it. The physical page mapper implementation for
x86_64 will use this mapping. Also changed the mapping code to map kernel
pages with the global flag.


# 0897e314 02-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Merged x86_64 headers into x86 headers.

Not many changes seeing as there's not much x86_64 stuff done yet. Small
differences are handled with ifdefs, large differences (descriptors.h,
struct iframe) have separate headers under arch/x86/32 and arch/x86/64.


# 0705884a 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Style fixes.


# c9f6d227 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

x86_64: Implemented exception handling.


# 3403f23e 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Moved the common parts of arch_cpu.h between x86 and x86_64 to arch/common_x86/cpu.h.


# 3f017e90 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Also need to fix the kernel_args_range addresses.


# 991e5bee 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Pass correct kernel_args address to the kernel.


# e5fc2bfc 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented long mode setup/switch code, the bootloader can now start the 64-bit kernel!

The setup procedure is fairly simple: create a 64-bit GDT and 64-bit page
tables that include all kernel mappings from the 32-bit address space, but at
the correct 64-bit address, then go through kernel_args and changes all virtual
addresses to 64-bit addresses, and finally switch to long mode and jump to the
kernel.


# e9922e775f2fbbffa4847ae797e5349542948f25 22-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Fix wrong size of gBootGDT on x86_64.

The BOOT_GDT_SEGMENT_COUNT was based on USER_DATA_SEGMENT on both
x86 and x86_64. However, on x86_64 the order of the segments is
different, leading to a too small gBootGDT array. Move the define to
the arch specific headers so they can be setup correctly in either case.
Also add a STATIC_ASSERT() to check that the descriptors fit into the
array.

Pointed out by CID 1210898.


# b41f281071b84235ea911f1e02123692798f706d 06-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: enable sse early

Enable SSE as a part of the "preparation of the environment to run any
C or C++ code" in the entry points of stage2 bootloader.

SSE2 is going to be used by memset() and memcpy().

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# b52b1047983e703a1d1c6691ec9ad9f13574bdc1 11-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: convert address of previous_debug_output

Together with the previous commit should fix #10535.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# c343f75d76653c4daaf630e4b288cec47d20de94 11-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

boot/x86_64: call debug_cleanup() before preparing mmu data

long_mmu_init() prepares initial paging structures for 64 bit kernel.
Once that function completes bootloader cannot allocate any memory
that needs to be passed to the kernel.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>


# 527da4ca8a4c008b58da456c01a49dcf16a98fbc 27-Jan-2014 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Separate bootloader and kernel GDT and IDT logic

From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.


# 611376fef7e00967fb65342802ba668a807348d5 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Let each CPU have its own GDT


# 4110b730dbee59f5515a0bf9997b6cd167965080 01-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Add support for CPUID sub-leaves

Some CPUID leaves may contain one or more sub-leaves accessed by setting
ECX to an appropriate value.


# e818b9707ca1fd3c3c019176fae62ef99e46de30 03-Jul-2013 Alex Smith <alex@alex-smith.me.uk>

Call debug_cleanup() before converting kernel_args to 64-bit addresses, fixes #9842.

In debug_cleanup(), if the debug syslog buffer is disabled (the default when
KDEBUG_LEVEL is 0), then a new buffer is allocated with kernel_args_malloc().
This is done after kernel_args addresses have been converted to 64-bit, so
the address the kernel gets will be 32-bit, resulting in the page fault seen
in #9842. Fixed by moving the call to debug_cleanup() to before
convert_kernel_args().


# 9f629ef38e6655e1509dca6db587a2035243ccdb 17-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Rename KERNEL_LOAD_BASE_64BIT to KERNEL_LOAD_BASE_64_BIT for consistency.


# 59ae45c1ab32476f1fa428dae22989f8387a1f9e 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed commpage for x86_64.

Since the commpage is at a kernel address, changed 64-bit paging code
to match x86's behaviour of allowing user-accessible mappings to be
created in the kernel portion of the address space. This is also
required by some drivers.


# 76a1175dbe1a314563ca18c0b7fb82695a9730cd 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support for SMP on x86_64.

No major changes to the kernel: just compiled in arch_smp.cpp and fixed the
IDT load in arch_cpu_init_percpu to use the correct limit for x86_64 (uses
sizeof(interrupt_descriptor)). In the boot loader, changed smp_boot_other_cpus
to construct a temporary GDT and get the page directory address from CR3, as
what's in kernel_args will be 64-bit stuff and will not work to switch the
CPUs into 32-bit mode in the trampoline code. Refactored 64-bit kernel entry
code to not use the stack after disabling paging, as the secondary CPUs are
given a 32-bit virtual stack address by the SMP trampoline code which will
no longer work.


# 93cba1da96275eb617fcdc581ec4522e0b107adf 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed a bug resulting from a mistake in the boot 64-bit paging setup.

This was an interesting bug to find. Was getting spurious triple faults
in the slab allocator. The problem was that the boot paging setup code
was mapping all page tables it created into the virtual address space,
but in the kernel no areas were being created to cover them, so during
arch_vm_init_end() the pages for them ended up being freed and then
overwritten later on. Fixed by unmapping page tables after populating
them in long_mmu_init().


# 15feb60325be086823e80a3468f7aab2bfbc9f7d 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 0da10c8b51f9ec443a53873b37d07fab30a5734e 05-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Some fixes to the long mode switch code.

* Wasn't storing the fixed virtual address of the PML4 in kernel_args.
* After switching to long mode, reload GDTR with the virtual address of
the GDT. This was working fine until now because the physical address
was identity mapped, but broke as soon as I removed the identity
mapping.


# a8f85e6e48ec38ad16d9e1289f031e696220367e 04-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Removed accidently left in debug message.


# e70dd7e0af671e37378d68c241a081ebeaf8f659 04-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Map all physical memory in the long mode paging setup.

Since x86_64 has such a large virtual address space all available physical
memory can be mapped in to it. The physical page mapper implementation for
x86_64 will use this mapping. Also changed the mapping code to map kernel
pages with the global flag.


# 0897e314b79d09b04349d3cfe6093a3fd6220da1 02-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Merged x86_64 headers into x86 headers.

Not many changes seeing as there's not much x86_64 stuff done yet. Small
differences are handled with ifdefs, large differences (descriptors.h,
struct iframe) have separate headers under arch/x86/32 and arch/x86/64.


# 0705884ac415022fb9c734da089fe3dd5a06873a 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Style fixes.


# c9f6d2271fc105de01b1359d66c5304c75bd396d 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

x86_64: Implemented exception handling.


# 3403f23e81b7bd6e50c459d01ae7238c1f3f5984 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Moved the common parts of arch_cpu.h between x86 and x86_64 to arch/common_x86/cpu.h.


# 3f017e90611b6b53186f72bd9f6aa837d15e588a 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Also need to fix the kernel_args_range addresses.


# 991e5bee90ffd98a39f012f6ce4e0740eb620073 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Pass correct kernel_args address to the kernel.


# e5fc2bfcab8c15a3ff7d33c358f9aa82ed73c823 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented long mode setup/switch code, the bootloader can now start the 64-bit kernel!

The setup procedure is fairly simple: create a 64-bit GDT and 64-bit page
tables that include all kernel mappings from the 32-bit address space, but at
the correct 64-bit address, then go through kernel_args and changes all virtual
addresses to 64-bit addresses, and finally switch to long mode and jump to the
kernel.