Why can't 64-bit Windows unwind user-kernel-user exceptions?

前端 未结 2 1767
孤街浪徒
孤街浪徒 2020-12-23 12:50

Why can\'t 64-bit Windows unwind the stack during an exception, if the stack crosses the kernel boundary - when 32-bit Windows can?

The context of this entire questi

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 13:43

    I'm the developer who wrote this Hotfix a loooooooong time ago as well as the blog post. The main reason is that the full register file isn't always captured when you transition into kernel space, for performance reasons.

    If you make a normal syscall, the x64 Application Binary Interface (ABI) only requires you to preserve the non-volatile registers (similar to making a normal function call). However, correctly unwinding the exception requires you to have all the registers, so it's not possible. Basically, this was a choice between perf in a critical scenario (i.e. a scenario that potentially happens thousands of times per second) vs. 100% correctly handling a pathological scenario (a crash).

    Bonus Reading

    • Overview of x64 Calling Conventions
    • x86 Software Conventions - Register Usage

提交回复
热议问题