* [PATCH] make distinction between repeat prefixes F3 and F2
@ 2007-11-22 10:32 Guillaume Thouvenin
[not found] ` <20071122113209.1a6ed6c1-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Guillaume Thouvenin @ 2007-11-22 10:32 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Hello,
CMPS and SCAS instructions accept repeat prefixes F3 and F2. So in
order to emulate those prefixed instructions we need to be able to know
if prefixes are REP/REPE/REPZ or REPNE/REPNZ. Currently kvm doesn't make
this distinction. This patch introduces this distinction.
Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin-Z51IpKcfGtLk1uMJSBkQmQ@public.gmane.org>
---
drivers/kvm/x86_emulate.c | 4 +++-
drivers/kvm/x86_emulate.h | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index bebdcee..f8e7200 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -824,8 +824,10 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
c->lock_prefix = 1;
break;
case 0xf2: /* REPNE/REPNZ */
+ c->rep_prefix = REPNE_REPNZ;
+ break;
case 0xf3: /* REP/REPE/REPZ */
- c->rep_prefix = 1;
+ c->rep_prefix = REP_REPE_REPZ;
break;
default:
goto done_prefixes;
diff --git a/drivers/kvm/x86_emulate.h b/drivers/kvm/x86_emulate.h
index 31aa3e1..5ce4c0c 100644
--- a/drivers/kvm/x86_emulate.h
+++ b/drivers/kvm/x86_emulate.h
@@ -161,6 +161,10 @@ struct x86_emulate_ctxt {
struct decode_cache decode;
};
+/* Repeat String Operation Prefix */
+#define REP_REPE_REPZ 1
+#define REPNE_REPNZ 2
+
/* Execution mode, passed to the emulator. */
#define X86EMUL_MODE_REAL 0 /* Real mode. */
#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <20071122113209.1a6ed6c1-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
@ 2007-11-22 10:37 ` Avi Kivity
2007-11-22 11:57 ` Amit Shah
1 sibling, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2007-11-22 10:37 UTC (permalink / raw)
To: Guillaume Thouvenin; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Guillaume Thouvenin wrote:
> Hello,
>
> CMPS and SCAS instructions accept repeat prefixes F3 and F2. So in
> order to emulate those prefixed instructions we need to be able to know
> if prefixes are REP/REPE/REPZ or REPNE/REPNZ. Currently kvm doesn't make
> this distinction. This patch introduces this distinction.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <20071122113209.1a6ed6c1-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
2007-11-22 10:37 ` Avi Kivity
@ 2007-11-22 11:57 ` Amit Shah
[not found] ` <200711221727.56037.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
1 sibling, 1 reply; 7+ messages in thread
From: Amit Shah @ 2007-11-22 11:57 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Guillaume Thouvenin
* Guillaume Thouvenin wrote:
> Hello,
>
> CMPS and SCAS instructions accept repeat prefixes F3 and F2. So in
> order to emulate those prefixed instructions we need to be able to know
> if prefixes are REP/REPE/REPZ or REPNE/REPNZ. Currently kvm doesn't make
> this distinction. This patch introduces this distinction.
>
> Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin-Z51IpKcfGtLk1uMJSBkQmQ@public.gmane.org>
>
> ---
>
> drivers/kvm/x86_emulate.c | 4 +++-
> drivers/kvm/x86_emulate.h | 4 ++++
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
> index bebdcee..f8e7200 100644
> --- a/drivers/kvm/x86_emulate.c
> +++ b/drivers/kvm/x86_emulate.c
> @@ -824,8 +824,10 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct
> x86_emulate_ops *ops) c->lock_prefix = 1;
> break;
> case 0xf2: /* REPNE/REPNZ */
> + c->rep_prefix = REPNE_REPNZ;
> + break;
> case 0xf3: /* REP/REPE/REPZ */
> - c->rep_prefix = 1;
> + c->rep_prefix = REP_REPE_REPZ;
> break;
> default:
> goto done_prefixes;
> diff --git a/drivers/kvm/x86_emulate.h b/drivers/kvm/x86_emulate.h
> index 31aa3e1..5ce4c0c 100644
> --- a/drivers/kvm/x86_emulate.h
> +++ b/drivers/kvm/x86_emulate.h
> @@ -161,6 +161,10 @@ struct x86_emulate_ctxt {
> struct decode_cache decode;
> };
>
> +/* Repeat String Operation Prefix */
> +#define REP_REPE_REPZ 1
> +#define REPNE_REPNZ 2
Can you just rename this to REP and REPNE?
Does this fix the problems you saw with openbsd?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <200711221727.56037.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-22 12:25 ` Guillaume Thouvenin
[not found] ` <20071122132516.405fac81-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
2007-11-22 12:35 ` Guillaume Thouvenin
1 sibling, 1 reply; 7+ messages in thread
From: Guillaume Thouvenin @ 2007-11-22 12:25 UTC (permalink / raw)
To: Amit Shah; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
On Thu, 22 Nov 2007 17:27:55 +0530
Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> Can you just rename this to REP and REPNE?
Yes I can. I send the new patch.
> Does this fix the problems you saw with openbsd?
No not yet. It will help to make the difference between REPE prefix and
REPNE prefix because both can be added to the CMPS and SCAS
instruction. To be able to boot OpenBSD41 properly we need to emulate
CMPS.
I replaced CMPS by a NOP instruction and it allows me to boot
openbsd but it's not really an acceptable solution, it was just to
see if that the emulation of CMPS instruction was the problem.
Guillaume
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <200711221727.56037.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-22 12:25 ` Guillaume Thouvenin
@ 2007-11-22 12:35 ` Guillaume Thouvenin
1 sibling, 0 replies; 7+ messages in thread
From: Guillaume Thouvenin @ 2007-11-22 12:35 UTC (permalink / raw)
To: Amit Shah; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
CMPS and SCAS instructions accept repeat prefixes REPE and REPNE. So in
order to emulate those prefixed instructions we need to be able to know
if prefixes are REP/REPE/REPZ or REPNE/REPNZ. Currently kvm doesn't
make this distinction. This patch introduces this distinction.
Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin-Z51IpKcfGtLk1uMJSBkQmQ@public.gmane.org>
---
drivers/kvm/x86_emulate.c | 4 +++-
drivers/kvm/x86_emulate.h | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index bebdcee..3eae1b1 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -824,8 +824,10 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
c->lock_prefix = 1;
break;
case 0xf2: /* REPNE/REPNZ */
+ c->rep_prefix = REPNE;
+ break;
case 0xf3: /* REP/REPE/REPZ */
- c->rep_prefix = 1;
+ c->rep_prefix = REP;
break;
default:
goto done_prefixes;
diff --git a/drivers/kvm/x86_emulate.h b/drivers/kvm/x86_emulate.h
index 31aa3e1..2252989 100644
--- a/drivers/kvm/x86_emulate.h
+++ b/drivers/kvm/x86_emulate.h
@@ -161,6 +161,10 @@ struct x86_emulate_ctxt {
struct decode_cache decode;
};
+/* Repeat String Operation Prefix */
+#define REP 1
+#define REPNE 2
+
/* Execution mode, passed to the emulator. */
#define X86EMUL_MODE_REAL 0 /* Real mode. */
#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <20071122132516.405fac81-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
@ 2007-11-22 12:36 ` Amit Shah
2007-11-22 13:22 ` Avi Kivity
1 sibling, 0 replies; 7+ messages in thread
From: Amit Shah @ 2007-11-22 12:36 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Guillaume Thouvenin
* Guillaume Thouvenin wrote:
> On Thu, 22 Nov 2007 17:27:55 +0530
>
> Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> > Can you just rename this to REP and REPNE?
>
> Yes I can. I send the new patch.
>
> > Does this fix the problems you saw with openbsd?
>
> No not yet. It will help to make the difference between REPE prefix and
> REPNE prefix because both can be added to the CMPS and SCAS
> instruction. To be able to boot OpenBSD41 properly we need to emulate
> CMPS.
>
> I replaced CMPS by a NOP instruction and it allows me to boot
> openbsd but it's not really an acceptable solution, it was just to
> see if that the emulation of CMPS instruction was the problem.
OK, that sounds great!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] make distinction between repeat prefixes F3 and F2
[not found] ` <20071122132516.405fac81-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
2007-11-22 12:36 ` Amit Shah
@ 2007-11-22 13:22 ` Avi Kivity
1 sibling, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2007-11-22 13:22 UTC (permalink / raw)
To: Guillaume Thouvenin; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Guillaume Thouvenin wrote:
> On Thu, 22 Nov 2007 17:27:55 +0530
> Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>
>
>> Can you just rename this to REP and REPNE?
>>
>
> Yes I can. I send the new patch.
>
Too late, merged it already.
>
>
>> Does this fix the problems you saw with openbsd?
>>
>
> No not yet. It will help to make the difference between REPE prefix and
> REPNE prefix because both can be added to the CMPS and SCAS
> instruction. To be able to boot OpenBSD41 properly we need to emulate
> CMPS.
>
> I replaced CMPS by a NOP instruction and it allows me to boot
> openbsd but it's not really an acceptable solution, it was just to
> see if that the emulation of CMPS instruction was the problem.
>
What is cmps accessing? VGA memory?
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-11-22 13:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-22 10:32 [PATCH] make distinction between repeat prefixes F3 and F2 Guillaume Thouvenin
[not found] ` <20071122113209.1a6ed6c1-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
2007-11-22 10:37 ` Avi Kivity
2007-11-22 11:57 ` Amit Shah
[not found] ` <200711221727.56037.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-22 12:25 ` Guillaume Thouvenin
[not found] ` <20071122132516.405fac81-okVqAf2pJUEUMgAS9GT5UVaPQRlvutdw@public.gmane.org>
2007-11-22 12:36 ` Amit Shah
2007-11-22 13:22 ` Avi Kivity
2007-11-22 12:35 ` Guillaume Thouvenin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox