# Linux Kernel Module Cheat

#### 28.8.1. x86_64 calling convention

Examples:

- lkmc/x86_64.h `ENTRY` and `EXIT`

One important catch is that the stack must always be aligned to 16-bits before making calls: https://stackoverflow.com/questions/56324948/why-does-calling-the-c-abort-function-from-an-x86-64-assembly-function-lead-to

Bibliography:

- https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI

- https://stackoverflow.com/questions/18024672/what-registers-are-preserved-through-a-linux-x86-64-function-call/55207335#55207335