#
1.17 |
|
05-Jun-2018 |
guenther |
Switch from lazy FPU switching to semi-eager FPU switching: track whether curproc's xstate ("extended state") is loaded in the CPU or not. - context switch, sendsig(), vmm, and doing CPU crypto in the kernel all check the flag and, if set, save the old thread's state to the PCB, clear the flag, and then load the _blank_ state - when returning to userspace, if the flag is clear then set it and restore the thread's state
This simpler tracking also fixes the restoring of FPU state after nested signal handlers.
With this, %cr0's TS flag is never set, the FPU #DNA trap can no longer happen, and IPIs are no longer necessary for flushing or syncing FPU state; on the other hand, restoring xstate while returning to userspace means we have to handle xrstor faulting if we could be loading an altered state. If that happens, reset the state, fake a #GP fault (SIGBUS), and recheck for ASTs.
While here, regularize fxsave/fxrstor vs xsave/xrstor handling, by using codepatching to switch to xsave/xrstor when present in the CPU. In addition, code patch in use of xsaveopt in most places when the CPU supports that. Use the 64bit-wide variants of the instructions in all cases so that x87 instruction fault IPs are reported correctly.
This change has three motivations: 1) with modern clang, SSE registers are used even in rcrt0.o, making lazy FPU switching a smaller benefit vs trap costs 2) the Intel SDM warns that lazy FPU switching may increase power costs 3) post-Spectre rumors suggest that the %cr0 TS flag might not block speculation, permitting leaking of information about FPU state (AES keys?) across protection boundaries.
tested by many in snaps; prodding from deraadt@
|
Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
|
#
1.16 |
|
26-Apr-2017 |
mlarkin |
branches: 1.16.2; 1.16.4; Fix a typo relating to savefpu alignment
ok kettenis
|
Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
|
#
1.15 |
|
03-Apr-2016 |
guenther |
Move the setting of pcb_fsbase out of reset_segs() into its callers
ok mpi@
|
Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
|
#
1.14 |
|
18-May-2015 |
guenther |
Do lazy update/reset of the FS.base and %[def]s segment registers: reseting segment registers in cpu_switchto if the old thread had made it to userspace and restoring FS.base only on first return to userspace since context switch.
ok mlarkin@
|
#
1.13 |
|
05-May-2015 |
guenther |
emul_native is only used for kernel threads which can't dump core, so delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump, and various #includes that are superfluous.
This leaves compat_linux processes without a coredump callback. If that ability is desired, someone should update it to use coredump_elf32() and verify the results...
ok kettenis@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
|
#
1.12 |
|
10-Jul-2011 |
deraadt |
remove irrelevant comments
|
#
1.11 |
|
13-Apr-2011 |
guenther |
Unrevert the FS.base diff: the issues were actually elsewhere Additional testing by jasper@ and pea@
|
#
1.10 |
|
10-Apr-2011 |
guenther |
Revert bulk of the FS.base diff, as it causes issues on some machines and the problem isn't obvious yet.
|
#
1.9 |
|
05-Apr-2011 |
guenther |
Add support for per-rthread base-offset for the %fs selector on amd64. Add pcb_fsbase to the PCB for tracking what the value for the thread is, and ci_cur_fsbase to struct cpu_info for tracking the CPU's current value for FS.base, then on return to user-space, skip the setting if the CPU has the right value already. Non-threaded processes without TLS leave FS.base zero, which can be conveniently optimized: setting %fs zeros FS.base for fewer cycles than wrmsr.
ok kettenis@
|
#
1.8 |
|
23-Mar-2011 |
pirofti |
Normalize sentinel. Use _MACHINE_*_H_ and _<ARCH>_*_H_ properly and consitently.
Discussed and okay drahn@. Okay deraadt@.
|
Revision tags: OPENBSD_4_9_BASE
|
#
1.7 |
|
13-Nov-2010 |
guenther |
Switch from TSS-per-process to TSS-per-CPU, placing the TSS right next to the cpu's GDT, also making the double-fault stack per-CPU, leaving it at the top of the page of the CPU's idle process. Inline pmap_activate() and pmap_deactivate() into the asm cpu_switchto routine, adding a check for the new pmap already being marked as active on the CPU. Garbage collect the hasn't-been-used-in-years GDT update IPI.
Tested by many; ok mikeb@, kettenis@
|
#
1.6 |
|
26-Oct-2010 |
guenther |
The LDT is only used by dead compat code now, so load the ldt register with the null selector (disabling use of it), stop reloading it on every context switch, and blow away the table itself, as well as the pcb and pmap bits that were used to track it. Also, delete two other unused pcb members: pcb_usersp and pcb_flags. (Deleting pcb_usersp also keeps the pcb_savefpu member aligned properly.) Finally, delete the defines for the unimplemented AMD64_{GET,SET}_LDT sysarch() calls.
Tested by various with both AMD and Intel chips ok mikeb@
|
Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
|
#
1.5 |
|
26-Jun-2008 |
ray |
First pass at removing clauses 3 and 4 from NetBSD licenses.
Not sure what's more surprising: how long it took for NetBSD to catch up to the rest of the BSDs (including UCB), or the amount of code that NetBSD has claimed for itself without attributing to the actual authors.
OK deraadt@
|
#
1.4 |
|
23-May-2008 |
jasper |
- remove USER_LDT, it was never in a state where it would copile, nor will we support i386-compat mode on amd64.
agreed by beck@, dlg@, kettenis@ ok deraadt@, tom@
|
Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
|
#
1.3 |
|
10-May-2006 |
krw |
Missing $OpenBSD$ tags.
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.2 |
|
13-Dec-2005 |
jsg |
Remove the advertising clause in the UCB license which Berkeley rescinded 22 July 1999. Checked by ian@, deraadt@ and millert@, arm portion checked by drahn@
|
Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
|
#
1.1 |
|
28-Jan-2004 |
mickey |
an amd64 arch support. hacked by art@ from netbsd sources and then later debugged by me into the shape where it can host itself. no bootloader yet as needs redoing from the recent advanced i386 sources (anyone? ;)
|
Revision tags: OPENBSD_6_2_BASE
|
#
1.16 |
|
26-Apr-2017 |
mlarkin |
Fix a typo relating to savefpu alignment
ok kettenis
|
Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
|
#
1.15 |
|
03-Apr-2016 |
guenther |
Move the setting of pcb_fsbase out of reset_segs() into its callers
ok mpi@
|
Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
|
#
1.14 |
|
18-May-2015 |
guenther |
Do lazy update/reset of the FS.base and %[def]s segment registers: reseting segment registers in cpu_switchto if the old thread had made it to userspace and restoring FS.base only on first return to userspace since context switch.
ok mlarkin@
|
#
1.13 |
|
05-May-2015 |
guenther |
emul_native is only used for kernel threads which can't dump core, so delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump, and various #includes that are superfluous.
This leaves compat_linux processes without a coredump callback. If that ability is desired, someone should update it to use coredump_elf32() and verify the results...
ok kettenis@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
|
#
1.12 |
|
10-Jul-2011 |
deraadt |
remove irrelevant comments
|
#
1.11 |
|
13-Apr-2011 |
guenther |
Unrevert the FS.base diff: the issues were actually elsewhere Additional testing by jasper@ and pea@
|
#
1.10 |
|
10-Apr-2011 |
guenther |
Revert bulk of the FS.base diff, as it causes issues on some machines and the problem isn't obvious yet.
|
#
1.9 |
|
05-Apr-2011 |
guenther |
Add support for per-rthread base-offset for the %fs selector on amd64. Add pcb_fsbase to the PCB for tracking what the value for the thread is, and ci_cur_fsbase to struct cpu_info for tracking the CPU's current value for FS.base, then on return to user-space, skip the setting if the CPU has the right value already. Non-threaded processes without TLS leave FS.base zero, which can be conveniently optimized: setting %fs zeros FS.base for fewer cycles than wrmsr.
ok kettenis@
|
#
1.8 |
|
23-Mar-2011 |
pirofti |
Normalize sentinel. Use _MACHINE_*_H_ and _<ARCH>_*_H_ properly and consitently.
Discussed and okay drahn@. Okay deraadt@.
|
Revision tags: OPENBSD_4_9_BASE
|
#
1.7 |
|
13-Nov-2010 |
guenther |
Switch from TSS-per-process to TSS-per-CPU, placing the TSS right next to the cpu's GDT, also making the double-fault stack per-CPU, leaving it at the top of the page of the CPU's idle process. Inline pmap_activate() and pmap_deactivate() into the asm cpu_switchto routine, adding a check for the new pmap already being marked as active on the CPU. Garbage collect the hasn't-been-used-in-years GDT update IPI.
Tested by many; ok mikeb@, kettenis@
|
#
1.6 |
|
26-Oct-2010 |
guenther |
The LDT is only used by dead compat code now, so load the ldt register with the null selector (disabling use of it), stop reloading it on every context switch, and blow away the table itself, as well as the pcb and pmap bits that were used to track it. Also, delete two other unused pcb members: pcb_usersp and pcb_flags. (Deleting pcb_usersp also keeps the pcb_savefpu member aligned properly.) Finally, delete the defines for the unimplemented AMD64_{GET,SET}_LDT sysarch() calls.
Tested by various with both AMD and Intel chips ok mikeb@
|
Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
|
#
1.5 |
|
26-Jun-2008 |
ray |
First pass at removing clauses 3 and 4 from NetBSD licenses.
Not sure what's more surprising: how long it took for NetBSD to catch up to the rest of the BSDs (including UCB), or the amount of code that NetBSD has claimed for itself without attributing to the actual authors.
OK deraadt@
|
#
1.4 |
|
23-May-2008 |
jasper |
- remove USER_LDT, it was never in a state where it would copile, nor will we support i386-compat mode on amd64.
agreed by beck@, dlg@, kettenis@ ok deraadt@, tom@
|
Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
|
#
1.3 |
|
10-May-2006 |
krw |
Missing $OpenBSD$ tags.
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.2 |
|
13-Dec-2005 |
jsg |
Remove the advertising clause in the UCB license which Berkeley rescinded 22 July 1999. Checked by ian@, deraadt@ and millert@, arm portion checked by drahn@
|
Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
|
#
1.1 |
|
28-Jan-2004 |
mickey |
an amd64 arch support. hacked by art@ from netbsd sources and then later debugged by me into the shape where it can host itself. no bootloader yet as needs redoing from the recent advanced i386 sources (anyone? ;)
|