blob: 7baa69755e00631a43eb88257e4291d2a9bcd2d2 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "syscall-entry.h"
#include "zircon-syscall-x86.S"
#include <lib/syscalls/zx-syscall-numbers.h>
.cfi_sections .eh_frame, .debug_frame
// (vmar_handle: %rdi, addr: %rsi, len: %rdx, handle: %ecx)
syscall_entry_begin zx_vmar_unmap_handle_close_thread_exit
// Save the handle argument in a callee-saves register (%rbx).
// Callee-save that register so we can unwind in the error case.
push_reg %rbx
mov %ecx, %ebx
zircon_syscall ZX_SYS_vmar_unmap, zx_vmar_unmap, zx_vmar_unmap_handle_close_thread_exit
test %eax, %eax
jnz .Lvmar_unmap_fail
// Now the stack is gone and we can never return!
mov %ebx, %edi
zircon_syscall ZX_SYS_handle_close, zx_handle_close, zx_vmar_unmap_handle_close_thread_exit
test %eax, %eax
jnz .Lhandle_close_fail
zircon_syscall ZX_SYS_thread_exit, zx_thread_exit, zx_vmar_unmap_handle_close_thread_exit
// It should be impossible to get here.
pop_reg %rbx
syscall_entry_end zx_vmar_unmap_handle_close_thread_exit