Arch specific vmapi tests.

Move GICv3 tests under aarch64 and add an initial SMCCC test to cover
the issue fixed in I08fd88a8e426bd85c1df2351fc79f96913a3f217.

Change-Id: I6aaec36fda55fa55fd287587986b89b11c8021cf
diff --git a/kokoro/ubuntu/test.sh b/kokoro/ubuntu/test.sh
index c29a1fe..632d4f4 100755
--- a/kokoro/ubuntu/test.sh
+++ b/kokoro/ubuntu/test.sh
@@ -62,7 +62,8 @@
   | tee $OUT/kokoro_log/unit_tests/sponge_log.log
 
 $HFTEST arch_test
-$HFTEST hafnium --initrd test/vmapi/gicv3/gicv3_test
+$HFTEST hafnium --initrd test/vmapi/arch/aarch64/aarch64_test
+$HFTEST hafnium --initrd test/vmapi/arch/aarch64/gicv3/gicv3_test
 $HFTEST hafnium --initrd test/vmapi/primary_only/primary_only_test
 $HFTEST hafnium --initrd test/vmapi/primary_with_secondaries/primary_with_secondaries_test
 $HFTEST hafnium --initrd test/linux/linux_test --vm_args "rdinit=/test_binary --"
diff --git a/project/reference b/project/reference
index 653261a..3fe2408 160000
--- a/project/reference
+++ b/project/reference
@@ -1 +1 @@
-Subproject commit 653261a75f4ef3f5a5335660b2d59df23b88d600
+Subproject commit 3fe2408c6b10192ee285b611062f9eae814577c5
diff --git a/test/vmapi/BUILD.gn b/test/vmapi/BUILD.gn
index 2dcfab0..7cbb8cd 100644
--- a/test/vmapi/BUILD.gn
+++ b/test/vmapi/BUILD.gn
@@ -13,11 +13,13 @@
 # limitations under the License.
 
 import("//build/image/image.gni")
