diff mbox

[1/8] kvm tools, bios: Setup CF after returning from interrupt handler

Message ID 1313147226-12400-1-git-send-email-penberg@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Pekka Enberg Aug. 12, 2011, 11:06 a.m. UTC
While reading the code, I noticed that we don't set CF in our interrupt handler
stubs. The guest kernel may think the interrupt handler succeeded depending on
whether or not it has set CF by itself (or whether BIOS code set it by chance).

While at it, fix INT 10h handler to clear CF to make sure the guest kernel
knows the interrupt handler succeeded.

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 tools/kvm/bios/bios.S |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/bios/bios.S b/tools/kvm/bios/bios.S
index 1ddc461..4f82126 100644
--- a/tools/kvm/bios/bios.S
+++ b/tools/kvm/bios/bios.S
@@ -10,10 +10,19 @@ 
 
 #include "macro.S"
 
+#define EFLAGS_CF	(1 << 0)
+
 /*
  * fake interrupt handler, nothing can be faster ever
  */
 ENTRY(bios_intfake)
+	/*
+	 * Set CF to indicate failure. We don't want callers to think that the
+	 * interrupt handler succeeded and then treat the return values in
+	 * registers as valid data.
+	 */
+	orl	$EFLAGS_CF, 0x4(%esp)
+
 	IRET
 ENTRY_END(bios_intfake)
 
@@ -48,11 +57,12 @@  ENTRY(bios_int10)
 	popl	%es
 	popw	%fs
 
+	/* Clear CF to indicate success.  */
+	andl	$~EFLAGS_CF, 0x4(%esp)
+
 	IRET
 ENTRY_END(bios_int10)
 
-#define EFLAGS_CF	(1 << 0)
-
 ENTRY(bios_int15)
 	cmp $0xE820, %eax
 	jne 1f
@@ -76,7 +86,7 @@  ENTRY(bios_int15)
 
 	popw	%fs
 
-	/* Clear CF */
+	/* Clear CF to indicate success.  */
 	andl	$~EFLAGS_CF, 0x4(%esp)
 1:
 	IRET