vfork.S revision 9ea4d5f3a852a03b5a2c5676da148a2779821518
19ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes/* 29ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * Copyright (C) 2013 The Android Open Source Project 39ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * All rights reserved. 49ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * 59ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * Redistribution and use in source and binary forms, with or without 69ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * modification, are permitted provided that the following conditions 79ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * are met: 89ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * * Redistributions of source code must retain the above copyright 99ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * notice, this list of conditions and the following disclaimer. 109ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * * Redistributions in binary form must reproduce the above copyright 119ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * notice, this list of conditions and the following disclaimer in 129ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * the documentation and/or other materials provided with the 139ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * distribution. 149ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * 159ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 169ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 179ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 189ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 199ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 209ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 219ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 229ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 239ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 249ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 259ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 269ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * SUCH DAMAGE. 279ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes */ 289ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes 299ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes#include <asm/unistd.h> 309ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes#include <linux/err.h> 319ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes#include <machine/asm.h> 329ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes 339ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes// This custom code preserves the return address across the system call. 349ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes 359ea4d5f3a852a03b5a2c5676da148a2779821518Elliott HughesENTRY(vfork) 369ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes popq %rdi // Grab the return address. 379ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes movl $__NR_vfork, %eax 389ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes syscall 399ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes pushq %rdi // Restore the return address. 409ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes cmpq $-MAX_ERRNO, %rax 419ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes jb 1f 429ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes negl %eax 439ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes movl %eax, %edi 449ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes call __set_errno 459ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes orq $-1, %rax 469ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes1: 479ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes ret 489ea4d5f3a852a03b5a2c5676da148a2779821518Elliott HughesEND(vfork) 49