changeset 13561:7ec47d2d30bc

1971 i86 kernel should be more careful when casting pointers Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Garrett D'Amore <garrett@nexenta.com>
author Richard Lowe <richlowe@richlowe.net>
date Sun, 15 May 2011 09:25:05 +0100
parents 61e2c882ccf8
children 7bae99960928
files usr/src/uts/i86pc/dboot/dboot_startkern.c usr/src/uts/i86pc/os/mp_pc.c usr/src/uts/intel/sys/segments.h
diffstat 3 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/i86pc/dboot/dboot_startkern.c	Tue Jan 10 20:33:03 2012 -0500
+++ b/usr/src/uts/i86pc/dboot/dboot_startkern.c	Sun May 15 09:25:05 2011 +0100
@@ -237,7 +237,7 @@
 		memlists[i].next = 0;
 		memlists[i - 1].next = (native_ptr_t)(uintptr_t)(memlists + i);
 	}
-	bi->bi_phys_install = (native_ptr_t)memlists;
+	bi->bi_phys_install = (native_ptr_t)(uintptr_t)memlists;
 	DBG(bi->bi_phys_install);
 }
 
@@ -258,7 +258,7 @@
 		rsvdmemlists[i - 1].next =
 		    (native_ptr_t)(uintptr_t)(rsvdmemlists + i);
 	}
-	bi->bi_rsvdmem = (native_ptr_t)rsvdmemlists;
+	bi->bi_rsvdmem = (native_ptr_t)(uintptr_t)rsvdmemlists;
 	DBG(bi->bi_rsvdmem);
 }
 
@@ -668,7 +668,7 @@
 		pcimemlists[i - 1].next =
 		    (native_ptr_t)(uintptr_t)(pcimemlists + i);
 	}
-	bi->bi_pcimem = (native_ptr_t)pcimemlists;
+	bi->bi_pcimem = (native_ptr_t)(uintptr_t)pcimemlists;
 	DBG(bi->bi_pcimem);
 }
 
@@ -808,7 +808,7 @@
 	 * we'll build the module list while we're walking through here
 	 */
 	DBG_MSG("\nFinding Modules\n");
-	check_higher((paddr_t)&_end);
+	check_higher((paddr_t)(uintptr_t)&_end);
 	for (mod = (mb_module_t *)(mb_info->mods_addr), i = 0;
 	    i < mb_info->mods_count;
 	    ++mod, ++i) {
@@ -826,7 +826,7 @@
 
 		check_higher(mod->mod_end);
 	}
-	bi->bi_modules = (native_ptr_t)modules;
+	bi->bi_modules = (native_ptr_t)(uintptr_t)modules;
 	DBG(bi->bi_modules);
 	bi->bi_module_cnt = mb_info->mods_count;
 	DBG(bi->bi_module_cnt);
@@ -911,7 +911,7 @@
 		pcimemlists[0].size = pci_hi_limit - pcimemlists[0].addr;
 		pcimemlists[0].next = 0;
 		pcimemlists[0].prev = 0;
-		bi->bi_pcimem = (native_ptr_t)pcimemlists;
+		bi->bi_pcimem = (native_ptr_t)(uintptr_t)pcimemlists;
 		DBG(bi->bi_pcimem);
 	} else {
 		dboot_panic("No memory info from boot loader!!!");
--- a/usr/src/uts/i86pc/os/mp_pc.c	Tue Jan 10 20:33:03 2012 -0500
+++ b/usr/src/uts/i86pc/os/mp_pc.c	Sun May 15 09:25:05 2011 +0100
@@ -165,7 +165,8 @@
 	 * mapped address, we need to calculate it here.
 	 */
 	rm->rm_longmode64_addr = rm_platter_pa +
-	    ((uint32_t)long_mode_64 - (uint32_t)real_mode_start_cpu);
+	    (uint32_t)((uintptr_t)long_mode_64 -
+	    (uintptr_t)real_mode_start_cpu);
 #endif	/* __amd64 */
 }
 
--- a/usr/src/uts/intel/sys/segments.h	Tue Jan 10 20:33:03 2012 -0500
+++ b/usr/src/uts/intel/sys/segments.h	Sun May 15 09:25:05 2011 +0100
@@ -352,8 +352,8 @@
 	uint32_t sgd_hioffset:16;	/* code seg off 31:16 */
 } gate_desc_t;
 
-#define	GATESEG_GETOFFSET(sgd)		((sgd)->sgd_looffset |		\
-					(sgd)->sgd_hioffset << 16)
+#define	GATESEG_GETOFFSET(sgd)	((uintptr_t)((sgd)->sgd_looffset |	\
+				(sgd)->sgd_hioffset << 16))
 
 #else	/* __amd64 */
 
@@ -380,9 +380,9 @@
 	uint64_t sgd_resv3:19;		/* unused, ignored */
 } gate_desc_t;
 
-#define	GATESEG_GETOFFSET(sgd)		((sgd)->sgd_looffset |		\
-					(sgd)->sgd_hioffset << 16 |	\
-					(sgd)->sgd_hi64offset << 32)
+#define	GATESEG_GETOFFSET(sgd)	((uintptr_t)((sgd)->sgd_looffset |	\
+				(sgd)->sgd_hioffset << 16 |		\
+				(uint64_t)((sgd)->sgd_hi64offset) << 32))
 
 #endif	/* __amd64 */