tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pcb offset into uarea



I'm adding code to i386 and amd64 to save the ymm registers on process
switch - allowing userspace to use the AVX instructions.

I also don't want to have to do it all again when the next set of
extensions appear.
This means that the size of the FPU save area (currently embedded in
the pcb) can't be determined until runtime.

Plan A is to move the FPU save are to the end of the pcb, and then
locate the pcb at the correct offset in the uarea so that the written
region ends at the end of the page.
The problem with this is that the offset of the pcb in the uarea
is set by MI code based on some #defines - and there seem to be
several related values.

Now on x86 (like most systems) the cpu stack advances into low memory.
The pcb is placed at the end of the uarea with the intial stack pointer
just below it.
I suspect that a long time ago (when the uarea had a fixed KVA) an
additional memory page was placed below the uarea to give interrupts
more stack space. I don't think this happens any more.

As an aside: The uarea used to be pageable, whereas (what is now) the
lwp structure isn't. Paging of uarea's was disabled a few years back
- so there is no real difference between the lifetimes of an lwp a uarea.
(zombies probably lose the uarea before the lwp).

An alternative would be to place the FP save area at the start of the uarea.
This would mean that, on stack overflow, the FP save area would be trashed
before some random piece of memory.
It might even be worth putting the pcb at the start of the uarea - so that
stack overflow crashes out the failing process, and probably earlier
than the random corruption would.

This gives me three options:
A) Put the save area at the end of the pcb and dynamically adjust the pcb
   offset.
B) Put the save area at the start of the uarea, with the pcb at a fixed
   offset at the end of the uarea.
C) Put the save area at the end of the pcb, and put the pcb at the start
   of the uarea.

Votes?
What have I missed?

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index