Index: src/trusted/validator_ragel/gen/validator_x86_32.c |
=================================================================== |
--- src/trusted/validator_ragel/gen/validator_x86_32.c (revision 9911) |
+++ src/trusted/validator_ragel/gen/validator_x86_32.c (working copy) |
@@ -3,6 +3,14 @@ |
* Compiled for ia32 mode. |
*/ |
+/* |
+ * This is the core of ia32-mode validator. Please note that this file |
+ * combines ragel machine description and C language actions. Please read |
+ * validator_internals.html first to understand how the whole thing is built: |
+ * it explains how the byte sequences are constructed, what constructs like |
+ * β@{}β or βREX_WRX?β mean, etc. |
+ */ |
+ |
#include <assert.h> |
#include <errno.h> |
#include <stddef.h> |
@@ -10,7 +18,7 @@ |
#include <stdlib.h> |
#include <string.h> |
-#include "native_client/src/trusted/validator_ragel/unreviewed/validator_internal.h" |
+#include "native_client/src/trusted/validator_ragel/validator_internal.h" |
/* Ignore this information: it's not used by security model in IA32 mode. */ |
#undef GET_VEX_PREFIX3 |
@@ -34,7 +42,7 @@ |
Bool ValidateChunkIA32(const uint8_t *data, size_t size, |
enum validation_options options, |
const NaClCPUFeaturesX86 *cpu_features, |
- validation_callback_func user_callback, |
+ ValidationCallbackFunc user_callback, |
void *callback_data) { |
bitmap_word valid_targets_small; |
bitmap_word jump_dests_small; |
@@ -645,7 +653,7 @@ |
goto st247; |
tr419: |
{ |
- BitmapClearBit(valid_targets, (current_position - data) - 1); |
+ MakeInvalidJumpTarget((current_position - data) - 1, valid_targets); |
instruction_start -= 3; |
instruction_info_collected |= SPECIAL_INSTRUCTION; |
} |
@@ -669,7 +677,7 @@ |
goto st247; |
tr420: |
{ |
- BitmapClearBit(valid_targets, (current_position - data) - 1); |
+ MakeInvalidJumpTarget((current_position - data) - 1, valid_targets); |
instruction_start -= 3; |
instruction_info_collected |= SPECIAL_INSTRUCTION; |
} |
@@ -689,7 +697,7 @@ |
goto st247; |
tr434: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
if ((instruction_info_collected & |
@@ -707,7 +715,7 @@ |
goto st247; |
tr443: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ SET_CPU_FEATURE(CPUFeature_x87); } |
{ |
@@ -986,7 +994,7 @@ |
goto st1; |
tr428: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st1; |
st1: |
@@ -1128,7 +1136,7 @@ |
goto st3; |
tr444: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st3; |
st3: |
@@ -1294,7 +1302,7 @@ |
goto st10; |
tr429: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st10; |
st10: |
@@ -1319,7 +1327,7 @@ |
goto st11; |
tr430: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st11; |
st11: |
@@ -1354,7 +1362,7 @@ |
goto _out; |
tr431: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st15; |
st15: |
@@ -1765,7 +1773,7 @@ |
goto st29; |
tr441: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st29; |
st29: |
@@ -1986,7 +1994,7 @@ |
goto st34; |
tr438: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st34; |
st34: |
@@ -2271,7 +2279,7 @@ |
goto tr16; |
tr460: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st46; |
st46: |
@@ -2455,7 +2463,7 @@ |
goto tr16; |
tr432: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_BRANCH_NOT_TAKEN(TRUE); |
@@ -2463,7 +2471,7 @@ |
goto st54; |
tr433: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_BRANCH_TAKEN(TRUE); |
@@ -2487,7 +2495,7 @@ |
goto tr16; |
tr439: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st56; |
st56: |
@@ -2497,7 +2505,7 @@ |
goto tr123; |
tr435: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st57; |
st57: |
@@ -2556,7 +2564,7 @@ |
goto tr16; |
tr436: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_DATA16_PREFIX(TRUE); |
@@ -3122,7 +3130,7 @@ |
goto st89; |
tr445: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st96; |
st96: |
@@ -3207,7 +3215,7 @@ |
goto tr16; |
tr450: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st98; |
st98: |
@@ -3564,7 +3572,7 @@ |
goto tr0; |
tr467: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st110; |
st110: |
@@ -3614,7 +3622,7 @@ |
goto st111; |
tr437: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st111; |
st111: |
@@ -3752,7 +3760,7 @@ |
goto st113; |
tr440: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st120; |
st120: |
@@ -3963,7 +3971,7 @@ |
goto tr16; |
tr442: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st122; |
st122: |
@@ -4546,7 +4554,7 @@ |
goto tr16; |
tr446: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st150; |
st150: |
@@ -6089,7 +6097,7 @@ |
goto tr16; |
tr447: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st200; |
st200: |
@@ -6266,7 +6274,7 @@ |
goto tr16; |
tr448: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st205; |
st205: |
@@ -6293,7 +6301,7 @@ |
goto tr16; |
tr449: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st206; |
st206: |
@@ -6320,7 +6328,7 @@ |
goto tr16; |
tr451: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st207; |
st207: |
@@ -6369,7 +6377,7 @@ |
goto tr381; |
tr452: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st208; |
st208: |
@@ -6439,7 +6447,7 @@ |
goto tr381; |
tr453: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st209; |
st209: |
@@ -6511,7 +6519,7 @@ |
goto tr383; |
tr454: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st210; |
st210: |
@@ -6582,7 +6590,7 @@ |
goto tr16; |
tr455: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st211; |
st211: |
@@ -6634,7 +6642,7 @@ |
goto tr381; |
tr456: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st212; |
st212: |
@@ -6700,7 +6708,7 @@ |
goto tr381; |
tr457: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st213; |
st213: |
@@ -6755,7 +6763,7 @@ |
goto tr381; |
tr458: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st214; |
st214: |
@@ -6813,7 +6821,7 @@ |
goto tr381; |
tr459: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st215; |
st215: |
@@ -6838,7 +6846,7 @@ |
goto tr391; |
tr461: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_LOCK_PREFIX(TRUE); |
@@ -6942,7 +6950,7 @@ |
goto tr16; |
tr462: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_REPNZ_PREFIX(TRUE); |
@@ -7022,7 +7030,7 @@ |
goto tr408; |
tr463: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
{ |
SET_REPZ_PREFIX(TRUE); |
@@ -7089,7 +7097,7 @@ |
goto tr16; |
tr464: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st229; |
st229: |
@@ -7158,7 +7166,7 @@ |
goto tr0; |
tr465: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st230; |
st230: |
@@ -7227,7 +7235,7 @@ |
goto tr0; |
tr466: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st231; |
st231: |
@@ -7258,7 +7266,7 @@ |
goto tr16; |
tr468: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st232; |
st232: |
@@ -7461,7 +7469,7 @@ |
goto tr16; |
tr469: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st234; |
st234: |
@@ -7664,7 +7672,7 @@ |
goto tr16; |
tr470: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st236; |
st236: |
@@ -7867,7 +7875,7 @@ |
goto tr16; |
tr471: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st238; |
st238: |
@@ -8070,7 +8078,7 @@ |
goto tr16; |
tr472: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st240; |
st240: |
@@ -8273,7 +8281,7 @@ |
goto tr16; |
tr473: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st242; |
st242: |
@@ -8476,7 +8484,7 @@ |
goto tr16; |
tr474: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st244; |
st244: |
@@ -8679,7 +8687,7 @@ |
goto tr16; |
tr475: |
{ |
- BitmapSetBit(valid_targets, current_position - data); |
+ MakeJumpTargetValid(current_position - data, valid_targets); |
} |
goto st246; |
st246: |