| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 /* | 32 /* |
| 33 * This code gets executed when switching from the 64-bit service | 33 * This code gets executed when switching from the 64-bit service |
| 34 * runtime to a 32-bit nacl module. NaClSwitch has one parameter only, | 34 * runtime to a 32-bit nacl module. NaClSwitch has one parameter only, |
| 35 * which is a struct passed by reference. | 35 * which is a struct passed by reference. |
| 36 */ | 36 */ |
| 37 | 37 |
| 38 #include "native_client/src/trusted/service_runtime/nacl_config.h" | 38 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
| 39 | 39 |
| 40 .text | 40 .text |
| 41 .globl IDENTIFIER(NaClSwitch) | 41 .globl IDENTIFIER(NaClSwitch) |
| 42 HIDDEN(NaClSwitch) |
| 42 IDENTIFIER(NaClSwitch): | 43 IDENTIFIER(NaClSwitch): |
| 43 #if NACL_LINUX || NACL_OSX | 44 #if NACL_LINUX || NACL_OSX |
| 44 /* if Linux/OSX, 1st param is in %rdi. move %rdi to %rcx */ | 45 /* if Linux/OSX, 1st param is in %rdi. move %rdi to %rcx */ |
| 45 mov %rdi, %rcx | 46 mov %rdi, %rcx |
| 46 #endif | 47 #endif |
| 47 /* if Windows, 1st param is already in %rcx */ | 48 /* if Windows, 1st param is already in %rcx */ |
| 48 | 49 |
| 49 mov 0x30(%ecx), %edx /* new_eip */ | 50 mov 0x30(%ecx), %edx /* new_eip */ |
| 50 mov 0x14(%ecx), %ebp /* frame_ptr.ptr_32.ptr */ | 51 mov 0x14(%ecx), %ebp /* frame_ptr.ptr_32.ptr */ |
| 51 movl 0x8(%ecx), %edi /* edi */ | 52 movl 0x8(%ecx), %edi /* edi */ |
| 52 movl 0x4(%ecx), %esi /* esi */ | 53 movl 0x4(%ecx), %esi /* esi */ |
| 53 movl 0(%ecx), %ebx /* ebx */ | 54 movl 0(%ecx), %ebx /* ebx */ |
| 54 | 55 |
| 55 mov 0x2e(%ecx), %gs /* gs */ | 56 mov 0x2e(%ecx), %gs /* gs */ |
| 56 /* We cannot set fs in 64-bit mode. Using arch_prctl didn't | 57 /* We cannot set fs in 64-bit mode. Using arch_prctl didn't |
| 57 * work either. | 58 * work either. |
| 58 */ | 59 */ |
| 59 /* mov 0x2c(%ecx), %fs */ | 60 /* mov 0x2c(%ecx), %fs */ |
| 60 mov 0x2a(%ecx), %es /* es */ | 61 mov 0x2a(%ecx), %es /* es */ |
| 61 | 62 |
| 62 /* do not leak info to app */ | 63 /* do not leak info to app */ |
| 63 xor %rax, %rax | 64 xor %rax, %rax |
| 64 | 65 |
| 65 /* We ljmp in 32-bit mode. So, we need a valid ds to access the | 66 /* We ljmp in 32-bit mode. So, we need a valid ds to access the |
| 66 * NaClThreadContext from the springboard. However, in 64-bit | 67 * NaClThreadContext from the springboard. However, in 64-bit |
| 67 * mode the ds val is 0. | 68 * mode the ds val is 0. |
| 68 */ | 69 */ |
| 69 ljmp *0x38(%ecx) /* spring_addr */ | 70 ljmp *0x38(%ecx) /* spring_addr */ |
| OLD | NEW |