Index: kernel/arch/amd64/src/asm.S
===================================================================
--- kernel/arch/amd64/src/asm.S	(revision 28f4adbc5088d8d67ea408f56eb3b35838031e6a)
+++ kernel/arch/amd64/src/asm.S	(revision e06ef614e48f0a39c138cf94e056639712adc95e)
@@ -95,5 +95,5 @@
 memcpy_from_uspace_failover_address:
 memcpy_to_uspace_failover_address:
-	xorq %rax, %rax         /* return 0, failure */
+	xorl %eax, %eax         /* return 0, failure */
 	ret
 
@@ -143,5 +143,5 @@
 
 set_efer_flag:
-	movq $0xc0000080, %rcx
+	movl $0xc0000080, %ecx
 	rdmsr
 	btsl %edi, %eax
@@ -150,5 +150,5 @@
 
 read_efer_flag:
-	movq $0xc0000080, %rcx
+	movl $0xc0000080, %ecx
 	rdmsr
 	ret
@@ -243,5 +243,5 @@
 	 * Stop stack traces here if we came from userspace.
 	 */
-	xorq %rdx, %rdx
+	xorl %edx, %edx
 	cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
 	cmovnzq %rdx, %rbp
@@ -386,4 +386,16 @@
 	movq ISTATE_OFFSET_RSP(%rsp), %rsp
 
+	/*
+	 * Clear the rest of the scratch registers to prevent information leak.
+	 * The 32-bit XOR on the low GPRs actually clears the entire 64-bit
+	 * register and the instruction is shorter.
+	 */
+	xorl %edx, %edx
+	xorl %esi, %esi
+	xorl %edi, %edi
+	xorq %r8, %r8
+	xorq %r9, %r9
+	xorq %r10, %r10
+
 	sysretq
 
@@ -413,5 +425,5 @@
 	movq %rdi, %rsi
 	movq $(PA2KA(0xb8000)), %rdi  /* base of EGA text mode memory */
-	xorq %rax, %rax
+	xorl %eax, %eax
 	
 	/* Read bits 8 - 15 of the cursor address */
@@ -493,10 +505,10 @@
 		movq $(PA2KA(0xb80a0)), %rsi
 		movq $(PA2KA(0xb8000)), %rdi
-		movq $480, %rcx
+		movl $480, %ecx
 		rep movsq
 		
 		/* Clear the 24th row */
-		xorq %rax, %rax
-		movq $20, %rcx
+		xorl %eax, %eax
+		movl $20, %ecx
 		rep stosq
 		
Index: kernel/arch/amd64/src/boot/boot.S
===================================================================
--- kernel/arch/amd64/src/boot/boot.S	(revision 28f4adbc5088d8d67ea408f56eb3b35838031e6a)
+++ kernel/arch/amd64/src/boot/boot.S	(revision e06ef614e48f0a39c138cf94e056639712adc95e)
@@ -516,10 +516,10 @@
 		movq $(PA2KA(0xb80a0)), %rsi
 		movq $(PA2KA(0xb8000)), %rdi
-		movq $480, %rcx
+		movl $480, %ecx
 		rep movsq
 		
 		/* Clear the 24th row */
-		xorq %rax, %rax
-		movq $20, %rcx
+		xorl %eax, %eax
+		movl $20, %ecx
 		rep stosq
 		
Index: kernel/arch/amd64/src/context.S
===================================================================
--- kernel/arch/amd64/src/context.S	(revision 28f4adbc5088d8d67ea408f56eb3b35838031e6a)
+++ kernel/arch/amd64/src/context.S	(revision e06ef614e48f0a39c138cf94e056639712adc95e)
@@ -45,6 +45,6 @@
 	CONTEXT_SAVE_ARCH_CORE %rdi %rdx
 	
-	xorq %rax, %rax       # context_save returns 1
-	incq %rax
+	xorl %eax, %eax       # context_save returns 1
+	incl %eax
 	ret
 
@@ -60,4 +60,4 @@
 	movq %rdx, (%rsp)
 	
-	xorq %rax, %rax       # context_restore returns 0
+	xorl %eax, %eax       # context_restore returns 0
 	ret
Index: uspace/lib/c/arch/amd64/src/entry.s
===================================================================
--- uspace/lib/c/arch/amd64/src/entry.s	(revision 28f4adbc5088d8d67ea408f56eb3b35838031e6a)
+++ uspace/lib/c/arch/amd64/src/entry.s	(revision e06ef614e48f0a39c138cf94e056639712adc95e)
@@ -42,5 +42,5 @@
 	#
 	pushq $0
-	mov %rsp, %rbp
+	movq %rsp, %rbp
 	
 	# %rdi was deliberately chosen as the first argument is also in %rdi
Index: uspace/lib/c/arch/amd64/src/fibril.S
===================================================================
--- uspace/lib/c/arch/amd64/src/fibril.S	(revision 28f4adbc5088d8d67ea408f56eb3b35838031e6a)
+++ uspace/lib/c/arch/amd64/src/fibril.S	(revision e06ef614e48f0a39c138cf94e056639712adc95e)
@@ -49,6 +49,6 @@
 	movq %rax, OFFSET_TLS(%rdi)
 		
-	xorq %rax,%rax		# context_save returns 1
-	incq %rax
+	xorl %eax, %eax		# context_save returns 1
+	incl %eax
 	ret
 
@@ -67,7 +67,7 @@
 	# Set thread local storage
 	movq OFFSET_TLS(%rdi), %rdi   # Set arg1 to TLS addr
-	movq $1, %rax		# SYS_TLS_SET
+	movl $1, %eax		# SYS_TLS_SET
 	syscall
 
-	xorq %rax,%rax		# context_restore returns 0
+	xorl %eax, %eax		# context_restore returns 0
 	ret
