Index: kernel/arch/amd64/src/ddi/ddi.c
===================================================================
--- kernel/arch/amd64/src/ddi/ddi.c	(revision 1d3d2cf821c9a68d853e80ee2c7571d01c79b54a)
+++ kernel/arch/amd64/src/ddi/ddi.c	(revision fb04cba8d949f8b13de326b3aefd058316d54046)
@@ -126,11 +126,16 @@
 		bitmap_initialize(&iomap, CPU->arch.tss->iomap,
 		    TSS_IOMAP_SIZE * 8);
-		bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
+		bitmap_copy(&iomap, &TASK->arch.iomap, bits);
 		
+		/*
+		 * Set the trailing bits in the last byte of the map to disable
+		 * I/O access.
+		 */
+		bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
 		/*
 		 * It is safe to set the trailing eight bits because of the
 		 * extra convenience byte in TSS_IOMAP_SIZE.
 		 */
-		bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8);
+		bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
 	}
 	irq_spinlock_unlock(&TASK->lock, false);
