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

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

Issue 1276543006: Experimental: Bundle revalidation inside user callback Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Fix error checking Created 5 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/validation_rewrite_32_test.cc
diff --git a/src/trusted/validator/validation_disable_nontemporals_test.cc b/src/trusted/validator/validation_rewrite_32_test.cc
similarity index 61%
copy from src/trusted/validator/validation_disable_nontemporals_test.cc
copy to src/trusted/validator/validation_rewrite_32_test.cc
index 211288d2407295b2c17043332d239f2f39ce42f9..23fa2829e5a5a095e98c6bf41a3547f2175a79e7 100644
--- a/src/trusted/validator/validation_disable_nontemporals_test.cc
+++ b/src/trusted/validator/validation_rewrite_32_test.cc
@@ -4,6 +4,7 @@
* found in the LICENSE file.
*/
+#include <string.h>
#include "gtest/gtest.h"
#include "native_client/src/shared/platform/nacl_log.h"
@@ -12,12 +13,17 @@
#define CODE_SIZE 32
#define NOP 0x90
-#define MOVNTI_CODE_SIZE 8
-// mov %edi,%edi; movnti %rax,0x68(%r15,%rdi,1)
-const char* movnti_code = "\x89\xff\x49\x0f\xc3\x44\x3f\x68";
+extern "C" {
+ extern const char no_rewrite_code[];
+ extern const char no_rewrite_code_post_rewrite[];
+ extern const char movntq_code[];
+ extern const char movntq_code_post_rewrite[];
+ extern const char movntdq_code[];
+ extern const char movntdq_code_post_rewrite[];
+}
-class ValidationDisableNonTemporalsTests : public ::testing::Test {
+class ValidationMovntRewriteTests : public ::testing::Test {
protected:
NaClValidationMetadata *metadata_ptr;
const struct NaClValidatorInterface *validator;
@@ -50,23 +56,31 @@ class ValidationDisableNonTemporalsTests : public ::testing::Test {
}
};
-TEST_F(ValidationDisableNonTemporalsTests, NotDisableNonTemporals) {
- memcpy(code_buffer, movnti_code, MOVNTI_CODE_SIZE);
+TEST_F(ValidationMovntRewriteTests, DisableNonTemporalsNoRewrite) {
+ memcpy(code_buffer, no_rewrite_code, strlen(no_rewrite_code));
+ NaClValidationStatus status = Validate(NACL_DISABLE_NONTEMPORALS_X86);
+ EXPECT_EQ(NaClValidationFailed, status);
+ EXPECT_EQ(0, memcmp(code_buffer,
+ no_rewrite_code_post_rewrite,
+ strlen(no_rewrite_code_post_rewrite)));
+}
+
+TEST_F(ValidationMovntRewriteTests, RewriteMovntq) {
+ memcpy(code_buffer, movntq_code, strlen(movntq_code));
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.
EXPECT_EQ(NaClValidationSucceeded, status);
- // Code should not change.
- EXPECT_EQ(0, memcmp(code_buffer, movnti_code, MOVNTI_CODE_SIZE));
+ EXPECT_EQ(0, memcmp(code_buffer,
+ movntq_code_post_rewrite,
+ strlen(movntq_code_post_rewrite)));
}
-TEST_F(ValidationDisableNonTemporalsTests, DisableNonTemporals) {
- memcpy(code_buffer, movnti_code, MOVNTI_CODE_SIZE);
- NaClValidationStatus status = Validate(NACL_DISABLE_NONTEMPORALS_X86);
- // Disable non-temporal instructions.
- EXPECT_EQ(NaClValidationFailed, status);
- // Code should not change.
- EXPECT_EQ(0, memcmp(code_buffer, movnti_code, MOVNTI_CODE_SIZE));
+TEST_F(ValidationMovntRewriteTests, RewriteMovntdq) {
+ memcpy(code_buffer, movntdq_code, strlen(movntdq_code));
+ NaClValidationStatus status = Validate(0);
+ EXPECT_EQ(NaClValidationSucceeded, status);
+ EXPECT_EQ(0, memcmp(code_buffer,
+ movntdq_code_post_rewrite,
+ strlen(movntdq_code_post_rewrite)));
}
int main(int argc, char *argv[]) {
« no previous file with comments | « src/trusted/validator/validation_disable_nontemporals_test.cc ('k') | src/trusted/validator/validation_rewrite_32_test_data.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698