Skip to contentSkip to conversation

xen: Crash domain rather than guest on unexpected PIO IO state

PATCH In review George Dunlap 2 participants 2 messages Jun 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Crash domain rather than guest on unexpected PIO IO state

Under certain conditions, if an IO gets into an unexpected state, hvmemul_do_io can return X86EMUL_UNHANDLEABLE. Unfortunately, handle_pio() does not expect this state, and calls BUG() if it sees it, crashing the host.

Other HVM io-related code crashes the guest in this case. This patch makes handle_pio() do the same.

The crash was seen when executing crash_guest in dom0 to forcibly crash the guest.

xen/arch/x86/hvm/io.c +3 -1
diff -r 782bc7b2661a -r f93006ca6d02 xen/arch/x86/hvm/io.c
@@ -239,7 +239,9 @@ int handle_pio(uint16_t port, int size, 
         curr->arch.hvm_vcpu.io_state = HVMIO_handle_pio_awaiting_completion;
         break;
     default:
-        BUG();
+        gdprintk(XENLOG_ERR, "Weird HVM ioemulation status %d.\n", rc);
+        domain_crash(curr->domain);
+        break;
     }
 
     return 1;
#1 lore raw

This is probably a candidate to backport to 4.1.x at some point.
-George

Quoted 27 lines · George Dunlap

Under certain conditions, if an IO gets into an unexpected state, hvmemul_do_io can return X86EMUL_UNHANDLEABLE. Unfortunately, handle_pio() does not expect this state, and calls BUG() if it sees it, crashing the host.

Other HVM io-related code crashes the guest in this case. This patch makes handle_pio() do the same.

The crash was seen when executing crash_guest in dom0 to forcibly crash the guest.

diff -r 782bc7b2661a -r f93006ca6d02 xen/arch/x86/hvm/io.c

xen/arch/x86/hvm/io.c +3 -1
@@ -239,7 +239,9 @@ int handle_pio(uint16_t port, int size, 
         curr->arch.hvm_vcpu.io_state = HVMIO_handle_pio_awaiting_completion;
         break;
     default:
-        BUG();
+        gdprintk(XENLOG_ERR, "Weird HVM ioemulation status %d.\n", rc);
+        domain_crash(curr->domain);
+        break;
     }
 
     return 1;