History log of /haiku/src/system/kernel/arch/x86/64/arch.S
Revision Date Author Comments
# 4f0173cd 27-Sep-2023 Puck Meerburg <puck@puckipedia.com>

kernel/x86_64: align the stack before calling the function

in arch_debug_call_with_fault_handler

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


# 94951269 05-May-2020 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86_64: AVX support

xsave or xsavec are supported.
breaks vregs compatibility.
change the thread structure object cache alignment to 64
the xsave fpu_state size isn't defined, it is for instance 832 here, thus I picked 1024.

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


# 513403d4 14-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert team and thread changes for COMPAT_MODE (hrev52010 & hrev52011).

This reverts commit c558f9c8fe54bc14515aa62bac7826271289f0e4.
This reverts commit 44f24718b1505e8d9c75e00e59f2f471a79b5f56.
This reverts commit a69cb330301c4d697daae57e6019a307f285043e.
This reverts commit 951182620e297d10af7fdcfe32f2b04d56086ae9.

There have been multiple reports that these changes break mounting NTFS partitions
(on all systems, see #14204), and shutting down (on certain systems, see #12405.)
Until they can be fixed, they are being backed out.


# 44f24718 20-May-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86_64: add compatibility source files to the build.

* add x86 versions of fnsave frstor.
* add missing declaration for elf32_resolve_symbol().

How-to build a x86_64/x86 bootstrap build:
mkdir generated_bootstrap; cd generated_bootstrap
../configure --bootstrap /dir/to/haikuporter/haikuporter /dir/to/haikuports.cross \
/dir/to/haikuports --build-cross-tools x86_64 /dir/to/buildtools --build-cross-tools x86 -j8 --use-gcc-pipe
jam -q -sHAIKU_PORTER_EXTRA_OPTIONS="-j8 --sourceforge-mirror=freefr --no-source-packages" @bootstrap-raw

Change-Id: I6eae3653c42a53683ae307107fae595c4b8ebcfb


# 9dd4d2dd 03-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: support for Intel SMAP and SMEP on x86_64.

SMAP will generated page faults when the kernel tries to access user pages unless overriden.
If SMAP is enabled, the override instructions are written where needed in memory with
binary "altcodepatches".
Support is enabled by default, might be disabled per safemode setting.

Change-Id: Ife26cd765056aeaf65b2ffa3cadd0dcf4e273a96


# 95e97463 14-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel: add generic wrapper for accessing user memory

This patch adds user_access() which can be used to gracefully handle
page faults that may happen when accessing user memory. It is used
by arch_cpu_user{memcpy, memset, strlcpy}() to allow using optimized
functions from the standard library.

Currently only x64 uses this, but nothing really is arch specific here.

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


# 396b7422 10-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel/x86_64: save fpu state at interrupts

The kernel is allowed to use fpu anywhere so we must make sure that
user state is not clobbered by saving fpu state at interrupt entry.
There is no need to do that in case of system calls since all fpu
data registers are caller saved.

We do not need, though, to save the whole fpu state at task swich
(again, thanks to calling convention). Only status and control
registers are preserved. This patch actually adds xmm0-15 register
to clobber list of task swich code, but the only reason of that is
to make sure that nothing bad happens inside the function that
executes that task swich. Inspection of the generated code shows
that no xmm registers are actually saved.

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


# 4b75a1e2 25-Aug-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel/x86_64: implement x86_swap_pgdir in C++

No reason not to inline this function.

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


# 76636769 06-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

kernel/x86_64: inline x86_{read, write}_msr()

This patch makes it possible to inline rdmsr and wrmsr instruction. The
performance impact shouldn't be significant since they are used relatively
rarely and wrmsr is usually a serializing instruction, but there is no reason
not to do so.


# 88e8e24c 06-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

kernel/x86_64: improve context switch implementation

The goal of this patch is to amortize the cost of context switch by making
the compiler aware that context switch clobbers all registers. Because all
register need to be saved anyway there is no additional cost of using
callee saved register in the function that does the context switch.


# 1b17f7ab 05-May-2013 Rene Gollent <anevilyak@gmail.com>

Fix x86-64 build.


# 5af6169b 05-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

x86[-64]: Fix arch_cpu_user_strlcpy() for small buffers

The case for small buffers was broken, since scasb operates on edi/rdi,
not esi/rsi.


# bcbf22a3 05-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

x86[-64]: Fix arch_cpu_user_strlcpy() for small buffers

The case for small buffers was broken, since scasb operates on edi/rdi,
not esi/rsi.


# 211f7132 06-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: move x86_userspace_thread_exit() from user stack to commpage

x86_userspace_thread_exit() is a stub originally placed at the bottom of
each thread user stack that ensures any thread invokes exit_thread() upon
returning from its main higher level function.

Putting anything that is expected to be executed on a stack causes problems
when implementing data execution prevention. Code of x86_userspace_thread_exit()
is now moved to commpage which seems to be much more appropriate place for it.


# 370ab57d 23-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Initial userland support for x86_64.

Userland switch is implemented, as is basic system call support (using
SYSCALL/SYSRET). The system call handler is not yet complete: it doesn't
handle more than 6 arguments, and does not perform all the necessary kernel
entry/exit work (neither does the interrupt handler). However, this is
sufficient for runtime_loader to start and print some debug output.


# b2cd72d8 14-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented arch_debug_call_with_fault_handler for x86_64.


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

Implemented arch_cpu_user_*() for x86_64, based on the x86 versions.


# b5c9d24a 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented threading for x86_64.

* Thread creation and switching is working fine, however threads do not yet
get interrupted because I've not implemented hardware interrupt handling
yet (I'll do that next).
* I've made some changes to struct iframe: I've removed the e/r prefixes
from the member names for both 32/64, so now they're just named ip, ax,
bp, etc. This makes it easier to write code that works with both 32/64
without having to deal with different iframe member names.


# 898b29e3 05-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Added temporary stack trace function to x86_64.

Will be merged with the x86 one later on. Requires -fno-omit-frame-pointer on
the kernel build flags, GCC defaults to not generating stack frames on x86_64.


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

Added arch_cpu.cpp to the x86_64 build.

* Some things are currently ifndef'd out completely for x86_64 because
they aren't implemented, there's a few other ifdef's to handle x86_64
differences but most of the code works unchanged.
* Renamed some i386_* functions to x86_*.
* Added a temporary method for setting the current thread on x86_64
(a global variable, not SMP safe). This will be changed to be done
via the GS segment but I've not implemented that yet.


# 95e97463d265c9f4a6e43265ef0f1f63a0825b21 14-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel: add generic wrapper for accessing user memory

This patch adds user_access() which can be used to gracefully handle
page faults that may happen when accessing user memory. It is used
by arch_cpu_user{memcpy, memset, strlcpy}() to allow using optimized
functions from the standard library.

Currently only x64 uses this, but nothing really is arch specific here.

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


# 396b74228eefcf4bc21333e05c1909b8692d1b86 10-Sep-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel/x86_64: save fpu state at interrupts

The kernel is allowed to use fpu anywhere so we must make sure that
user state is not clobbered by saving fpu state at interrupt entry.
There is no need to do that in case of system calls since all fpu
data registers are caller saved.

We do not need, though, to save the whole fpu state at task swich
(again, thanks to calling convention). Only status and control
registers are preserved. This patch actually adds xmm0-15 register
to clobber list of task swich code, but the only reason of that is
to make sure that nothing bad happens inside the function that
executes that task swich. Inspection of the generated code shows
that no xmm registers are actually saved.

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


# 4b75a1e2377d5380d6bea4319fc8f1bc2f595665 25-Aug-2014 Paweł Dziepak <pdziepak@quarnos.org>

kernel/x86_64: implement x86_swap_pgdir in C++

No reason not to inline this function.

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


# 76636769bd9a53acbf21bbfd411f731d2ab51e49 06-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

kernel/x86_64: inline x86_{read, write}_msr()

This patch makes it possible to inline rdmsr and wrmsr instruction. The
performance impact shouldn't be significant since they are used relatively
rarely and wrmsr is usually a serializing instruction, but there is no reason
not to do so.


# 88e8e24c84aded0ff085aa93402c71862c5e4fe0 06-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

kernel/x86_64: improve context switch implementation

The goal of this patch is to amortize the cost of context switch by making
the compiler aware that context switch clobbers all registers. Because all
register need to be saved anyway there is no additional cost of using
callee saved register in the function that does the context switch.


# 1b17f7ab00ea450c315029358c4eedb166f47c79 05-May-2013 Rene Gollent <anevilyak@gmail.com>

Fix x86-64 build.


# 5af6169bb2afb3dd70839d2439802ba10999e35c 05-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

x86[-64]: Fix arch_cpu_user_strlcpy() for small buffers

The case for small buffers was broken, since scasb operates on edi/rdi,
not esi/rsi.


# bcbf22a316baf9c159b286ca774b27b21102b53f 05-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

x86[-64]: Fix arch_cpu_user_strlcpy() for small buffers

The case for small buffers was broken, since scasb operates on edi/rdi,
not esi/rsi.


# 211f71325a1c2c1f3c7d0efabe01506144fcd6ba 06-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: move x86_userspace_thread_exit() from user stack to commpage

x86_userspace_thread_exit() is a stub originally placed at the bottom of
each thread user stack that ensures any thread invokes exit_thread() upon
returning from its main higher level function.

Putting anything that is expected to be executed on a stack causes problems
when implementing data execution prevention. Code of x86_userspace_thread_exit()
is now moved to commpage which seems to be much more appropriate place for it.


# 370ab57d49a208f79ce3c5e9f92be13b58c48f18 23-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Initial userland support for x86_64.

Userland switch is implemented, as is basic system call support (using
SYSCALL/SYSRET). The system call handler is not yet complete: it doesn't
handle more than 6 arguments, and does not perform all the necessary kernel
entry/exit work (neither does the interrupt handler). However, this is
sufficient for runtime_loader to start and print some debug output.


# b2cd72d8f3c4a3710fdbaf36802de3d6e74a4066 14-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented arch_debug_call_with_fault_handler for x86_64.


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

Implemented arch_cpu_user_*() for x86_64, based on the x86 versions.


# b5c9d24abcc3599375153ed310b495ea944d46a0 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented threading for x86_64.

* Thread creation and switching is working fine, however threads do not yet
get interrupted because I've not implemented hardware interrupt handling
yet (I'll do that next).
* I've made some changes to struct iframe: I've removed the e/r prefixes
from the member names for both 32/64, so now they're just named ip, ax,
bp, etc. This makes it easier to write code that works with both 32/64
without having to deal with different iframe member names.


# 898b29e3628ba9252c527e6296b88cf71d37b863 05-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Added temporary stack trace function to x86_64.

Will be merged with the x86 one later on. Requires -fno-omit-frame-pointer on
the kernel build flags, GCC defaults to not generating stack frames on x86_64.


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

Added arch_cpu.cpp to the x86_64 build.

* Some things are currently ifndef'd out completely for x86_64 because
they aren't implemented, there's a few other ifdef's to handle x86_64
differences but most of the code works unchanged.
* Renamed some i386_* functions to x86_*.
* Added a temporary method for setting the current thread on x86_64
(a global variable, not SMP safe). This will be changed to be done
via the GS segment but I've not implemented that yet.