| Index: src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
|
| diff --git a/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S b/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
|
| index 7f83707fc5d557be2c8118799bae6c5aaf3f2b42..ce425b20d67ee769fa622a224b52b1d711169081 100644
|
| --- a/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
|
| +++ b/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
|
| @@ -1,7 +1,7 @@
|
| /*
|
| - * Copyright 2009 The Native Client Authors. All rights reserved.
|
| - * Use of this source code is governed by a BSD-style license that can
|
| - * be found in the LICENSE file.
|
| + * Copyright (c) 2011 The Native Client Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| */
|
|
|
| /*
|
| @@ -23,25 +23,48 @@
|
| IDENTIFIER(NaClSwitch):
|
| #if NACL_WINDOWS
|
| /* if Windows, 1st param is already in %rcx, not %rdi */
|
| - mov %rcx, %rdi
|
| #elif NACL_LINUX || NACL_OSX
|
| /* elif Linux/OSX, 1st param is already in %rdi. */
|
| + mov %rdi, %rcx
|
| #else
|
| # error "What OS/compiler is the service runtime being compiled with?"
|
| #endif
|
|
|
| - movq 0x8(%rdi), %rbx
|
| - movq 0x20(%rdi), %rbp
|
| - movq 0x60(%rdi), %r12
|
| - movq 0x68(%rdi), %r13
|
| - movq 0x70(%rdi), %r14
|
| - movq 0x78(%rdi), %r15
|
| + movq 0x8(%rcx), %rbx
|
| + movq 0x20(%rcx), %rbp
|
| + movq 0x60(%rcx), %r12
|
| + movq 0x68(%rcx), %r13
|
| + movq 0x70(%rcx), %r14
|
| + movq 0x78(%rcx), %r15
|
|
|
| /* there is no springboard for x86_64 */
|
| - movq 0x38(%rdi), %rsp /* rsp -- switch stack */
|
| - movq 0x90(%rdi), %rax /* syscall return */
|
| - jmp *0x88(%rdi)
|
| + movq 0x38(%rcx), %rsp /* rsp -- switch stack */
|
| + movq 0x90(%rcx), %rax /* syscall return */
|
| +
|
| + /*
|
| + * %rdi is the first argument in the user calling convention.
|
| + * When starting the initial thread, we are passing the address
|
| + * of the parameter block here. The initial stack pointer has
|
| + * been adjusted to one word below there, to insert a dummy
|
| + * return address for the user entry point function.
|
| + */
|
| + leal 8(%rsp), %edi
|
| +
|
| + /*
|
| + * Zero all unused registers. The 32-bit instructions
|
| + * are a byte shorter than their 64-bit counterparts
|
| + * when the target register is one of the first eight,
|
| + * and they implicitly zero the high halves.
|
| + */
|
| + xorl %edx, %edx
|
| + movl %edx, %esi
|
| + movq %rdx, %r8
|
| + movq %rdx, %r9
|
| + movq %rdx, %r10
|
| + movq %rdx, %r11
|
| +
|
| + jmp *0x88(%rcx)
|
| /*
|
| - * This leaves %rdi pointing to the thread context, but that
|
| + * This leaves %rcx pointing to the thread context, but that
|
| * should be memory that's inaccessible by NaCl module code.
|
| */
|
|
|