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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/bios/bios.S |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

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
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux