Skip to contentSkip to conversation

KVM: x86: clflushopt should be treated as a no-op by emulation

PATCH Applied David Edmondson 3 participants 3 messages Nov 3, 2020 – Nov 13, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 arch/x86/kvm/emulate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/kvm/emulate.c +7 -1
index 0d917eb70319..56cae1ff9e3f 100644
@@ -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 = { {
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · David Edmondson

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

Fixes 13e457e0eebf ("KVM: x86: Emulator does not decode clflush well")

FWIW,

Quoted 31 lines
---
 arch/x86/kvm/emulate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/kvm/emulate.c +7 -1
index 0d917eb70319..56cae1ff9e3f 100644
@@ -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 = { {
maintainer Applied
#2 lore raw
In reply to David Edmondson
Quoted 28 lines · David Edmondson

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

Fixes 13e457e0eebf ("KVM: x86: Emulator does not decode clflush well")
---
  arch/x86/kvm/emulate.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/kvm/emulate.c +6 -0
index 0d917eb70319..56cae1ff9e3f 100644
@@ -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;

arch/x86/kvm/emulate.c static const struct opcode group11[] = { · line 4597

Quoted 8 lines
arch/x86/kvm/emulate.c +1 -1
@@ -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