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

Unified Diff: src/trusted/validator_ragel/dfa_validate_common.c

Issue 1234393005: A mechanism to identify/forbid/"rewrite" non-temporal instructions (and other) (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Renaming Created 5 years, 5 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/dfa_validate_common.c
diff --git a/src/trusted/validator_ragel/dfa_validate_common.c b/src/trusted/validator_ragel/dfa_validate_common.c
index 330a0ce2c44fc128ff1f7736740f2da3b9f0d80a..0bf579790e59a7ac90626eac9fb4782b15289775 100644
--- a/src/trusted/validator_ragel/dfa_validate_common.c
+++ b/src/trusted/validator_ragel/dfa_validate_common.c
@@ -33,16 +33,26 @@ Bool NaClDfaProcessValidationError(const uint8_t *begin, const uint8_t *end,
return FALSE;
}
-Bool NaClDfaStubOutCPUUnsupportedInstruction(const uint8_t *begin,
- const uint8_t *end,
- uint32_t info,
- void *callback_data) {
+Bool NaClDfaForbidOrRewriteInstruction(const uint8_t *begin,
+ const uint8_t *end,
+ uint32_t info,
+ void *callback_data) {
+ struct ForbidRewriteCallbackData *data = callback_data;
Petr Hosek 2015/07/20 23:58:57 Shouldn't you doing a cast here? Is this actually
ruiq 2015/07/21 00:39:44 This is valid in C, while not in C++. In C++, an e
Petr Hosek 2015/07/21 00:46:58 I'd still include an explicit cast, even if this p
ruiq 2015/07/21 02:52:24 I left this as it is: 1) It is not ambiguous; 2) i
/* Stub-out instructions unsupported on this CPU, but valid on other CPUs. */
if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) {
- int *did_stubout = callback_data;
- *did_stubout = 1;
+ data->did_rewrite = 1;
memset((uint8_t *)begin, NACL_HALT_OPCODE, end - begin);
return TRUE;
+ } else if ((info & VALIDATION_ERRORS_MASK) == FORBID_OR_REWRITE_INSTRUCTION) {
+ if (data->pnacl_mode)
+ return FALSE;
+ else {
+ /* TODO: rewrite instruction. For now, we keep the original instruction
Petr Hosek 2015/07/20 23:58:57 Nit: Please include your LDAP in the TODO, i.e. "T
ruiq 2015/07/21 02:52:24 Done.
+ * and indicate validation success, which is consistent with current
+ * validation results. */
+ data->did_rewrite = 1;
+ return TRUE;
+ }
} else {
return FALSE;
}

Powered by Google App Engine
This is Rietveld 408576698