Why are rbp and rsp called general purpose registers?

前端 未结 3 1504
情书的邮戳
情书的邮戳 2020-11-28 07:41

According to Intel in x64 the following registers are called general purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP and R8-R15) https://software.intel.com/en-us/a

3条回答
  •  隐瞒了意图╮
    2020-11-28 08:12

    Dereferencing rbp might result in a #SS(stack segment) fault.

    Recently, I hit a linux kernel crash with a 'stack segment fault'.

    crash> dmesg
    [...]
    stack segment: 0000 [#1] SMP
    [...]
    RIP: 0010:[]  lock_get_status+0x9b/0x3b0
    RSP: 0018:ffff89954a317d90  EFLAGS: 00010282
    [...]
    RBP: 800000fa8c251867 R08: 0000000000001000 R09: 000000000000ffff
    [...]
    crash> dis lock_get_status+0x9b
    0xffffffff8125fa8b :      mov    0x28(%rbp),%rax
    

    The memory address in rbp is non-canonical address. That's the reason for this crash. What I learned from this crash is that accessing rbp implicitly accesses ss segment register even through rbp is not used as a stack frame base pointer.

    According to Intel SDMv1 3.4.1 General-Purpose Registers:

    EBP — Pointer to data on the stack (in the SS segment)

提交回复
热议问题