[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4DEEB516.4681.19EE05CD@pageexec.freemail.hu>
Date: Wed, 08 Jun 2011 01:32:38 +0200
From: pageexec@...email.hu
To: Brian Gerst <brgerst@...il.com>
CC: Andrew Lutomirski <luto@....edu>, Ingo Molnar <mingo@...e.hu>,
x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, Jesper Juhl <jj@...osbits.net>,
Borislav Petkov <bp@...en8.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Arjan van de Ven <arjan@...radead.org>,
Jan Beulich <JBeulich@...ell.com>,
richard -rw- weinberger <richard.weinberger@...il.com>,
Mikael Pettersson <mikpe@...uu.se>,
Andi Kleen <andi@...stfloor.org>,
Louis Rilling <Louis.Rilling@...labs.com>,
Valdis.Kletnieks@...edu
Subject: Re: [PATCH v5 8/9] x86-64: Emulate legacy vsyscalls
On 6 Jun 2011 at 10:07, Brian Gerst wrote:
> > do you know what that mucking looks like? ;) prepare for the most complex code
> > you've ever seen (it's in __bad_area_nosemaphore):
> >
> > 779 #ifdef CONFIG_X86_64
> > 780 »·······if (mm && (error_code & PF_INSTR) && mm->context.vdso) {
> > 781 »·······»·······if (regs->ip == (unsigned long)vgettimeofday) {
> > 782 »·······»·······»·······regs->ip = (unsigned long)VDSO64_SYMBOL(mm->context.vdso, gettimeofday);
> > 783 »·······»·······»·······return;
> > 784 »·······»·······} else if (regs->ip == (unsigned long)vtime) {
> > 785 »·······»·······»·······regs->ip = (unsigned long)VDSO64_SYMBOL(mm->context.vdso, clock_gettime);
> > 786 »·······»·······»·······return;
> > 787 »·······»·······} else if (regs->ip == (unsigned long)vgetcpu) {
> > 788 »·······»·······»·······regs->ip = (unsigned long)VDSO64_SYMBOL(mm->context.vdso, getcpu);
> > 789 »·······»·······»·······return;
> > 790 »·······»·······}
> > 791 »·······}
> > 792 #endif
>
> I like this approach, however since we're already in the kernel it
> makes sense just to run the normal syscall instead of redirecting to
> the vdso.
it's not that simple as the page fault occurs not at the actual syscall
insn but at the first insn of the given vsyscall function, so you'd have
to emulate it carefully to be able to return back the original caller in
userland.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists