2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * NaCl Simple/secure ELF loader (NaCl SEL).
35 #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_NACL_CONFIG_H_
36 #define NATIVE_CLIENT_SERVICE_RUNTIME_NACL_CONFIG_H_
39 * this value must be consistent with NaCl compiler flags
40 * -falign-functions -falign-labels -and nacl-align.
42 #if defined(NACL_BLOCK_SHIFT)
43 # define NACL_INSTR_BLOCK_SHIFT (NACL_BLOCK_SHIFT)
45 # error "NACL_BLOCK_SHIFT should be defined by CFLAGS"
47 #define NACL_INSTR_BLOCK_SIZE (1 << NACL_INSTR_BLOCK_SHIFT)
49 /* this must be a multiple of the system page size */
50 #define NACL_PAGESHIFT 12
51 #define NACL_PAGESIZE (1U << NACL_PAGESHIFT)
53 #define NACL_MAP_PAGESHIFT 12
54 #define NACL_MAP_PAGESIZE (1U << NACL_MAP_PAGESHIFT)
56 #if NACL_MAP_PAGESHIFT < NACL_PAGESHIFT
57 # error "NACL_MAP_PAGESHIFT smaller than NACL_PAGESHIFT"
60 /* NACL_MAP_PAGESIFT >= NACL_PAGESHIFT must hold */
61 #define NACL_PAGES_PER_MAP (1 << (NACL_MAP_PAGESHIFT-NACL_PAGESHIFT))
63 #define NACL_MEMORY_ALLOC_RETRY_MAX 256 /* see win/sel_memory.c */
66 * NACL_KERN_STACK_SIZE: The size of the secure stack allocated for
67 * use while a NaCl thread is in kernel mode, i.e., during
68 * startup/exit and during system call processing.
70 #define NACL_KERN_STACK_SIZE (32 << 10)
73 * NACL_CONFIG_PATH_MAX: What is the maximum file path allowed in the
74 * NaClSysOpen syscall? This is on the kernel stack for validation
75 * during the processing of the syscall, so beware running into
76 * NACL_KERN_STACK_SIZE above.
78 #define NACL_CONFIG_PATH_MAX 1024
81 * Macro for the start address of the trampolines.
82 * The first 64KB (16 pages) are inaccessible to prevent addr16/data16 attacks.
84 #define NACL_SYSCALL_START_ADDR (16 << NACL_PAGESHIFT)
85 /* Macro for the start address of a specific trampoline. */
86 #define NACL_SYSCALL_ADDR(syscall_number) \
87 (NACL_SYSCALL_START_ADDR + (syscall_number << NACL_INSTR_BLOCK_SHIFT))
90 * Syscall trampoline code have a block size that may differ from the
91 * alignment restrictions of the executable. The ELF executable's
92 * alignment restriction (16 or 32) defines what are potential entry
93 * points, so the trampoline region must still respect that. We
94 * prefill the trampoline region with HLT, so non-syscall entry points
95 * will not cause problems as long as our trampoline instruction
96 * sequence never grows beyond 16 bytes, so the "odd" potential entry
97 * points for a 16-byte aligned ELF will not be able to jump into the
98 * middle of the trampoline code.
100 #define NACL_SYSCALL_BLOCK_SHIFT 5
101 #define NACL_SYSCALL_BLOCK_SIZE (1 << NACL_SYSCALL_BLOCK_SHIFT)
104 * macros to provide uniform access to identifiers from assembly due
105 * to different C -> asm name mangling convention
107 #if NACL_WINDOWS || NACL_OSX
108 # define IDENTIFIER(n) _##n
110 # define IDENTIFIER(n) n
113 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_NACL_CONFIG_H_ */