[Skiboot] [PATCH v2 21/25] asm/head: move opal entry token check into C

Nicholas Piggin npiggin at gmail.com
Sat Nov 25 01:08:30 AEDT 2017


Move opal_check_token from asm to C.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 asm/head.S  | 13 ++-----------
 core/opal.c |  7 ++++++-
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/asm/head.S b/asm/head.S
index a786ba126..68a4e7b87 100644
--- a/asm/head.S
+++ b/asm/head.S
@@ -964,7 +964,7 @@ opal_entry:
 	LOAD_ADDR_FROM_TOC(%r12, reboot_in_progress)
 	lbz	%r12,0(%r12)
 	cmpwi	%r12,0
-	bne	3f
+	bne	2f
 
 	/* Check entry */
 	mr	%r3,%r1
@@ -986,13 +986,9 @@ opal_entry:
 	 * function pointer. Also check the token.
 	 * For ELFv2 ABI, the local entry point is used so no need for r12.
 	 */
-	cmpldi	%r0,OPAL_LAST
-	bgt-	2f
 	sldi	%r0,%r0,3
 	LOAD_ADDR_FROM_TOC(%r12, opal_branch_table)
 	ldx	%r0,%r12,%r0
-	cmpldi	%r0,0
-	beq-	2f
 	mtctr	%r0
 
 	/* Jump ! */
@@ -1007,12 +1003,7 @@ opal_entry:
 	ld	%r1,STACK_GPR1(%r1)
 	blr
 
-2:	/* Bad token */
-	ld	%r3,STACK_GPR0(%r1)
-	bl	opal_bad_token
-	b	1b
-
-3:	/* Reboot in progress, reject all calls */
+2:	/* Reboot in progress, reject all calls */
 	li	%r3,OPAL_BUSY
 	b	1b
 
diff --git a/core/opal.c b/core/opal.c
index 5143692d8..4d5282791 100644
--- a/core/opal.c
+++ b/core/opal.c
@@ -118,15 +118,20 @@ static void opal_trace_entry(struct stack_frame *eframe __unused)
 #endif
 }
 
+static int64_t opal_check_token(uint64_t token);
+
 /* Called from head.S, thus no prototype */
 int64_t opal_entry_check(struct stack_frame *eframe);
 
-int64_t __attrconst opal_entry_check(struct stack_frame *eframe)
+int64_t opal_entry_check(struct stack_frame *eframe)
 {
 	uint64_t token = eframe->gpr[0];
 
 	opal_trace_entry(eframe);
 
+	if (!opal_check_token(token))
+		return opal_bad_token(token);
+
 	return OPAL_SUCCESS;
 }
 
-- 
2.15.0



More information about the Skiboot mailing list