diff mbox

Fix kernel pio emulation mistake

Message ID 9832F13BD22FB94A829F798DA4A8280501A1D68ACD@pdsmsx503.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dong, Eddie March 20, 2009, 9:07 a.m. UTC
> kvm_emulate_pio() returns 1 when emulation is complete,
> and 0 when emulation needs further processing in
> userspace.  So I think in both cases cannot_emulate is
> the wrong answer.  I think 'in' emulation gets it right.

OK, yes. Do u mean this?  I may misunderstand.

Thx, eddie

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

Comments

Avi Kivity March 22, 2009, 9:09 a.m. UTC | #1
Dong, Eddie wrote:
>> kvm_emulate_pio() returns 1 when emulation is complete,
>> and 0 when emulation needs further processing in
>> userspace.  So I think in both cases cannot_emulate is
>> the wrong answer.  I think 'in' emulation gets it right.
>>     
>
> OK, yes. Do u mean this?  I may misunderstand.
>
> Thx, eddie
>
> diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
> index ca91749..838fdc9 100644
> --- a/arch/x86/kvm/x86_emulate.c
> +++ b/arch/x86/kvm/x86_emulate.c
> @@ -1838,11 +1838,11 @@ special_insn:
>  		io_dir_in = 0;
>  	do_io:	if (kvm_emulate_pio(ctxt->vcpu, NULL, io_dir_in,
>  				   (c->d & ByteOp) ? 1 : c->op_bytes,
> -				   port) != 0) {
> +				   port) == 0) {
>  			c->eip = saved_eip;
> -			goto cannot_emulate;
> +			return -1;
>  		}
> -		break;
> +		return 0;
>  	case 0xf4:              /* hlt */
>  		ctxt->vcpu->arch.halt_request = 1;
>  		break; 

I think this is right, but can you add a testcase to 
user/test/x86/realmode.c?

(you need to set the emulate_invalid_guest_state module parameter to 1 
to run this test)
diff mbox

Patch

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index ca91749..838fdc9 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -1838,11 +1838,11 @@  special_insn:
 		io_dir_in = 0;
 	do_io:	if (kvm_emulate_pio(ctxt->vcpu, NULL, io_dir_in,
 				   (c->d & ByteOp) ? 1 : c->op_bytes,
-				   port) != 0) {
+				   port) == 0) {
 			c->eip = saved_eip;
-			goto cannot_emulate;
+			return -1;
 		}
-		break;
+		return 0;
 	case 0xf4:              /* hlt */
 		ctxt->vcpu->arch.halt_request = 1;
 		break; --