Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: src/trusted/validator/x86/ncval_reg_sfi/address_sets_inl.c

Issue 625923004: Delete old x86 validator. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: rebase master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 /*
8 * address_sets_inl.c - Holds inline routines for commonly used (simple)
9 * functions in address_sets.h. Used to speed up code. Inlined routines
10 * correspond to the following functions in address_sets.h, but with
11 * an 'Inline' suffix:
12 *
13 * NaClAddressSetAdd
14 */
15
16 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_ADDRESS_SETS_INL_C __
17 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_ADDRESS_SETS_INL_C __
18
19 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/address_sets.h"
20
21 /* Model the offset created by removing the bottom three bits of a PcAddress. */
22 typedef NaClPcAddress NaClPcOffset;
23
24 /* Model the set of possible 3-bit tails of possible PcAddresses. */
25 static const uint8_t nacl_pc_address_masks[8] = {
26 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
27
28 /* Convert the 3 lower bits of an address into the corresponding address mask
29 * to use.
30 */
31 static INLINE uint8_t NaClPcAddressToMask(NaClPcAddress address) {
32 return nacl_pc_address_masks[(int) (address & (NaClPcAddress)0x7)];
33 }
34
35 /* Convert an address into the corresponding offset in an address table.
36 * That is, strip off the last three bits, since these remaining bits
37 * will be encoded using the union of address masks in the address table.
38 */
39 static INLINE NaClPcOffset NaClPcAddressToOffset(NaClPcAddress address) {
40 return address >> 3;
41 }
42
43 /* Returns true if the given address is within the code segment. Generates
44 * error messages if it isn't.
45 */
46 static INLINE Bool NaClCheckAddressRange(NaClPcAddress address,
47 NaClValidatorState* state) {
48 if (address >= state->codesize) {
49 NaClValidatorPcAddressMessage(LOG_ERROR, state, address,
50 "Jump to address outside code segment.\n");
51 return FALSE;
52 }
53 return TRUE;
54 }
55
56 static INLINE void NaClAddressSetAddInline(NaClAddressSet set,
57 NaClPcAddress address,
58 NaClValidatorState* state) {
59 if (NaClCheckAddressRange(address, state)) {
60 DEBUG(NaClLog(LOG_INFO,
61 "Address set add: %"NACL_PRIxNaClPcAddress"\n",
62 address));
63 set[NaClPcAddressToOffset(address)] |= NaClPcAddressToMask(address);
64 }
65 }
66
67 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_ADDRESS_SETS_IN L_C__ */
OLDNEW
« no previous file with comments | « src/trusted/validator/x86/ncval_reg_sfi/address_sets.c ('k') | src/trusted/validator/x86/ncval_reg_sfi/nc_cpu_checks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698