Re: [PATCH] Add VDSO time function support for x86 32-bit kernel

From: H. Peter Anvin
Date: Thu Dec 13 2012 - 19:36:38 EST


On 12/13/2012 04:20 PM, Andy Lutomirski wrote:

Whatever data you need you can just map it into the vdso range. There
really shouldn't be anything special about that at all.

The fixmap stuff is an x86-64 legacy that you don't have to worry about,
obviously.

The fixmap page is new. It's not ABI -- the layout can freely change,
but the vdso needs to be able to see. It would make no sense to cow
that page, and it would be more complicated to make it be part of the
(64-bit) vdso, so I left it as a fixmap when I did the vvar cleanups.


Well, the vsyscall fixmap is an ABI. But just because a page is mapped into userspace doesn't mean cow. Think of it as a device mmap, or an mmap of a shared file.

For compat mode, though, I don't think it can be in the fixmap unless
there are segmentation games that I think are impossible, or unless
the vdso wants to do a far call (which I would guess is not much
faster than a system call, although I haven't benchmarked it). This
is because there are no addresses at all that can be seen from 32-bit
code segments and that are in the kernel address range.

Yes, you'd have to nip into 64-bit mode which is not really practical.

What you could do is probably arrange (using some linker script magic)
for a symbol to exist that points at the page *before* the vdso
starts. Then just map the vvar page there when starting a compat
task. You could then address it using a normal symbol reference by
tweaking the vvar macro. (I think this'll access it via the GOT.)
Alternatively, you could just pick an absolute address -- the page is
NX, so you don't really need to worry about randomization.

IMO it seems this is making it way more complicated than it is. Just make sure you have a section in the vdso where you can map in a data page with the symbols in the right offsets. Extra points for doing magic so that it is at the beginning or end, but I think that might be harder than necessary.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/