Page MenuHomeFreeBSD

Set %esp correctly in the extended TSS.
ClosedPublic

Authored by jhb on Dec 7 2015, 12:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 2:53 AM
Unknown Object (File)
Mon, Oct 13, 2:53 AM
Unknown Object (File)
Sun, Oct 12, 11:04 PM
Unknown Object (File)
Sun, Oct 12, 3:01 PM
Unknown Object (File)
Thu, Oct 9, 2:39 AM
Unknown Object (File)
Sun, Oct 5, 12:53 AM
Unknown Object (File)
Sat, Oct 4, 9:33 PM
Unknown Object (File)
Sat, Oct 4, 8:03 PM

Details

Summary

The pcb is saved at the top of the kernel stack on x86 platforms.
The initial kenrel stack pointer is set in the TSS so that the trapframe
from user -> kernel transitions begins directly below the pcb and grows
down.

The XSAVE changes moved the FPU save area out of the pcb and into a
variable-sized area after the pcb. This required updating the expressions
to calculate the initial stack pointer from 'stacktop - sizeof(pcb)' to
'stacktop - sizeof(pcb) + FPU save area size'.

The i386_set_ioperm() system call allows user applications to access
individual I/O ports via the I/O port permission bitmap in the TSS.
On FreeBSD this requires allocating a custom per-process TSS instead of
using the shared per-CPU TSS.

The expression to initialize the initial kernel stack pointer in the
per-process TSS created for i386_set_ioperm() was not properly updated
after the XSAVE changes. Processes that used i386_set_ioperm() would
trash the trapframe during subsequent context switches resulting in
panics from memory corruption.

This changes fixes the kernel stack pointer calculation for the per-process
TSS.

Reported by: n_hibma

Test Plan
  • Run a simple test program that calls i386_set_ioperm(). Previously the machine/VM would panic almost instantly. Now the program is able to run fine.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1459
Build 1464: arc lint + arc unit

Event Timeline

jhb retitled this revision from to Set %esp correctly in the extended TSS..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: kib.
kib edited edge metadata.
This revision is now accepted and ready to land.Dec 7 2015, 9:51 AM

This has been confirmed to fix our problem in VB VM as well as on an ALIX board.