asmlinkage函数是否仍然使用寄存器来传递参数?

时间:2015-01-06 06:09:01

标签: c linux-kernel toolchain arm64

有关于asmlinkage的描述:

  

" asmlinkage标签是我们应该注意的另一件事   这个简单的功能。对于某些gcc魔术来说,这是一个#define   该函数不应该期望找到它的任何编译器   寄存器中的参数(常见的优化),但仅限于CPU   堆。回想一下我们之前关于system_call消耗它的断言   第一个参数,系统呼叫号码,并允许最多四个   传递给实际系统调用的参数。 system_call   仅仅通过留下其他论点来实现这一壮举   在堆栈中传递给寄存器)。所有系统调用都已标记   使用asmlinkage标记,所以他们都查看堆栈的参数。   当然,在sys_ni_syscall的情况下,这并没有任何区别,   因为sys_ni_syscall不接受任何参数,但这是一个问题   对于大多数其他系统调用。而且,因为你会看到asmlinkage   在许多其他功能面前,我以为你应该知道它是什么   是关于。

asmlinkage告诉工具链这个函数不通过通用寄存器传递参数,而是堆栈。但我在linux内核中找到了一个函数" asmlinkage void __exception do_mem_abort()",

拱/ arm64 /毫米/ fault.c

/*
 * Dispatch a data abort to the relevant handler.
 */
asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr,
                     struct pt_regs *regs)
{
    const struct fault_info *inf = fault_info + (esr & 63);
    struct siginfo info;

    if (!inf->fn(addr, esr, regs))
        return;

    pr_alert("Unhandled fault: %s (0x%08x) at 0x%016lx\n",
         inf->name, esr, addr);

    info.si_signo = inf->sig;
    info.si_errno = 0;
    info.si_code  = inf->code;
    info.si_addr  = (void __user *)addr;
    arm64_notify_die("", regs, &info, esr);
}
下面的

是反汇编:

ffffffc000081180 <do_mem_abort>:
ffffffc000081180:   a9b57bfd    stp x29, x30, [sp,#-176]!
ffffffc000081184:   910003fd    mov x29, sp
ffffffc000081188:   12001424    and w4, w1, #0x3f
ffffffc00008118c:   b0005365    adrp    x5, ffffffc000aee000 <init_sighand+0x760>
ffffffc000081190:   52800303    mov w3, #0x18                   // #24
ffffffc000081194:   a90153f3    stp x19, x20, [sp,#16]
ffffffc000081198:   a9025bf5    stp x21, x22, [sp,#32]
ffffffc00008119c:   911860a5    add x5, x5, #0x618
ffffffc0000811a0:   9ba37c84    umull   x4, w4, w3
ffffffc0000811a4:   f86468a6    ldr x6, [x5,x4]
ffffffc0000811a8:   2a0103f3    mov w19, w1
ffffffc0000811ac:   aa0003f5    mov x21, x0
ffffffc0000811b0:   aa0203f6    mov x22, x2
ffffffc0000811b4:   8b0400b4    add x20, x5, x4
ffffffc0000811b8:   d63f00c0    blr x6
ffffffc0000811bc:   350000a0    cbnz    w0, ffffffc0000811d0 <do_mem_abort+0x50>
ffffffc0000811c0:   a94153f3    ldp x19, x20, [sp,#16]
ffffffc0000811c4:   a9425bf5    ldp x21, x22, [sp,#32]
ffffffc0000811c8:   a8cb7bfd    ldp x29, x30, [sp],#176
ffffffc0000811cc:   d65f03c0    ret
ffffffc0000811d0:   f9400a81    ldr x1, [x20,#16]
ffffffc0000811d4:   b0004360    adrp    x0, ffffffc0008ee000 <kallsyms_token_index+0x2e00>
ffffffc0000811d8:   2a1303e2    mov w2, w19
ffffffc0000811dc:   aa1503e3    mov x3, x21
ffffffc0000811e0:   91102000    add x0, x0, #0x408
ffffffc0000811e4:   941a8cf8    bl  ffffffc0007245c4 <printk>
ffffffc0000811e8:   b9400a85    ldr w5, [x20,#8]
ffffffc0000811ec:   b9400e84    ldr w4, [x20,#12]
ffffffc0000811f0:   d0004420    adrp    x0, ffffffc000907000 <kallsyms_token_index+0x1be00>
ffffffc0000811f4:   9110c000    add x0, x0, #0x430
ffffffc0000811f8:   aa1603e1    mov x1, x22
ffffffc0000811fc:   9100c3a2    add x2, x29, #0x30
ffffffc000081200:   2a1303e3    mov w3, w19
ffffffc000081204:   b90033a5    str w5, [x29,#48]
ffffffc000081208:   b90037bf    str wzr, [x29,#52]
ffffffc00008120c:   b9003ba4    str w4, [x29,#56]
ffffffc000081210:   f90023b5    str x21, [x29,#64]
ffffffc000081214:   94001f12    bl  ffffffc000088e5c <arm64_notify_die>
ffffffc000081218:   17ffffea    b   ffffffc0000811c0 <do_mem_abort+0x40>

它仍然使用x0,x1,x2传递三个参数,对于arm64来说它是不同的行为吗? THX

0 个答案:

没有答案
相关问题