Commit 6ab0b9fe authored by Rik van Riel's avatar Rik van Riel Committed by Radim Krčmář

x86,kvm: remove KVM emulator get_fpu / put_fpu

Now that get_fpu and put_fpu do nothing, because the scheduler will
automatically load and restore the guest FPU context for us while we
are in this code (deep inside the vcpu_run main loop), we can get rid
of the get_fpu and put_fpu hooks.
Signed-off-by: default avatarRik van Riel <riel@redhat.com>
Suggested-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f775b13e
...@@ -214,8 +214,6 @@ struct x86_emulate_ops { ...@@ -214,8 +214,6 @@ struct x86_emulate_ops {
void (*halt)(struct x86_emulate_ctxt *ctxt); void (*halt)(struct x86_emulate_ctxt *ctxt);
void (*wbinvd)(struct x86_emulate_ctxt *ctxt); void (*wbinvd)(struct x86_emulate_ctxt *ctxt);
int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt); int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt);
void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */
void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */
int (*intercept)(struct x86_emulate_ctxt *ctxt, int (*intercept)(struct x86_emulate_ctxt *ctxt,
struct x86_instruction_info *info, struct x86_instruction_info *info,
enum x86_intercept_stage stage); enum x86_intercept_stage stage);
......
...@@ -1046,7 +1046,6 @@ static void fetch_register_operand(struct operand *op) ...@@ -1046,7 +1046,6 @@ static void fetch_register_operand(struct operand *op)
static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg) static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg)
{ {
ctxt->ops->get_fpu(ctxt);
switch (reg) { switch (reg) {
case 0: asm("movdqa %%xmm0, %0" : "=m"(*data)); break; case 0: asm("movdqa %%xmm0, %0" : "=m"(*data)); break;
case 1: asm("movdqa %%xmm1, %0" : "=m"(*data)); break; case 1: asm("movdqa %%xmm1, %0" : "=m"(*data)); break;
...@@ -1068,13 +1067,11 @@ static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg) ...@@ -1068,13 +1067,11 @@ static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg)
#endif #endif
default: BUG(); default: BUG();
} }
ctxt->ops->put_fpu(ctxt);
} }
static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,
int reg) int reg)
{ {
ctxt->ops->get_fpu(ctxt);
switch (reg) { switch (reg) {
case 0: asm("movdqa %0, %%xmm0" : : "m"(*data)); break; case 0: asm("movdqa %0, %%xmm0" : : "m"(*data)); break;
case 1: asm("movdqa %0, %%xmm1" : : "m"(*data)); break; case 1: asm("movdqa %0, %%xmm1" : : "m"(*data)); break;
...@@ -1096,12 +1093,10 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, ...@@ -1096,12 +1093,10 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,
#endif #endif
default: BUG(); default: BUG();
} }
ctxt->ops->put_fpu(ctxt);
} }
static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
{ {
ctxt->ops->get_fpu(ctxt);
switch (reg) { switch (reg) {
case 0: asm("movq %%mm0, %0" : "=m"(*data)); break; case 0: asm("movq %%mm0, %0" : "=m"(*data)); break;
case 1: asm("movq %%mm1, %0" : "=m"(*data)); break; case 1: asm("movq %%mm1, %0" : "=m"(*data)); break;
...@@ -1113,12 +1108,10 @@ static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) ...@@ -1113,12 +1108,10 @@ static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
case 7: asm("movq %%mm7, %0" : "=m"(*data)); break; case 7: asm("movq %%mm7, %0" : "=m"(*data)); break;
default: BUG(); default: BUG();
} }
ctxt->ops->put_fpu(ctxt);
} }
static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
{ {
ctxt->ops->get_fpu(ctxt);
switch (reg) { switch (reg) {
case 0: asm("movq %0, %%mm0" : : "m"(*data)); break; case 0: asm("movq %0, %%mm0" : : "m"(*data)); break;
case 1: asm("movq %0, %%mm1" : : "m"(*data)); break; case 1: asm("movq %0, %%mm1" : : "m"(*data)); break;
...@@ -1130,7 +1123,6 @@ static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) ...@@ -1130,7 +1123,6 @@ static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
case 7: asm("movq %0, %%mm7" : : "m"(*data)); break; case 7: asm("movq %0, %%mm7" : : "m"(*data)); break;
default: BUG(); default: BUG();
} }
ctxt->ops->put_fpu(ctxt);
} }
static int em_fninit(struct x86_emulate_ctxt *ctxt) static int em_fninit(struct x86_emulate_ctxt *ctxt)
...@@ -1138,9 +1130,7 @@ static int em_fninit(struct x86_emulate_ctxt *ctxt) ...@@ -1138,9 +1130,7 @@ static int em_fninit(struct x86_emulate_ctxt *ctxt)
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
return emulate_nm(ctxt); return emulate_nm(ctxt);
ctxt->ops->get_fpu(ctxt);
asm volatile("fninit"); asm volatile("fninit");
ctxt->ops->put_fpu(ctxt);
return X86EMUL_CONTINUE; return X86EMUL_CONTINUE;
} }
...@@ -1151,9 +1141,7 @@ static int em_fnstcw(struct x86_emulate_ctxt *ctxt) ...@@ -1151,9 +1141,7 @@ static int em_fnstcw(struct x86_emulate_ctxt *ctxt)
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
return emulate_nm(ctxt); return emulate_nm(ctxt);
ctxt->ops->get_fpu(ctxt);
asm volatile("fnstcw %0": "+m"(fcw)); asm volatile("fnstcw %0": "+m"(fcw));
ctxt->ops->put_fpu(ctxt);
ctxt->dst.val = fcw; ctxt->dst.val = fcw;
...@@ -1167,9 +1155,7 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt) ...@@ -1167,9 +1155,7 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
return emulate_nm(ctxt); return emulate_nm(ctxt);
ctxt->ops->get_fpu(ctxt);
asm volatile("fnstsw %0": "+m"(fsw)); asm volatile("fnstsw %0": "+m"(fsw));
ctxt->ops->put_fpu(ctxt);
ctxt->dst.val = fsw; ctxt->dst.val = fsw;
...@@ -4001,12 +3987,8 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt) ...@@ -4001,12 +3987,8 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt)
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
return rc; return rc;
ctxt->ops->get_fpu(ctxt);
rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state)); rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state));
ctxt->ops->put_fpu(ctxt);
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
return rc; return rc;
...@@ -4049,8 +4031,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt) ...@@ -4049,8 +4031,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
return rc; return rc;
ctxt->ops->get_fpu(ctxt);
if (size < __fxstate_size(16)) { if (size < __fxstate_size(16)) {
rc = fxregs_fixup(&fx_state, size); rc = fxregs_fixup(&fx_state, size);
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
...@@ -4066,8 +4046,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt) ...@@ -4066,8 +4046,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state)); rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state));
out: out:
ctxt->ops->put_fpu(ctxt);
return rc; return rc;
} }
...@@ -5317,9 +5295,7 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt) ...@@ -5317,9 +5295,7 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt)
{ {
int rc; int rc;
ctxt->ops->get_fpu(ctxt);
rc = asm_safe("fwait"); rc = asm_safe("fwait");
ctxt->ops->put_fpu(ctxt);
if (unlikely(rc != X86EMUL_CONTINUE)) if (unlikely(rc != X86EMUL_CONTINUE))
return emulate_exception(ctxt, MF_VECTOR, 0, false); return emulate_exception(ctxt, MF_VECTOR, 0, false);
......
...@@ -5251,14 +5251,6 @@ static void emulator_halt(struct x86_emulate_ctxt *ctxt) ...@@ -5251,14 +5251,6 @@ static void emulator_halt(struct x86_emulate_ctxt *ctxt)
emul_to_vcpu(ctxt)->arch.halt_request = 1; emul_to_vcpu(ctxt)->arch.halt_request = 1;
} }
static void emulator_get_fpu(struct x86_emulate_ctxt *ctxt)
{
}
static void emulator_put_fpu(struct x86_emulate_ctxt *ctxt)
{
}
static int emulator_intercept(struct x86_emulate_ctxt *ctxt, static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
struct x86_instruction_info *info, struct x86_instruction_info *info,
enum x86_intercept_stage stage) enum x86_intercept_stage stage)
...@@ -5336,8 +5328,6 @@ static const struct x86_emulate_ops emulate_ops = { ...@@ -5336,8 +5328,6 @@ static const struct x86_emulate_ops emulate_ops = {
.halt = emulator_halt, .halt = emulator_halt,
.wbinvd = emulator_wbinvd, .wbinvd = emulator_wbinvd,
.fix_hypercall = emulator_fix_hypercall, .fix_hypercall = emulator_fix_hypercall,
.get_fpu = emulator_get_fpu,
.put_fpu = emulator_put_fpu,
.intercept = emulator_intercept, .intercept = emulator_intercept,
.get_cpuid = emulator_get_cpuid, .get_cpuid = emulator_get_cpuid,
.set_nmi_mask = emulator_set_nmi_mask, .set_nmi_mask = emulator_set_nmi_mask,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment