Skip to contentSkip to conversation

Fix kernel panic in check_ivt

parisc-linux Grant Grundler 3 participants 3 messages Jun 4, 2007 2 messages not in the archive PA-RISC architecture

lore
Share & tools
lore

Grant Grundler

author Acked-by
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Kyle McMartin

From: Kyle McMartin <[email protected]>

check_ivt had some seriously broken code wrt function pointers on parisc64. Instead of referencing the hpmc code via a function pointer, export symbols and reference it as a const array.

Thanks to jda for pointing out the broken 64-bit func ptr handling.

This looks good to me...please push to your git tree. Tested on 32-bit (c3k).

thanks (jda and kyle),
grant

Quoted 64 lines
---
 arch/parisc/kernel/hpmc.S  |    7 ++++---
 arch/parisc/kernel/traps.c |    8 ++++----
 2 files changed, 8 insertions(+), 7 deletions(-)
arch/parisc/kernel/hpmc.S +4 -3
index d8baa15..abda491 100644
@@ -79,6 +79,8 @@ END(hpmc_pim_data)
 	.text
 
 	.import intr_save, code
+	.export __os_hpmc, data
+__os_hpmc:
 ENTRY(os_hpmc)
 
 	/*
@@ -295,8 +297,7 @@ os_hpmc_6:
 	b .
 	nop
 ENDPROC(os_hpmc)
-
-	/* this label used to compute os_hpmc checksum */
-ENTRY(os_hpmc_end)
+__os_hpmc_end:
+	.export __os_hpmc_end, data 	/* this label used to compute os_hpmc checksum */
 
 	nop
arch/parisc/kernel/traps.c +4 -4
index 0ba1d3d..e8b977a 100644
@@ -807,8 +807,8 @@ int __init check_ivt(void *iva)
 	u32 *ivap;
 	u32 *hpmcp;
 	u32 length;
-	extern void os_hpmc(void);
-	extern void os_hpmc_end(void);
+	extern const u32 __os_hpmc[];
+	extern const u32 __os_hpmc_end[];
 
 	if (strcmp((char *)iva, "cows can fly"))
 		return -1;
@@ -820,10 +820,10 @@ int __init check_ivt(void *iva)
 
 	/* Compute Checksum for HPMC handler */
 
-	length = (u32)((unsigned long)os_hpmc_end - (unsigned long)os_hpmc);
+	length = __os_hpmc_end - __os_hpmc;
 	ivap[7] = length;
 
-	hpmcp = (u32 *)os_hpmc;
+	hpmcp = (u32 *)__os_hpmc;
 
 	for (i=0; i<length/4; i++)
 	    check += *hpmcp++;
Signature · 6 lines
1.5.1.3

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Kyle McMartin

From: Kyle McMartin <[email protected]>

check_ivt had some seriously broken code wrt function pointers on parisc64. Instead of referencing the hpmc code via a function pointer, export symbols and reference it as a const array.

Thanks to jda for pointing out the broken 64-bit func ptr handling.

Better(*) patch below...

[ Well, simpler is better, right? ]

arch/parisc/kernel/hpmc.S +1 -4
index d8baa15..43b41df 100644
@@ -295,8 +295,5 @@ os_hpmc_6:
 	b .
 	nop
 ENDPROC(os_hpmc)
-
-	/* this label used to compute os_hpmc checksum */
-ENTRY(os_hpmc_end)
-
+ENTRY(os_hpmc_end)	/* this label used to compute os_hpmc checksum */
 	nop
arch/parisc/kernel/traps.c +4 -3
index 0ba1d3d..c3ec9f1 100644
@@ -802,13 +802,14 @@ void handle_interruption(int code, struct pt_regs *regs)
 
 int __init check_ivt(void *iva)
 {
+	extern const u32 os_hpmc[];
+	extern const u32 os_hpmc_end[];
+
 	int i;
 	u32 check = 0;
 	u32 *ivap;
 	u32 *hpmcp;
 	u32 length;
-	extern void os_hpmc(void);
-	extern void os_hpmc_end(void);
 
 	if (strcmp((char *)iva, "cows can fly"))
 		return -1;
@@ -820,7 +821,7 @@ int __init check_ivt(void *iva)
 
 	/* Compute Checksum for HPMC handler */
 
-	length = (u32)((unsigned long)os_hpmc_end - (unsigned long)os_hpmc);
+	length = os_hpmc_end - os_hpmc;
 	ivap[7] = length;
 
 	hpmcp = (u32 *)os_hpmc;

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

#4 lore raw
In reply to a message not in the archive

Review void handle_interruption(int code, struct pt_regs *regs) · line 806

Quoted 6 lines · Kyle McMartin
(quoted diff) +2 -0
@@ -802,13 +802,14 @@ void handle_interruption(int code, struct pt_regs *regs)
 
 int __init check_ivt(void *iva)
 {
+	extern const u32 os_hpmc[];
+	extern const u32 os_hpmc_end[];

Cute. If it works, it's cleaner code, so by all means.

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux