History log of /haiku/src/system/kernel/arch/x86/32/thread.cpp
Revision Date Author Comments
# bc5570ae 04-Jun-2021 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86: set initial user thread IOPL to zero

User threads aren't supposed to be able to adjust the interrupt flag (IF). A few
apps for instance DOSBox would just use the popf instruction and disable the
flag, expecting the change to be ignored.

Quote from the Intel manual:
"The interrupt flag (IF) is altered only when executing at a level at least as
privileged as the IOPL. If a POPF/POPFD instruction is executed with
insufficient privilege, an exception does not occur, but the privileged bits
do not change."

fix #14711

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


# d9b9a94c 01-Jun-2021 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86: disable trap and direction flag on signal handler entry

https://github.com/freebsd/freebsd-src/commit/846ac2266b625d13ce6d1fc9370c3c3cc2a960bb
https://github.com/freebsd/freebsd-src/commit/22eca0bf45fa506e27a58007cfc70f08ce4f3538
Change-Id: I19620d15372572ce4498d9145fd6b0df50f91bb9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4043
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 9046835d 18-Feb-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Patch by Ingo Weinhold: fix stack alignment on x86.

This is required to use some SSE instructions, which are generated by
gcc 4.8, most notably when compiling WebKit code (but it may happen
elsewhere as well).

Fixes about 900 crashes and 10000 test failures in WebKit, so this must
be working. Fixes #10509 for x86.


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

x86: Let each CPU have its own GDT


# afaa6ed4 21-Sep-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Randomize initial stack pointer on alternative signal stacks

If the alternate signal stack is used randomize the initial stack
pointer in the same way it is randomized on "normal" thread stacks.
Also, update MINSIGSTKSZ value so that regardless of where the new
stack pointer points to there is at least 4k of stack left.


# 84bb91df 16-Apr-2013 Pawel Dziepak <pdziepak@quarnos.org>

arch: use PRNGs from kernel utils for initializing stack pointer


# e85e399f 17-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

commpage: randomize position of commpage

This patch introduces randomization of commpage position. From now on commpage
table contains offsets from begining to of the commpage to the particular
commpage entry. Similary addresses of symbols in ELF memory image "commpage"
are just offsets from the begining of the commpage.

This patch also updates KDL so that commpage entries are recognized and shown
correctly in stack trace. An update of Debugger is yet to be done.


# 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.


# 3b4269ec 24-Feb-2013 Pawel Dziepak <pdziepak@quarnos.org>

arch: randomize initial user stack pointer

Inside the page randomization of initial user stack pointer is not only a part
of ASLR implementation but also a performance improvement that helps
eliminating aligned 64 kB data access.

Minimal user stack size is increased to 8 kB in order to ensure that regardless
of initial stack pointer value there is still enough space on stack.


# d2a1be1c 18-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Cleaner separation of 32-/64-bit specific CPU/interrupt code.

Renamed {32,64}/int.cpp to {32,64}/descriptors.cpp, which now contain
functions for GDT and TSS setup that were previously in arch_cpu.cpp,
as well as the IDT setup code. These get called from the init functions
in arch_cpu.cpp, rather than having a bunch of ifdef'd chunks of code
for 32/64.


# c0d28c01 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented signals for x86_64.


# 03add8e7 29-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented TLS for x86_64.


# 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.


# 9046835de9260baab79fa1422096bf0f1a9509ca 18-Feb-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Patch by Ingo Weinhold: fix stack alignment on x86.

This is required to use some SSE instructions, which are generated by
gcc 4.8, most notably when compiling WebKit code (but it may happen
elsewhere as well).

Fixes about 900 crashes and 10000 test failures in WebKit, so this must
be working. Fixes #10509 for x86.


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

x86: Let each CPU have its own GDT


# afaa6ed4b37c519afd3f593509fd490082d7b8d2 21-Sep-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Randomize initial stack pointer on alternative signal stacks

If the alternate signal stack is used randomize the initial stack
pointer in the same way it is randomized on "normal" thread stacks.
Also, update MINSIGSTKSZ value so that regardless of where the new
stack pointer points to there is at least 4k of stack left.


# 84bb91df8324ff0fd40cb893de9c74b79f4f0d5e 16-Apr-2013 Pawel Dziepak <pdziepak@quarnos.org>

arch: use PRNGs from kernel utils for initializing stack pointer


# e85e399fd7b229b8bc92f28928a059876d7216d3 17-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

commpage: randomize position of commpage

This patch introduces randomization of commpage position. From now on commpage
table contains offsets from begining to of the commpage to the particular
commpage entry. Similary addresses of symbols in ELF memory image "commpage"
are just offsets from the begining of the commpage.

This patch also updates KDL so that commpage entries are recognized and shown
correctly in stack trace. An update of Debugger is yet to be done.


# 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.


# 3b4269ecf59fa0a994ecf20ec3472e02184f9328 24-Feb-2013 Pawel Dziepak <pdziepak@quarnos.org>

arch: randomize initial user stack pointer

Inside the page randomization of initial user stack pointer is not only a part
of ASLR implementation but also a performance improvement that helps
eliminating aligned 64 kB data access.

Minimal user stack size is increased to 8 kB in order to ensure that regardless
of initial stack pointer value there is still enough space on stack.


# d2a1be1c4e4a8ae3879d7f59b07a6924c62b4b14 18-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Cleaner separation of 32-/64-bit specific CPU/interrupt code.

Renamed {32,64}/int.cpp to {32,64}/descriptors.cpp, which now contain
functions for GDT and TSS setup that were previously in arch_cpu.cpp,
as well as the IDT setup code. These get called from the init functions
in arch_cpu.cpp, rather than having a bunch of ifdef'd chunks of code
for 32/64.


# c0d28c01990d8815dddc645177f44b9ce361d186 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented signals for x86_64.


# 03add8e7c216a9ba83a2c565cb82962d6cdc53c4 29-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented TLS for x86_64.


# 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.