+import("//build/toolchain/platform.gni")
 
 group("vmapi") {
   testonly = true
 
   deps = [
+    "arch/${plat_arch}:arch",
     "primary_only:primary_only_test",
     "primary_with_secondaries:primary_with_secondaries_test",
   ]
diff --git a/test/vmapi/arch/aarch64/BUILD.gn b/test/vmapi/arch/aarch64/BUILD.gn
new file mode 100644
index 0000000..a43f30a
--- /dev/null
+++ b/test/vmapi/arch/aarch64/BUILD.gn
@@ -0,0 +1,45 @@
+# Copyright 2019 The Hafnium Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/image/image.gni")
+
+group("arch") {
+  testonly = true
+
+  deps = [
+    ":aarch64_test",
+  ]
+}
+
+# Tests specific to aarch64.
+vm_kernel("aarch64_test_vm") {
+  testonly = true
+
+  sources = [
+    "smccc.c",
+  ]
+
+  deps = [
+    "//src/arch/aarch64:arch",
+    "//test/hftest:hftest_primary_vm",
+  ]
+}
+
+initrd("aarch64_test") {
+  testonly = true
+
+  manifest = "manifest.dts"
+  primary_name = "aarch64_test"
+  primary_vm = ":aarch64_test_vm"
+}
diff --git a/test/vmapi/gicv3/BUILD.gn b/test/vmapi/arch/aarch64/gicv3/BUILD.gn
similarity index 100%
rename from test/vmapi/gicv3/BUILD.gn
rename to test/vmapi/arch/aarch64/gicv3/BUILD.gn
diff --git a/test/vmapi/gicv3/busy_secondary.c b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
similarity index 100%
rename from test/vmapi/gicv3/busy_secondary.c
rename to test/vmapi/arch/aarch64/gicv3/busy_secondary.c
diff --git a/test/vmapi/gicv3/gicv3.c b/test/vmapi/arch/aarch64/gicv3/gicv3.c
similarity index 100%
rename from test/vmapi/gicv3/gicv3.c
rename to test/vmapi/arch/aarch64/gicv3/gicv3.c
diff --git a/test/vmapi/gicv3/inc/gicv3.h b/test/vmapi/arch/aarch64/gicv3/inc/gicv3.h
similarity index 100%
rename from test/vmapi/gicv3/inc/gicv3.h
rename to test/vmapi/arch/aarch64/gicv3/inc/gicv3.h
diff --git a/test/vmapi/gicv3/interrupts.c b/test/vmapi/arch/aarch64/gicv3/interrupts.c
similarity index 100%
rename from test/vmapi/gicv3/interrupts.c
rename to test/vmapi/arch/aarch64/gicv3/interrupts.c
diff --git a/test/vmapi/gicv3/manifest.dts b/test/vmapi/arch/aarch64/gicv3/manifest.dts
similarity index 100%
rename from test/vmapi/gicv3/manifest.dts
rename to test/vmapi/arch/aarch64/gicv3/manifest.dts
diff --git a/test/vmapi/gicv3/services/BUILD.gn b/test/vmapi/arch/aarch64/gicv3/services/BUILD.gn
similarity index 100%
rename from test/vmapi/gicv3/services/BUILD.gn
rename to test/vmapi/arch/aarch64/gicv3/services/BUILD.gn
diff --git a/test/vmapi/gicv3/services/busy.c b/test/vmapi/arch/aarch64/gicv3/services/busy.c
similarity index 100%
rename from test/vmapi/gicv3/services/busy.c
rename to test/vmapi/arch/aarch64/gicv3/services/busy.c
diff --git a/test/vmapi/gicv3/services/common.c b/test/vmapi/arch/aarch64/gicv3/services/common.c
similarity index 100%
rename from test/vmapi/gicv3/services/common.c
rename to test/vmapi/arch/aarch64/gicv3/services/common.c
diff --git a/test/vmapi/gicv3/services/common.h b/test/vmapi/arch/aarch64/gicv3/services/common.h
similarity index 100%
rename from test/vmapi/gicv3/services/common.h
rename to test/vmapi/arch/aarch64/gicv3/services/common.h
diff --git a/test/vmapi/gicv3/services/systemreg.c b/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
similarity index 100%
rename from test/vmapi/gicv3/services/systemreg.c
rename to test/vmapi/arch/aarch64/gicv3/services/systemreg.c
diff --git a/test/vmapi/gicv3/services/timer.c b/test/vmapi/arch/aarch64/gicv3/services/timer.c
similarity index 100%
rename from test/vmapi/gicv3/services/timer.c
rename to test/vmapi/arch/aarch64/gicv3/services/timer.c
diff --git a/test/vmapi/gicv3/timer_secondary.c b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
similarity index 100%
rename from test/vmapi/gicv3/timer_secondary.c
rename to test/vmapi/arch/aarch64/gicv3/timer_secondary.c
diff --git a/test/vmapi/arch/aarch64/manifest.dts b/test/vmapi/arch/aarch64/manifest.dts
new file mode 100644
index 0000000..d77879c
--- /dev/null
+++ b/test/vmapi/arch/aarch64/manifest.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2019 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/dts-v1/;
+/plugin/;
+
+&{/} {
+	hypervisor {
+		compatible = "hafnium,hafnium";
+		vm1 {
+			debug_name = "aarch64_test";
+			kernel_filename = "aarch64_test";
+		};
+	};
+};
diff --git a/test/vmapi/arch/aarch64/smccc.c b/test/vmapi/arch/aarch64/smccc.c
new file mode 100644
index 0000000..39bc764
--- /dev/null
+++ b/test/vmapi/arch/aarch64/smccc.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vmapi/hf/call.h"
+
+#include "hftest.h"
+
+TEST(smccc, hf_debug_log_zero_or_unchanged)
+{
+	register uint64_t r0 __asm__("x0") = HF_DEBUG_LOG;
+	register uint64_t r1 __asm__("x1") = '\n';
+	register uint64_t r2 __asm__("x2") = UINT64_C(0x2222222222222222);
+	register uint64_t r3 __asm__("x3") = UINT64_C(0x3333333333333333);
+	register uint64_t r4 __asm__("x4") = UINT64_C(0x4444444444444444);
+	register uint64_t r5 __asm__("x5") = UINT64_C(0x5555555555555555);
+	register uint64_t r6 __asm__("x6") = UINT64_C(0x6666666666666666);
+	register uint64_t r7 __asm__("x7") = UINT64_C(0x7777777777777777);
+
+	__asm__ volatile(
+		"smc #0"
+		: /* Output registers, also used as inputs ('+' constraint). */
+		"+r"(r0), "+r"(r1), "+r"(r2), "+r"(r3), "+r"(r4), "+r"(r5),
+		"+r"(r6), "+r"(r7));
+
+	EXPECT_EQ(r0, 0);
+	EXPECT_EQ(r1, 0);
+	EXPECT_EQ(r2, 0);
+	EXPECT_EQ(r3, 0);
+	EXPECT_EQ(r4, UINT64_C(0x4444444444444444));
+	EXPECT_EQ(r5, UINT64_C(0x5555555555555555));
+	EXPECT_EQ(r6, UINT64_C(0x6666666666666666));
+	EXPECT_EQ(r7, UINT64_C(0x7777777777777777));
+}