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

Unified Diff: src/trusted/validator/validation_disable_nontemporals_test.cc

Issue 1309953002: x86 validator: Rewrite non-temporal stores into cached memory accesses (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Review nit Created 4 years, 10 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
« no previous file with comments | « src/trusted/validator/validation_cache_test.cc ('k') | src/trusted/validator/validation_rewrite_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator/validation_disable_nontemporals_test.cc
diff --git a/src/trusted/validator/validation_disable_nontemporals_test.cc b/src/trusted/validator/validation_disable_nontemporals_test.cc
index 4932c8428e34dce3ada31bbede2fdb87c7585782..ff5ac9563e23b83fcca2a3f082d75387e602a383 100644
--- a/src/trusted/validator/validation_disable_nontemporals_test.cc
+++ b/src/trusted/validator/validation_disable_nontemporals_test.cc
@@ -35,11 +35,11 @@ class ValidationDisableNonTemporalsTests : public ::testing::Test {
memset(code_buffer, NOP, sizeof(code_buffer));
}
- NaClValidationStatus Validate(uint32_t flags) {
+ NaClValidationStatus Validate(uint32_t flags, Bool readonly_text) {
return validator->Validate(0, code_buffer, 32,
FALSE, /* stubout_mode */
flags,
- FALSE, /* readonly_text */
+ readonly_text,
cpu_features,
metadata_ptr,
NULL);
@@ -52,17 +52,29 @@ class ValidationDisableNonTemporalsTests : public ::testing::Test {
TEST_F(ValidationDisableNonTemporalsTests, NotDisableNonTemporals) {
memcpy(code_buffer, movnti_code, MOVNTI_CODE_SIZE);
- NaClValidationStatus status = Validate(0);
- // If we are not disabling non-temporal instructions, use the original
- // validation rule, i.e., allow them. In future, we will do rewriting.
+ NaClValidationStatus status = Validate(0, FALSE);
+ // If we are not disabling non-temporal instructions, we should rewrite
+ // them and return validation success.
EXPECT_EQ(NaClValidationSucceeded, status);
- // Code should not change.
+ // Just make sure code has changed. The rewriting itself is tested in
+ // validation_rewrite_test.cc
+ EXPECT_NE(0, memcmp(code_buffer, movnti_code, MOVNTI_CODE_SIZE));
+}
+
+TEST_F(ValidationDisableNonTemporalsTests, FailAndNotRewriteWhenReadOnlyText) {
+ memcpy(code_buffer, movnti_code, MOVNTI_CODE_SIZE);
+ NaClValidationStatus status = Validate(0, TRUE);
+ // If we are not disabling non-temporal instructions, we should rewrite
+ // them. However, readonly_text = TRUE would make the text
+ // non-modifiable. In this case, we should return validation failed, and
+ // not do rewriting.
+ EXPECT_EQ(NaClValidationFailed, status);
EXPECT_EQ(0, memcmp(code_buffer, movnti_code, MOVNTI_CODE_SIZE));
}
TEST_F(ValidationDisableNonTemporalsTests, DisableNonTemporals) {
memcpy(code_buffer, movnti_code, MOVNTI_CODE_SIZE);
- NaClValidationStatus status = Validate(NACL_DISABLE_NONTEMPORALS_X86);
+ NaClValidationStatus status = Validate(NACL_DISABLE_NONTEMPORALS_X86, FALSE);
// Disable non-temporal instructions.
EXPECT_EQ(NaClValidationFailed, status);
// Code should not change.
« no previous file with comments | « src/trusted/validator/validation_cache_test.cc ('k') | src/trusted/validator/validation_rewrite_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698