2020-11-03 12:12:18

by David Edmondson

[permalink] [raw]
Subject: [PATCH] KVM: x86: clflushopt should be treated as a no-op by emulation

The instruction emulator ignores clflush instructions, yet fails to
support clflushopt. Treat both similarly.

Fixes: 13e457e0eebf ("KVM: x86: Emulator does not decode clflush well")
Signed-off-by: David Edmondson <[email protected]>
---
arch/x86/kvm/emulate.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 0d917eb70319..56cae1ff9e3f 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4046,6 +4046,12 @@ static int em_clflush(struct x86_emulate_ctxt *ctxt)
return X86EMUL_CONTINUE;
}

+static int em_clflushopt(struct x86_emulate_ctxt *ctxt)
+{
+ /* emulating clflushopt regardless of cpuid */
+ return X86EMUL_CONTINUE;
+}
+
static int em_movsxd(struct x86_emulate_ctxt *ctxt)
{
ctxt->dst.val = (s32) ctxt->src.val;
@@ -4585,7 +4591,7 @@ static const struct opcode group11[] = {
};

static const struct gprefix pfx_0f_ae_7 = {
- I(SrcMem | ByteOp, em_clflush), N, N, N,
+ I(SrcMem | ByteOp, em_clflush), I(SrcMem | ByteOp, em_clflushopt), N, N,
};

static const struct group_dual group15 = { {
--
2.28.0


2020-11-13 11:14:40

by Joao Martins

[permalink] [raw]
Subject: Re: [PATCH] KVM: x86: clflushopt should be treated as a no-op by emulation

On 11/3/20 12:04 PM, David Edmondson wrote:
> The instruction emulator ignores clflush instructions, yet fails to
> support clflushopt. Treat both similarly.
>
> Fixes: 13e457e0eebf ("KVM: x86: Emulator does not decode clflush well")
> Signed-off-by: David Edmondson <[email protected]>

FWIW,

Reviewed-by: Joao Martins <[email protected]>

> ---
> arch/x86/kvm/emulate.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 0d917eb70319..56cae1ff9e3f 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -4046,6 +4046,12 @@ static int em_clflush(struct x86_emulate_ctxt *ctxt)
> return X86EMUL_CONTINUE;
> }
>
> +static int em_clflushopt(struct x86_emulate_ctxt *ctxt)
> +{
> + /* emulating clflushopt regardless of cpuid */
> + return X86EMUL_CONTINUE;
> +}
> +
> static int em_movsxd(struct x86_emulate_ctxt *ctxt)
> {
> ctxt->dst.val = (s32) ctxt->src.val;
> @@ -4585,7 +4591,7 @@ static const struct opcode group11[] = {
> };
>
> static const struct gprefix pfx_0f_ae_7 = {
> - I(SrcMem | ByteOp, em_clflush), N, N, N,
> + I(SrcMem | ByteOp, em_clflush), I(SrcMem | ByteOp, em_clflushopt), N, N,
> };
>
> static const struct group_dual group15 = { {
>

2020-11-13 11:31:58

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH] KVM: x86: clflushopt should be treated as a no-op by emulation

On 03/11/20 13:04, David Edmondson wrote:
> The instruction emulator ignores clflush instructions, yet fails to
> support clflushopt. Treat both similarly.
>
> Fixes: 13e457e0eebf ("KVM: x86: Emulator does not decode clflush well")
> Signed-off-by: David Edmondson <[email protected]>
> ---
> arch/x86/kvm/emulate.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 0d917eb70319..56cae1ff9e3f 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -4046,6 +4046,12 @@ static int em_clflush(struct x86_emulate_ctxt *ctxt)
> return X86EMUL_CONTINUE;
> }
>
> +static int em_clflushopt(struct x86_emulate_ctxt *ctxt)
> +{
> + /* emulating clflushopt regardless of cpuid */
> + return X86EMUL_CONTINUE;
> +}
> +
> static int em_movsxd(struct x86_emulate_ctxt *ctxt)
> {
> ctxt->dst.val = (s32) ctxt->src.val;
> @@ -4585,7 +4591,7 @@ static const struct opcode group11[] = {
> };
>
> static const struct gprefix pfx_0f_ae_7 = {
> - I(SrcMem | ByteOp, em_clflush), N, N, N,
> + I(SrcMem | ByteOp, em_clflush), I(SrcMem | ByteOp, em_clflushopt), N, N,
> };
>
> static const struct group_dual group15 = { {
>

Queued, thanks.

Paolo