Skip to contentSkip to conversation

question on memory map of process on i386

DISCUSSION Christopher Friesen 3 participants 4 messages Aug 3, 2005 – Aug 4, 2005

lore
Share & tools
lore
#0 lore raw

On i386, /proc/<pid>/maps shows the following entry:

ffffe000-fffff000 ---p 00000000 00:00 0

This page of memory is way up above TASK_SIZE (which is 0xc0000000), so how is it visible to userspace?

Just to complicate things, I seem to find the vma for this page using find_vma_prev().

Can anyone explain what's going on?

Thanks,

Chris

#1 lore raw
Quoted 4 lines · Christopher Friesen

On i386, /proc/<pid>/maps shows the following entry:

ffffe000-fffff000 ---p 00000000 00:00 0

Quoted 8 lines

This page of memory is way up above TASK_SIZE (which is 0xc0000000), so how is it visible to userspace?

Just to complicate things, I seem to find the vma for this page using find_vma_prev().

Can anyone explain what's going on?

Looking at the code, it seems to be the "gate area". But what this is used for, I'm not really sure. I did a little searching but found no good explanations of it. So I added Keith to the CC since most of the updates to this was submitted by him :-)

-- Steve

#2 lore raw
In reply to Christopher Friesen
Quoted 5 lines · Christopher Friesen

On i386, /proc/<pid>/maps shows the following entry:

ffffe000-fffff000 ---p 00000000 00:00 0

Quoted 7 lines

This page of memory is way up above TASK_SIZE (which is 0xc0000000), so how is it visible to userspace?

Just to complicate things, I seem to find the vma for this page using find_vma_prev().

Can anyone explain what's going on?

The gate page is a section of code that is generated as part of the kernel build. At run time, the gate page is mapped into all the user space processes. There is also a virtual dynamic .so (vdso) file that is created by the kernel and picked up by the linker, the vdso maps the kernel entries in the gate page. Run this command and look for "gate".

ldd -v which cat

Once all the dots are joined by the linker, a program can use the vdso to directly access the gate page, even though the vdso and the underlying page belongs to the kernel. This direct access does not incur any of the overhead associated with a syscall, so it can be very fast.

What is in the gate page varies from one architecture to another, glibc hides the arch differences from the program. Some sample uses for the gate page -

i386: select between int 0x80 or sysenter to enter the kernel.
ia64: select between break 0x100000 or epc to enter the kernel, epc is
significantly faster. On ia64, the gate page also contains the signal delivery trampoline.

#3 lore raw
Quoted 5 lines · Keith Owens

The gate page is a section of code that is generated as part of the kernel build. At run time, the gate page is mapped into all the user space processes. There is also a virtual dynamic .so (vdso) file that is created by the kernel and picked up by the linker, the vdso maps the kernel entries in the gate page. Run this command and look for "gate".

Okay, I suspected it might be something like this.

Why does find_vma() fail for that page though? This confuses some code that I wrote. Do I have to teach my stuff about get_gate_vma() and in_gate_area()?

Chris