aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexander Gilday <alexander.gilday@arm.com>2018-11-01 09:30:29 +0000
committerJacob Bramley <jacob.bramley@arm.com>2018-11-01 09:30:29 +0000
commit7560559a4efb32d9e51f12c5d17687a271f14d65 (patch)
tree97d17404f8ff705539dd065abeec2bddec4c2b44 /test
parentcb963f7bd9ac4f72d5948eef3f293a44315ecaee (diff)
Add support for Load/Store PAC instructions.
This includes the LDRAA and LDRAB instructions. Change-Id: I0fede6e215c3f8c49cf0093a83a67358a697b6c2
Diffstat (limited to 'test')
-rw-r--r--test/aarch64/test-assembler-aarch64.cc69
-rw-r--r--test/aarch64/test-disasm-aarch64.cc25
2 files changed, 94 insertions, 0 deletions
diff --git a/test/aarch64/test-assembler-aarch64.cc b/test/aarch64/test-assembler-aarch64.cc
index 90b70956..10f12911 100644
--- a/test/aarch64/test-assembler-aarch64.cc
+++ b/test/aarch64/test-assembler-aarch64.cc
@@ -3486,6 +3486,75 @@ TEST(load_store_regoffset) {
}
+TEST(load_pauth) {
+ SETUP_WITH_FEATURES(CPUFeatures::kPAuth);
+
+ uint64_t src[4] = {1, 2, 3, 4};
+ uintptr_t src_base = reinterpret_cast<uintptr_t>(src);
+
+ START();
+ __ Mov(x16, src_base);
+ __ Mov(x17, src_base);
+ __ Mov(x18, src_base + 4 * sizeof(src[0]));
+ __ Mov(x19, src_base + 4 * sizeof(src[0]));
+
+ // Add PAC codes to addresses
+ __ Pacdza(x16);
+ __ Pacdzb(x17);
+ __ Pacdza(x18);
+ __ Pacdzb(x19);
+
+ __ Ldraa(x0, MemOperand(x16));
+ __ Ldraa(x1, MemOperand(x16, sizeof(src[0])));
+ __ Ldraa(x2, MemOperand(x16, 2 * sizeof(src[0]), PreIndex));
+ __ Ldraa(x3, MemOperand(x18, -sizeof(src[0])));
+ __ Ldrab(x4, MemOperand(x17));
+ __ Ldrab(x5, MemOperand(x17, sizeof(src[0])));
+ __ Ldrab(x6, MemOperand(x17, 2 * sizeof(src[0]), PreIndex));
+ __ Ldrab(x7, MemOperand(x19, -sizeof(src[0])));
+ END();
+
+#ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
+ RUN();
+
+ ASSERT_EQUAL_64(1, x0);
+ ASSERT_EQUAL_64(2, x1);
+ ASSERT_EQUAL_64(3, x2);
+ ASSERT_EQUAL_64(4, x3);
+ ASSERT_EQUAL_64(1, x4);
+ ASSERT_EQUAL_64(2, x5);
+ ASSERT_EQUAL_64(3, x6);
+ ASSERT_EQUAL_64(4, x7);
+ ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x16);
+ ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x17);
+#endif // VIXL_INCLUDE_SIMULATOR_AARCH64
+
+ TEARDOWN();
+}
+
+
+#ifdef VIXL_NEGATIVE_TESTING
+TEST(load_pauth_negative_test) {
+ SETUP_WITH_FEATURES(CPUFeatures::kPAuth);
+
+ uint64_t src[4] = {1, 2, 3, 4};
+ uintptr_t src_base = reinterpret_cast<uintptr_t>(src);
+
+ START();
+ __ Mov(x16, src_base);
+
+ __ Pacdza(x16);
+
+ __ Ldrab(x0, MemOperand(x16));
+ END();
+
+ MUST_FAIL_WITH_MESSAGE(RUN(), "Failed to authenticate pointer.");
+
+ TEARDOWN();
+}
+#endif // VIXL_NEGATIVE_TESTING
+
+
TEST(load_store_float) {
SETUP_WITH_FEATURES(CPUFeatures::kFP);
diff --git a/test/aarch64/test-disasm-aarch64.cc b/test/aarch64/test-disasm-aarch64.cc
index 1282c38b..3e065873 100644
--- a/test/aarch64/test-disasm-aarch64.cc
+++ b/test/aarch64/test-disasm-aarch64.cc
@@ -1866,6 +1866,31 @@ TEST(load_store_pair) {
}
+TEST(load_pauth) {
+ SETUP();
+
+ COMPARE(ldraa(x0, MemOperand(x1)), "ldraa x0, [x1]");
+ COMPARE(ldraa(x2, MemOperand(sp)), "ldraa x2, [sp]");
+ COMPARE(ldraa(x3, MemOperand(x4, 64)), "ldraa x3, [x4, #64]");
+ COMPARE(ldraa(x5, MemOperand(sp, 512)), "ldraa x5, [sp, #512]");
+ COMPARE(ldraa(x6, MemOperand(x7, -256)), "ldraa x6, [x7, #-256]");
+ COMPARE(ldraa(x8, MemOperand(sp, -1024)), "ldraa x8, [sp, #-1024]");
+ COMPARE(ldraa(x9, MemOperand(x10, 2048, PreIndex)),
+ "ldraa x9, [x10, #2048]!");
+
+ COMPARE(ldrab(x9, MemOperand(x10)), "ldrab x9, [x10]");
+ COMPARE(ldrab(x11, MemOperand(sp)), "ldrab x11, [sp]");
+ COMPARE(ldrab(x12, MemOperand(x13, 64)), "ldrab x12, [x13, #64]");
+ COMPARE(ldrab(x14, MemOperand(sp, 512)), "ldrab x14, [sp, #512]");
+ COMPARE(ldrab(x15, MemOperand(x16, -256)), "ldrab x15, [x16, #-256]");
+ COMPARE(ldrab(x17, MemOperand(sp, -1024)), "ldrab x17, [sp, #-1024]");
+ COMPARE(ldrab(x18, MemOperand(x19, 2048, PreIndex)),
+ "ldrab x18, [x19, #2048]!");
+
+ CLEANUP();
+}
+
+
TEST(load_store_exclusive) {
SETUP();