arm64: initialize secmon environment

The exception vectors were not reinitialized in secmon yet.
Add that as well as the split BSP vs non-BSP path. In doing
so bring in the cpu.c semantics for determining bsp at runtime.

BUG=chrome-os-partner:30785
BRANCH=None
TEST=Built and booted to kernel. Also noted only one CPU
     printing messages.

Change-Id: I26a7f9446f4422d2203b1d520e69f8dee9450b59
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 67f79c61c902ee614f029047255b4be35112cd32
Original-Change-Id: Ide66f13c24f5798d5983c481ce616ae2800d558c
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/218845
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: http://review.coreboot.org/9091
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/src/arch/arm64/armv8/secmon_loader.c b/src/arch/arm64/armv8/secmon_loader.c
index 4d83764..e571b51 100644
--- a/src/arch/arm64/armv8/secmon_loader.c
+++ b/src/arch/arm64/armv8/secmon_loader.c
@@ -25,6 +25,7 @@
 #include <arch/lib_helpers.h>
 #include <arch/secmon.h>
 #include <arch/spintable.h>
+#include <arch/stages.h>
 #include <console/console.h>
 #include <rmodule.h>
 #include <string.h>
@@ -85,15 +86,22 @@
 static void secmon_start(void *arg)
 {
 	uint32_t scr;
+	secmon_entry_t entry;
 	struct secmon_params *p = NULL;
 	struct secmon_runit *r = arg;
 
+	entry = r->entry;
+
 	if (cpu_is_bsp())
 		p = &r->bsp_params;
-	else if (r->secondary_params.entry != NULL)
-		p = &r->secondary_params;
+	else {
+		entry = secondary_entry_point(entry);
+		if (r->secondary_params.entry != NULL)
+			p = &r->secondary_params;
+	}
 
-	printk(BIOS_DEBUG, "CPU%x entering secure monitor.\n", cpu_info()->id);
+	printk(BIOS_DEBUG, "CPU%x entering secure monitor %p.\n",
+		cpu_info()->id, entry);
 
 	/* We want to enforce the following policies:
 	 * NS bit is set for lower EL
@@ -102,7 +110,7 @@
 	scr |= SCR_NS;
 	raw_write_scr_el3(scr);
 
-	r->entry(p);
+	entry(p);
 }
 
 void secmon_run(void (*entry)(void *), void *cb_tables)