- FreePool(OrigDevPath);
- return status;
-}
-
-#ifdef __MAKEWITH_GNUEFI
-/* Nasty: ELF and EFI have different calling conventions. Here is the map for
- * calling ELF -> EFI
- *
- * 1) rdi -> rcx (32 saved)
- * 2) rsi -> rdx (32 saved)
- * 3) rdx -> r8 ( 32 saved)
- * 4) rcx -> r9 (32 saved)
- * 5) r8 -> 32(%rsp) (48 saved)
- * 6) r9 -> 40(%rsp) (48 saved)
- * 7) pad+0(%rsp) -> 48(%rsp) (64 saved)
- * 8) pad+8(%rsp) -> 56(%rsp) (64 saved)
- * 9) pad+16(%rsp) -> 64(%rsp) (80 saved)
- * 10) pad+24(%rsp) -> 72(%rsp) (80 saved)
- * 11) pad+32(%rsp) -> 80(%rsp) (96 saved)
-
- *
- * So for a five argument callback, the map is ignore the first two arguments
- * and then map (EFI -> ELF) assuming pad = 0.
- *
- * ARG4 -> ARG1
- * ARG3 -> ARG2
- * ARG5 -> ARG3
- * ARG6 -> ARG4
- * ARG11 -> ARG5
- *
- * Calling conventions also differ over volatile and preserved registers in
- * MS: RBX, RBP, RDI, RSI, R12, R13, R14, and R15 are considered nonvolatile .
- * In ELF: Registers %rbp, %rbx and %r12 through %r15 “belong” to the calling
- * function and the called function is required to preserve their values.
- *
- * This means when accepting a function callback from MS -> ELF, we have to do
- * separate preservation on %rdi, %rsi before swizzling the arguments and
- * handing off to the ELF function.
- */
-
-asm (
-".type security2_policy_authentication,@function\n"
-"thunk_security2_policy_authentication:\n\t"
- "mov 0x28(%rsp), %r10 # ARG5\n\t"
- "push %rdi\n\t"
- "push %rsi\n\t"
- "mov %r10, %rdi\n\t"
- "subq $8, %rsp # space for storing stack pad\n\t"
- "mov $0x08, %rax\n\t"
- "mov $0x10, %r10\n\t"
- "and %rsp, %rax\n\t"
- "cmovnz %rax, %r11\n\t"
- "cmovz %r10, %r11\n\t"
- "subq %r11, %rsp\n\t"
- "addq $8, %r11\n\t"
- "mov %r11, (%rsp)\n\t"
-"# five argument swizzle\n\t"
- "mov %rdi, %r10\n\t"
- "mov %rcx, %rdi\n\t"
- "mov %rdx, %rsi\n\t"
- "mov %r8, %rdx\n\t"
- "mov %r9, %rcx\n\t"
- "mov %r10, %r8\n\t"
- "callq security2_policy_authentication@PLT\n\t"
- "mov (%rsp), %r11\n\t"
- "addq %r11, %rsp\n\t"
- "pop %rsi\n\t"
- "pop %rdi\n\t"
- "ret\n"
-);
-
-asm (
-".type security_policy_authentication,@function\n"
-"thunk_security_policy_authentication:\n\t"
- "push %rdi\n\t"
- "push %rsi\n\t"
- "subq $8, %rsp # space for storing stack pad\n\t"
- "mov $0x08, %rax\n\t"
- "mov $0x10, %r10\n\t"
- "and %rsp, %rax\n\t"
- "cmovnz %rax, %r11\n\t"
- "cmovz %r10, %r11\n\t"
- "subq %r11, %rsp\n\t"
- "addq $8, %r11\n\t"
- "mov %r11, (%rsp)\n\t"
-"# three argument swizzle\n\t"
- "mov %rcx, %rdi\n\t"
- "mov %rdx, %rsi\n\t"
- "mov %r8, %rdx\n\t"
- "callq security_policy_authentication@PLT\n\t"
- "mov (%rsp), %r11\n\t"
- "addq %r11, %rsp\n\t"
- "pop %rsi\n\t"
- "pop %rdi\n\t"
- "ret\n"
-);
-#endif