Index: arch/ia32/src/boot/boot.S
===================================================================
--- arch/ia32/src/boot/boot.S	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/boot/boot.S	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -96,6 +96,4 @@
 	orl $(1<<31), %ebx
 	movl %ebx, %cr0
-	jmp 0f
-0:
 	ret
 
Index: arch/ia32/src/mm/frame.c
===================================================================
--- arch/ia32/src/mm/frame.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/mm/frame.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -38,8 +38,4 @@
 {
 	if (config.cpu_active == 1) {
-		kernel_frames = frames;
-		kernel_frames_free = frames_free;
-		frame_kernel_bitmap = frame_bitmap;
-
 		frame_not_free(0x0);
 
Index: arch/ia32/src/mm/page.c
===================================================================
--- arch/ia32/src/mm/page.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/mm/page.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -65,6 +65,6 @@
 		 */
 		for (i = 1; i < frames; i++) {
-			map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, dba);
-			map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, dba);
+			map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, KA2PA(dba));
+			map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, KA2PA(dba));
 		}
 
@@ -113,5 +113,5 @@
 	pte = (page >> 12) & 0x3ff;	/* page table entry */
 	
-	pd = (struct page_specifier *) dba;
+	pd = (struct page_specifier *) PA2KA(dba);
 	
 	if (!pd[pde].present) {
@@ -127,5 +127,5 @@
 	}
 	
-	pt = (struct page_specifier *) (pd[pde].frame_address << 12);
+	pt = (struct page_specifier *) PA2KA((pd[pde].frame_address << 12));
 
 	pt[pte].frame_address = frame >> 12;
