From: Mike Frysinger <vapier@gentoo.org>
To: linux-ia64@vger.kernel.org
Subject: Re: getcpu() returns EFAULT when called via the vdso
Date: Mon, 07 May 2012 23:12:29 +0000 [thread overview]
Message-ID: <201205071912.30351.vapier@gentoo.org> (raw)
In-Reply-To: <201205061645.24398.vapier@gentoo.org>
[-- Attachment #1: Type: Text/Plain, Size: 1797 bytes --]
On Monday 07 May 2012 13:58:53 Luck, Tony wrote:
> the disassembly of the sched_getcpu() code at runtime looks like:
> 0x2000000000203940 <+0>: [MMI] alloc r32=ar.pfs,9,1,0
> 0x2000000000203941 <+1>: adds r14=8,r13
> 0x2000000000203942 <+2>: mov r33=r12;;
> 0x2000000000203950 <+16>: [MMI] ld8 r14=[r14]
> 0x2000000000203951 <+17>: nop.m 0x0
> 0x2000000000203952 <+18>: mov r15=1304
> 0x2000000000203960 <+32>: [MII] mov r35=r0 <<<<<<<<<<<<<<<<<<<
> 0x2000000000203961 <+33>: mov r34=r0;;<<<<<<<<<<<<<<<<<<<
> 0x2000000000203962 <+34>: mov b7=r14;;
> 0x2000000000203970 <+48>: [MIB] nop.m 0x0
> 0x2000000000203971 <+49>: nop.i 0x0
> 0x2000000000203972 <+50>: br.call.sptk.many b6=b7;;
>
> When the "br.call" is executed, we flip to the new register
> frame and r34/r35 in the sched_getcpu() frame become r32/r33
> in the new frame.
i think only one register is rotated because we called alloc with locals=1.
stepping through with gdb shows that -- on the first insn in
__kernel_syscall_via_epc, r32 is now the local variable on the stack, r33 and
r34 are 0.
> So you get -EFAULT because the VDSO tries to dereference a NULL
> pointer for each of the *cpu and *node arguments.
the kernel doesn't care if cpu/node are NULL:
SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,
struct getcpu_cache __user *, unused)
{
int err = 0;
int cpu = raw_smp_processor_id();
if (cpup)
err |= put_user(cpu, cpup);
if (nodep)
err |= put_user(cpu_to_node(cpu), nodep);
return err ? -EFAULT : 0;
}
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-05-07 23:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-06 20:45 getcpu() returns EFAULT when called via the vdso Mike Frysinger
2012-05-07 17:58 ` Luck, Tony
2012-05-07 23:12 ` Mike Frysinger [this message]
2012-05-07 23:53 ` Mike Frysinger
2012-05-08 21:13 ` Tony Luck
2012-05-08 22:31 ` Mike Frysinger
2012-05-15 5:41 ` Mike Frysinger
2012-11-29 23:34 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201205071912.30351.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.