diff mbox

[2/5] KVM: emulator: sysexit should #GP in non protected mode.

Message ID 1302600985-10704-2-git-send-email-gleb@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gleb Natapov April 12, 2011, 9:36 a.m. UTC
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 arch/x86/kvm/emulate.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Avi Kivity April 12, 2011, 12:17 p.m. UTC | #1
On 04/12/2011 12:36 PM, Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov<gleb@redhat.com>
> ---
>   arch/x86/kvm/emulate.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 3e8b4ab..eb4c7eb 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
>   		cs.d = 0;
>   		cs.l = 1;
>   		break;
> +	default:
> +		return emulate_gp(ctxt, 0);
>   	}

In addition, looks like the instruction is valid in 16-bit protected mode.
Gleb Natapov April 12, 2011, 12:23 p.m. UTC | #2
On Tue, Apr 12, 2011 at 03:17:51PM +0300, Avi Kivity wrote:
> On 04/12/2011 12:36 PM, Gleb Natapov wrote:
> >Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >---
> >  arch/x86/kvm/emulate.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> >
> >diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> >index 3e8b4ab..eb4c7eb 100644
> >--- a/arch/x86/kvm/emulate.c
> >+++ b/arch/x86/kvm/emulate.c
> >@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
> >  		cs.d = 0;
> >  		cs.l = 1;
> >  		break;
> >+	default:
> >+		return emulate_gp(ctxt, 0);
> >  	}
> 
> In addition, looks like the instruction is valid in 16-bit protected mode.
> 
Actually we already check for real mode and vm86 at the start of the
function, so the patch is incorrect. Will have to fix compile warning in
some other way.

--
			Gleb.
--
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
Avi Kivity April 12, 2011, 12:30 p.m. UTC | #3
On 04/12/2011 03:23 PM, Gleb Natapov wrote:
> On Tue, Apr 12, 2011 at 03:17:51PM +0300, Avi Kivity wrote:
> >  On 04/12/2011 12:36 PM, Gleb Natapov wrote:
> >  >Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >  >---
> >  >   arch/x86/kvm/emulate.c |    2 ++
> >  >   1 files changed, 2 insertions(+), 0 deletions(-)
> >  >
> >  >diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> >  >index 3e8b4ab..eb4c7eb 100644
> >  >--- a/arch/x86/kvm/emulate.c
> >  >+++ b/arch/x86/kvm/emulate.c
> >  >@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
> >  >   		cs.d = 0;
> >  >   		cs.l = 1;
> >  >   		break;
> >  >+	default:
> >  >+		return emulate_gp(ctxt, 0);
> >  >   	}
> >
> >  In addition, looks like the instruction is valid in 16-bit protected mode.
> >
> Actually we already check for real mode and vm86 at the start of the
> function, so the patch is incorrect. Will have to fix compile warning in
> some other way.
>

Right.  Note the check for vm86 is unneeded, since we have the Priv tag 
set and vm86 implies cpl 3.
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 3e8b4ab..eb4c7eb 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1973,6 +1973,8 @@  emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 		cs.d = 0;
 		cs.l = 1;
 		break;
+	default:
+		return emulate_gp(ctxt, 0);
 	}
 	cs_sel |= SELECTOR_RPL_MASK;
 	ss_sel |= SELECTOR_RPL_MASK;