This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: loc2c-runtime deref()
Hi -
roland wrote:
> > The $target and $target->field extraction logic in the translator
> > emits code that calls the macro deref() in src/runtime/loc2c-runtime.h
> > to follow pointers. This macro appears to be tuned for accessing
> > user-space (refers to uaccess.h's __get_user_asm). [...]
>
> You are misunderstanding the code.
Possibly.
> Ignore the names in the implementation details.
In the absence of documentation, there's little else to go by, I
guess. cscope-identified callers to __get_user_asm (such as
strncpy_from_user) seem to agree with my interpretation. According to
a make -E, the current deref() maps to this blob:
int _bad = 0;
u8 _b;
u16 _w;
u32 _l;
u64 _q;
long _v;
switch (4)
{
case 1:
__asm__ __volatile__ ("1: mov" "b" " %2,%" "b" "1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " xor" "b" " %" "b" "1,%" "b" "1\n" "
jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous": "=r" (_bad), "=q" (_b): "m" ((*(struct __large_struct *) (addr))), "i" (1), "0" (_bad)); _v = _b; break; case 2:
__asm__ __volatile__ ("1:
mov" "w" " %2,%" "w" "1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" "
xor" "w" " %" "w" "1,%" "w" "1\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous": "=r" (_bad), "=r" (_w): "m" ((*(struct __large_struct *) (addr))), "i" (1), "0" (_bad)); _v = _w; break; case 4:
__asm__ __volatile__ ("1: mov" "l" " %2,%" "" "1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " xor" "l" " %" "" "1,%" "" "1\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous": "=r" (_bad), "=r" (_l): "m" ((*(struct __large_struct *) (addr))), "i" (1), "0" (_bad)); _v = _l; break; case 8:
__asm__ __volatile__ ("1: mov" "q" " %2,%" "" "1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " xor" "q" " %" "" "1,%" "" "1\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous": "=r" (_bad), "=r" (_q): "m" ((*(struct __large_struct *) (addr))), "i" (1), "0" (_bad)); _v = _q; break; default:
_v =
__get_user_bad ();}
if (_bad) goto deref_fault; _v;}
> The runtime macros are tailored specifically for kernel-mode access,
> and their sole purpose is to catch invalid pointer references.
Which runtime and which macros are you referring to?
- FChE