12025cf9eSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 2c25be94fSDenys Vlasenko/* 3c25be94fSDenys Vlasenko * thunks_32.S - assembly helpers for mixed-bitness code 4c25be94fSDenys Vlasenko * Copyright (c) 2015 Denys Vlasenko 5c25be94fSDenys Vlasenko * 6c25be94fSDenys Vlasenko * These are little helpers that make it easier to switch bitness on 7c25be94fSDenys Vlasenko * the fly. 8c25be94fSDenys Vlasenko */ 9c25be94fSDenys Vlasenko 10c25be94fSDenys Vlasenko .text 11c25be94fSDenys Vlasenko .code32 12c25be94fSDenys Vlasenko 13c25be94fSDenys Vlasenko .global call64_from_32 14c25be94fSDenys Vlasenko .type call32_from_64, @function 15c25be94fSDenys Vlasenko 16c25be94fSDenys Vlasenko // 4(%esp): function to call 17c25be94fSDenys Vlasenkocall64_from_32: 18c25be94fSDenys Vlasenko // Fetch function address 19c25be94fSDenys Vlasenko mov 4(%esp), %eax 20c25be94fSDenys Vlasenko 21c25be94fSDenys Vlasenko // Save registers which are callee-clobbered by 64-bit ABI 22c25be94fSDenys Vlasenko push %ecx 23c25be94fSDenys Vlasenko push %edx 24c25be94fSDenys Vlasenko push %esi 25c25be94fSDenys Vlasenko push %edi 26c25be94fSDenys Vlasenko 27c25be94fSDenys Vlasenko // Switch to long mode 28c25be94fSDenys Vlasenko jmp $0x33,$1f 29c25be94fSDenys Vlasenko1: .code64 30c25be94fSDenys Vlasenko 31c25be94fSDenys Vlasenko // Call the function 32c25be94fSDenys Vlasenko call *%rax 33c25be94fSDenys Vlasenko 34c25be94fSDenys Vlasenko // Switch to compatibility mode 35c25be94fSDenys Vlasenko push $0x23 /* USER32_CS */ 36c25be94fSDenys Vlasenko .code32; push $1f; .code64 /* hack: can't have X86_64_32S relocation in 32-bit ELF */ 37c25be94fSDenys Vlasenko lretq 38c25be94fSDenys Vlasenko1: .code32 39c25be94fSDenys Vlasenko 40c25be94fSDenys Vlasenko pop %edi 41c25be94fSDenys Vlasenko pop %esi 42c25be94fSDenys Vlasenko pop %edx 43c25be94fSDenys Vlasenko pop %ecx 44c25be94fSDenys Vlasenko 45c25be94fSDenys Vlasenko ret 46c25be94fSDenys Vlasenko 47c25be94fSDenys Vlasenko.size call64_from_32, .-call64_from_32 48