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

Unified Diff: src/trusted/validator_ragel/unreviewed/dfa_validate_64.c

Issue 10883051: Add documentation for the dynamic code modifications. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator_ragel/unreviewed/dfa_validate_64.c
===================================================================
--- src/trusted/validator_ragel/unreviewed/dfa_validate_64.c (revision 9570)
+++ src/trusted/validator_ragel/unreviewed/dfa_validate_64.c (working copy)
@@ -34,7 +34,7 @@
UNREFERENCED_PARAMETER(info);
/* Instruction is unsupported by CPU, but otherwise valid. */
- if ((info & VALIDATION_ERRORS) == CPUID_UNSUPPORTED_INSTRUCTION) {
+ if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) {
*((enum NaClValidationStatus*)callback_data) =
NaClValidationFailedCpuNotSupported;
}
@@ -46,7 +46,7 @@
UNREFERENCED_PARAMETER(callback_data);
/* Stubout unsupported by CPU, but otherwise valid instructions. */
- if ((info & VALIDATION_ERRORS) == CPUID_UNSUPPORTED_INSTRUCTION) {
+ if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) {
memset((uint8_t *)begin, NACL_HALT_OPCODE, end - begin + 1);
return TRUE;
} else {
@@ -111,7 +111,7 @@
return data->copy_func(
(uint8_t *)begin_new + data->delta,
- (info & VALIDATION_ERRORS) == CPUID_UNSUPPORTED_INSTRUCTION ?
+ (info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION ?
(uint8_t *)kStubOutMem :
(uint8_t *)begin_new,
(uint8_t)(end_new - begin_new + 1));
@@ -157,7 +157,7 @@
CHECK(instruction_length <= MAX_INSTRUCTION_LENGTH);
/* Unsupported instruction must have been replaced with HLTs. */
- if ((info & VALIDATION_ERRORS) == CPUID_UNSUPPORTED_INSTRUCTION) {
+ if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) {
if (memcmp(kStubOutMem, begin_old, instruction_length) == 0) {
return TRUE;
} else {
@@ -166,11 +166,11 @@
/* If we have jump which jumps out of it's range... */
} else if (info & DIRECT_JUMP_OUT_OF_RANGE) {
/* then everything is fine if it's the only error and jump is unchanged! */
- if ((info & (VALIDATION_ERRORS & ~DIRECT_JUMP_OUT_OF_RANGE)) ||
+ if ((info & (VALIDATION_ERRORS_MASK & ~DIRECT_JUMP_OUT_OF_RANGE)) ||
memcmp(begin_new, begin_old, instruction_length) != 0)
return FALSE;
/* If instruction is not accepted then we have nothing to do here. */
- } else if (info & (VALIDATION_ERRORS | BAD_JUMP_TARGET)) {
+ } else if (info & (VALIDATION_ERRORS_MASK | BAD_JUMP_TARGET)) {
return FALSE;
/* Instruction is untouched: we are done. */
} else if (memcmp(begin_new, begin_old, instruction_length) == 0) {
@@ -180,17 +180,21 @@
return FALSE;
/* Instruction with two-bit immediate can only change these two bits. */
} else if ((info & IMMEDIATE_2BIT) == IMMEDIATE_2BIT) {
- if (memcmp(begin_new, begin_old, instruction_length - 1) != 0 ||
+ if (memcmp(begin_new, begin_old,
+ instruction_length - (info & IMMEDIATES_SIZE_MASK) - 1) != 0 ||
(*end_new & 0xfc) != (*end_old & 0xfc)) {
return FALSE;
}
+ /* Instruction's last byte is not immediate, thus it must be unchanged. */
} else if (info & LAST_BYTE_IS_NOT_IMMEDIATE) {
- if (memcmp(begin_new, begin_old, instruction_length - 1) != 0) {
+ if (memcmp(begin_new, begin_old,
+ instruction_length - (info & IMMEDIATES_SIZE_MASK) - 1) != 0 ||
+ (*end_new) != (*end_old)) {
return FALSE;
}
/* Normal instruction can only change an immediate. */
} else if (memcmp(begin_new, begin_old,
- instruction_length - (info & IMMEDIATES_SIZE)) != 0) {
+ instruction_length - (info & IMMEDIATES_SIZE_MASK)) != 0) {
return FALSE;
}
return TRUE;
« no previous file with comments | « src/trusted/validator_ragel/unreviewed/dfa_validate_32.c ('k') | src/trusted/validator_ragel/unreviewed/files32.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698