Skip to contentSkip to conversation

cleaning up the INIT code

Linux-ia64 Luck, Tony 1 participant 1 message Jun 9, 2003

lore
Share & tools
lore

Luck, Tony

author
#0 lore raw

David,

Here's a patch that does some major surgery to the INIT code (which I've been looking at a lot more closely while I was fixing the recent breakages in this area). The first thing that I noticed while working on it was that on Tiger I didn't get the pretty process backtraces on which you'd been working so hard. I just got:

"Entered OS INIT handler"

which was a lot less helpful :-) The reason for this turned out to be that the SAL on Tiger does not generate an error record for an INIT ... so the code that grabbed the error record and dissected it to find the minstate saved registers did nothing for me. SAL folks here say they don't have to create a record for an INIT (in fact they tell us whether there is a record via the "mi" bit of the processor state parameter ... see SDV pg. 2:276, and for INIT PSP.mi is 0 on Tiger).

The PAL does provide a pointer to the minstate area (see 11.3.2 PALE_CHECK Exit state, and 11.4.2 PALE_INIT Exit State), which is still valid when we get to the OS entry points for INIT and MCA. So it seems simpler to just use that, rather than go the long way round getting the error record (which doesn't even exist on Tiger).

So this patch picks up r17 (pointer to minstate) and r18 (processor state parameter) and squirrels them away in the ia64_sal_to_os_handoff_state structure ... then uses them in the INIT handler.

-Tony

===== arch/ia64/kernel/mca.c 1.32 vs edited =====

arch/ia64/kernel/mca.c +11 -24
@@ -322,7 +322,7 @@
 }
 
 void
-init_handler_platform (sal_log_processor_info_t *proc_ptr,
+init_handler_platform (pal_min_state_area_t *ms,
 		       struct pt_regs *pt, struct switch_stack *sw)
 {
 	struct unw_frame_info info;
@@ -337,10 +337,10 @@
 	 */
 	printk("Delaying for 5 seconds...\n");
 	udelay(5*1000000);
-	show_min_state(&SAL_LPI_PSI_INFO(proc_ptr)->min_state_area);
+	show_min_state(ms);
 
 	printk("Backtrace of current task (pid %d, %s)\n", current->pid, current->comm);
-	fetch_min_state(&SAL_LPI_PSI_INFO(proc_ptr)->min_state_area, pt, sw);
+	fetch_min_state(ms, pt, sw);
 	unw_init_from_interruption(&info, current, pt, sw);
 	ia64_do_show_stack(&info, NULL);
 
@@ -1240,32 +1240,19 @@
 void
 ia64_init_handler (struct pt_regs *pt, struct switch_stack *sw)
 {
-	sal_log_processor_info_t *proc_ptr;
-	ia64_err_rec_t *plog_ptr;
+	pal_min_state_area_t *ms;
 
-	printk(KERN_INFO "Entered OS INIT handler\n");
-
-	/* Get the INIT processor log */
-	if (!ia64_log_get(SAL_INFO_TYPE_INIT, (prfunc_t)printk))
-		return;                 // no record retrieved
-
-#ifdef IA64_DUMP_ALL_PROC_INFO
-	ia64_log_print(SAL_INFO_TYPE_INIT, (prfunc_t)printk);
-#endif
+	printk(KERN_INFO "Entered OS INIT handler. PSP=%lx\n",
+		ia64_sal_to_os_handoff_state.proc_state_param);
 
 	/*
-	 * get pointer to min state save area
-	 *
+	 * Address of minstate area provided by PAL is physical,
+	 * uncacheable (bit 63 set). Convert to Linux virtual
+	 * address in region 6.
 	 */
-	plog_ptr=(ia64_err_rec_t *)IA64_LOG_CURR_BUFFER(SAL_INFO_TYPE_INIT);
-	proc_ptr = &plog_ptr->proc_err;
-
-	ia64_process_min_state_save(&SAL_LPI_PSI_INFO(proc_ptr)->min_state_area);
-
-	/* Clear the INIT SAL logs now that they have been saved in the OS buffer */
-	ia64_sal_clear_state_info(SAL_INFO_TYPE_INIT);
+	ms = (pal_min_state_area_t *)(ia64_sal_to_os_handoff_state.pal_min_state | (6ul<<61));
 
-	init_handler_platform(proc_ptr, pt, sw);	/* call platform specific routines */
+	init_handler_platform(ms, pt, sw);	/* call platform specific routines */
 }
 
 /*

===== arch/ia64/kernel/mca_asm.S 1.8 vs edited =====

arch/ia64/kernel/mca_asm.S +6 -6
@@ -50,14 +50,15 @@
  *		6. GR12 = Return address to location within SAL_CHECK
  */
 #define SAL_TO_OS_MCA_HANDOFF_STATE_SAVE(_tmp)		\
-	movl	_tmp=ia64_sal_to_os_handoff_state;;	\
-	DATA_VA_TO_PA(_tmp);;				\
+	LOAD_PHYSICAL(nop 0, p0, _tmp, ia64_sal_to_os_handoff_state);; \
 	st8	[_tmp]=r1,0x08;;			\
 	st8	[_tmp]=r8,0x08;;			\
 	st8	[_tmp]=r9,0x08;;			\
 	st8	[_tmp]=r10,0x08;;			\
 	st8	[_tmp]=r11,0x08;;			\
-	st8	[_tmp]=r12,0x08
+	st8	[_tmp]=r12,0x08;;			\
+	st8	[_tmp]=r17,0x08;;			\
+	st8	[_tmp]=r18,0x08
 
 /*
  * OS_MCA_TO_SAL_HANDOFF_STATE (SAL 3.0 spec)
@@ -70,9 +71,8 @@
  *	returns ptr to SAL rtn save loc in _tmp
  */
 #define OS_MCA_TO_SAL_HANDOFF_STATE_RESTORE(_tmp)	\
-(p6)	movl	_tmp=ia64_sal_to_os_handoff_state;;	\
-(p7)	movl	_tmp=ia64_os_to_sal_handoff_state;;	\
-	DATA_VA_TO_PA(_tmp);;				\
+	LOAD_PHYSICAL(nop 0, p6, _tmp, ia64_sal_to_os_handoff_state);; \
+	LOAD_PHYSICAL(nop 0, p7, _tmp, ia64_os_to_sal_handoff_state);; \
 (p6)	movl	r8=IA64_MCA_COLD_BOOT;			\
 (p6)	movl	r10=IA64_MCA_SAME_CONTEXT;		\
 (p6)	add     _tmp=0x18,_tmp;;			\

===== include/asm-ia64/mca.h 1.7 vs edited =====

include/asm-ia64/mca.h +2 -0
@@ -92,6 +92,8 @@
 	u64		imsto_sal_check_ra;	/* Return address in SAL_CHECK while going
 						 * back to SAL from OS after MCA handling.
 						 */
+	u64		pal_min_state;		/* from PAL in r17 */
+	u64		proc_state_param;	/* from PAL in r18. See SDV 2:268 11.3.2.1 */
 } ia64_mca_sal_to_os_state_t;
 
 enum {