I am reading the copy_from_user
function, in copy_from_user
function, the macro __get_user_asm
is used.
there is a mmap syscall in linux, mmap syscall will call function copy_from_user
. this function will use the macro __get_user_asm
if the size is constant. the content of __get_user_asm
is
#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
asm volatile("1: mov"itype" %2,%"rtype"1\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3: mov %3,%0\n" \
" xor"itype" %"rtype"1,%"rtype"1\n" \
" jmp 2b\n" \
".previous\n" \
_ASM_EXTABLE(1b, 3b) \
: "=r" (err), ltype(x) \
: "m" (__m(addr)), "i" (errret), "0" (err))
when i try to translate
__get_user_asm(*(u8 *)dst, (u8 __user *)src, ret, "b", "b", "=q", 1);
to the real source,
1: movb %2,%b1\n
2:\n
.section .fixup, "ax" \n
3: mov %3, %0 \n
**xorb %b1, %b1\n**
jmp 2b\n
.previous\n
: "=r" (ret), =q(dst)
:"m"(dst), "i"(1), "0"(ret)
.quad "1b", "2b"\n
.previous\n```
, there are somewhere i can't understand.
1, in xorb %b1, %b1
, what's %b1
(b one, not b L)?
2, in jmp 2b
, is 2b
a label or a memroy address? if 2b
is a label, how can i find this lable?
3, what's the function of .quad "1b", "2b"
?
where can i get the knowledge that make me to understand the linux kernel source in semantics layer?