Index: arch/ia32/src/pm.c
===================================================================
--- arch/ia32/src/pm.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/pm.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -132,5 +132,5 @@
 void pm_init(void)
 {
-	struct descriptor *gdt_p = (struct descriptor *) gdtr.base;
+	struct descriptor *gdt_p = (struct descriptor *) PA2KA(gdtr.base);
 
 	/*
Index: arch/ia32/src/smp/ap.S
===================================================================
--- arch/ia32/src/smp/ap.S	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/smp/ap.S	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -64,4 +64,5 @@
 	movl $(ctx-0x80000000),%eax	# KA2PA((__address) &ctx)
 	movl (%eax),%esp
+	subl $0x80000000,%esp		# KA2PA(ctx.sp)
 
 	lidt idtr
Index: arch/ia32/src/smp/mps.c
===================================================================
--- arch/ia32/src/smp/mps.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/ia32/src/smp/mps.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -393,4 +393,5 @@
 }
 
+
 /*
  * Kernel thread for bringing up application processors. It becomes clear
@@ -415,9 +416,7 @@
 
 	/*
-	 * Grab a frame and map its address to page 0. This is a hack which
-	 * accesses data in frame 0. Note that page 0 is not present because
-	 * of nil reference bug catching.
-	 */
-	frame = frame_alloc(FRAME_KA);
+	 * We need to access data in frame 0.
+	 */
+	frame = frame_alloc(0);
 	map_page_to_frame(frame,0,PAGE_CACHEABLE,0);
 
@@ -474,5 +473,5 @@
 		memcopy(gdt, gdt_new, GDT_ITEMS*sizeof(struct descriptor));
 		gdtr.base = KA2PA((__address) gdt_new);
-		
+
 		if (l_apic_send_init_ipi(pr[i].l_apic_id)) {
 			/*
Index: arch/mips/src/mm/frame.c
===================================================================
--- arch/mips/src/mm/frame.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ arch/mips/src/mm/frame.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -32,6 +32,3 @@
 void frame_arch_init(void)
 {
-	kernel_frames = frames;
-	kernel_frames_free = frames_free;
-	frame_kernel_bitmap = frame_bitmap;
 }
Index: src/mm/frame.c
===================================================================
--- src/mm/frame.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ src/mm/frame.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -49,12 +49,4 @@
 count_t frame_bitmap_octets;
 
-/*
- * This is for kernel address space frames (allocated with FRAME_KA).
- * Their addresses may not interfere with user address space.
- */
-__u8 *frame_kernel_bitmap;
-count_t kernel_frames;
-count_t kernel_frames_free;
-
 static spinlock_t framelock;
 
@@ -78,15 +70,8 @@
                 memsetb((__address) frame_bitmap, frame_bitmap_octets, 0);
                 frames_free = frames;
-
-		/*
-		 * Will be properly set up by architecture dependent frame init.
-		 */
-		frame_kernel_bitmap = NULL;
-		kernel_frames_free = 0;
-		kernel_frames = 0;	
 	}
 
 	/*
-	 * No frame allocations/reservations  prior this point.
+	 * No frame allocations/reservations prior this point.
 	 */
 
@@ -109,18 +94,10 @@
 	int i;
 	pri_t pri;
-	__u8 **frame_bitmap_ptr = &frame_bitmap;
-	count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;
-	
-	if (flags & FRAME_KA) {
-		frame_bitmap_ptr = &frame_kernel_bitmap;
-		frames_ptr = &kernel_frames;
-		frames_free_ptr = &kernel_frames_free;
-	}
 	
 loop:
 	pri = cpu_priority_high();
 	spinlock_lock(&framelock);
-	if (*frames_free_ptr) {
-		for (i=0; i < *frames_ptr; i++) {
+	if (frames_free) {
+		for (i=0; i < frames; i++) {
 			int m, n;
 		
@@ -128,14 +105,7 @@
 			n = i % 8;
 
-			if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) {
-				(*frame_bitmap_ptr)[m] |= (1<<n);
-				*frames_free_ptr--;
-				if (flags & FRAME_KA) {
-					/*
-					 * frames_free_ptr points to kernel_frames_free
-					 * It is still necessary to decrement frames_free.
-					 */
-					frames_free--;
-				}
+			if ((frame_bitmap[m] & (1<<n)) == 0) {
+				frame_bitmap[m] |= (1<<n);
+				frames_free--;
 				spinlock_unlock(&framelock);
 				cpu_priority_restore(pri);
@@ -165,11 +135,4 @@
 	pri_t pri;
 	__u32 frame;
-	count_t *frames_free_ptr = &frames_free, *frames_ptr = &frames;
-	__u8 **frame_bitmap_ptr = &frame_bitmap;
-
-	if (IS_KA(addr)) {
-		frames_free_ptr = &kernel_frames_free;
-		frame_bitmap_ptr = &frame_kernel_bitmap;
-	}
 
 	pri = cpu_priority_high();
@@ -178,5 +141,5 @@
 	frame = IS_KA(addr) ? KA2PA(addr) : addr;
 	frame /= FRAME_SIZE;
-	if (frame < *frames_ptr) {
+	if (frame < frames) {
 		int m, n;
 	
@@ -184,14 +147,7 @@
 		n = frame % 8;
 	
-		if ((*frame_bitmap_ptr)[m] & (1<<n)) {
-			(*frame_bitmap_ptr)[m] &= ~(1<<n);
-			*frames_free_ptr++;
-			if (IS_KA(addr)) {
-				/*
-				 * frames_free_ptr points to kernel_frames_free
-				 * It is still necessary to increment frames_free.
-				 */
-				 frames_free++;
-			}	
+		if (frame_bitmap[m] & (1<<n)) {
+			frame_bitmap[m] &= ~(1<<n);
+			frames_free++;
 		}
 		else panic("frame already free\n");
@@ -211,6 +167,4 @@
 	pri_t pri;
 	__u32 frame;
-	count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;
-	__u8 **frame_bitmap_ptr = &frame_bitmap;
 	
 	pri = cpu_priority_high();
@@ -218,5 +172,5 @@
 	frame = IS_KA(addr) ? KA2PA(addr) : addr;
 	frame /= FRAME_SIZE;
-	if (frame < *frames_ptr) {
+	if (frame < frames) {
 		int m, n;
 
@@ -224,14 +178,7 @@
 		n = frame % 8;
 	
-		if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) {	
-			(*frame_bitmap_ptr)[m] |= (1<<n);
-			*frames_free_ptr--;	
-			if (IS_KA(addr)) {
-				/*
-				 * frames_free_ptr points to kernel_frames_free
-				 * It is still necessary to decrement frames_free.
-				 */
-				frames_free--;
-			}
+		if ((frame_bitmap[m] & (1<<n)) == 0) {	
+			frame_bitmap[m] |= (1<<n);
+			frames_free--;	
 		}
 	}
Index: src/proc/scheduler.c
===================================================================
--- src/proc/scheduler.c	(revision b0bf5012e7a657969b61b900eb1f1446c6e3acae)
+++ src/proc/scheduler.c	(revision a7a10630dfc3a5ecc03560398ae5bced5116ebb2)
@@ -44,10 +44,4 @@
 #include <arch/faddr.h>
 #include <arch/atomic.h>
-
-/*
- * NOTE ON ATOMIC READS:
- * Some architectures cannot read __u32 atomically.
- * For that reason, all accesses to nrdy and the likes must be protected by spinlock.
- */
 
 volatile int nrdy;
