Skip to content

Commit 6ab0b9f

Browse files
Rik van Rielrkrcmar
authored andcommitted
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: Rik van Riel <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent f775b13 commit 6ab0b9f

File tree

3 files changed

+0
-36
lines changed

3 files changed

+0
-36
lines changed

arch/x86/include/asm/kvm_emulate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ struct x86_emulate_ops {
214214
void (*halt)(struct x86_emulate_ctxt *ctxt);
215215
void (*wbinvd)(struct x86_emulate_ctxt *ctxt);
216216
int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt);
217-
void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */
218-
void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */
219217
int (*intercept)(struct x86_emulate_ctxt *ctxt,
220218
struct x86_instruction_info *info,
221219
enum x86_intercept_stage stage);

arch/x86/kvm/emulate.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ static void fetch_register_operand(struct operand *op)
10461046

10471047
static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg)
10481048
{
1049-
ctxt->ops->get_fpu(ctxt);
10501049
switch (reg) {
10511050
case 0: asm("movdqa %%xmm0, %0" : "=m"(*data)); break;
10521051
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)
10681067
#endif
10691068
default: BUG();
10701069
}
1071-
ctxt->ops->put_fpu(ctxt);
10721070
}
10731071

10741072
static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,
10751073
int reg)
10761074
{
1077-
ctxt->ops->get_fpu(ctxt);
10781075
switch (reg) {
10791076
case 0: asm("movdqa %0, %%xmm0" : : "m"(*data)); break;
10801077
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,
10961093
#endif
10971094
default: BUG();
10981095
}
1099-
ctxt->ops->put_fpu(ctxt);
11001096
}
11011097

11021098
static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
11031099
{
1104-
ctxt->ops->get_fpu(ctxt);
11051100
switch (reg) {
11061101
case 0: asm("movq %%mm0, %0" : "=m"(*data)); break;
11071102
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)
11131108
case 7: asm("movq %%mm7, %0" : "=m"(*data)); break;
11141109
default: BUG();
11151110
}
1116-
ctxt->ops->put_fpu(ctxt);
11171111
}
11181112

11191113
static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
11201114
{
1121-
ctxt->ops->get_fpu(ctxt);
11221115
switch (reg) {
11231116
case 0: asm("movq %0, %%mm0" : : "m"(*data)); break;
11241117
case 1: asm("movq %0, %%mm1" : : "m"(*data)); break;
@@ -1130,17 +1123,14 @@ static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg)
11301123
case 7: asm("movq %0, %%mm7" : : "m"(*data)); break;
11311124
default: BUG();
11321125
}
1133-
ctxt->ops->put_fpu(ctxt);
11341126
}
11351127

11361128
static int em_fninit(struct x86_emulate_ctxt *ctxt)
11371129
{
11381130
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
11391131
return emulate_nm(ctxt);
11401132

1141-
ctxt->ops->get_fpu(ctxt);
11421133
asm volatile("fninit");
1143-
ctxt->ops->put_fpu(ctxt);
11441134
return X86EMUL_CONTINUE;
11451135
}
11461136

@@ -1151,9 +1141,7 @@ static int em_fnstcw(struct x86_emulate_ctxt *ctxt)
11511141
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
11521142
return emulate_nm(ctxt);
11531143

1154-
ctxt->ops->get_fpu(ctxt);
11551144
asm volatile("fnstcw %0": "+m"(fcw));
1156-
ctxt->ops->put_fpu(ctxt);
11571145

11581146
ctxt->dst.val = fcw;
11591147

@@ -1167,9 +1155,7 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
11671155
if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM))
11681156
return emulate_nm(ctxt);
11691157

1170-
ctxt->ops->get_fpu(ctxt);
11711158
asm volatile("fnstsw %0": "+m"(fsw));
1172-
ctxt->ops->put_fpu(ctxt);
11731159

11741160
ctxt->dst.val = fsw;
11751161

@@ -4001,12 +3987,8 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt)
40013987
if (rc != X86EMUL_CONTINUE)
40023988
return rc;
40033989

4004-
ctxt->ops->get_fpu(ctxt);
4005-
40063990
rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state));
40073991

4008-
ctxt->ops->put_fpu(ctxt);
4009-
40103992
if (rc != X86EMUL_CONTINUE)
40113993
return rc;
40123994

@@ -4049,8 +4031,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
40494031
if (rc != X86EMUL_CONTINUE)
40504032
return rc;
40514033

4052-
ctxt->ops->get_fpu(ctxt);
4053-
40544034
if (size < __fxstate_size(16)) {
40554035
rc = fxregs_fixup(&fx_state, size);
40564036
if (rc != X86EMUL_CONTINUE)
@@ -4066,8 +4046,6 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt)
40664046
rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state));
40674047

40684048
out:
4069-
ctxt->ops->put_fpu(ctxt);
4070-
40714049
return rc;
40724050
}
40734051

@@ -5317,9 +5295,7 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt)
53175295
{
53185296
int rc;
53195297

5320-
ctxt->ops->get_fpu(ctxt);
53215298
rc = asm_safe("fwait");
5322-
ctxt->ops->put_fpu(ctxt);
53235299

53245300
if (unlikely(rc != X86EMUL_CONTINUE))
53255301
return emulate_exception(ctxt, MF_VECTOR, 0, false);

arch/x86/kvm/x86.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5251,14 +5251,6 @@ static void emulator_halt(struct x86_emulate_ctxt *ctxt)
52515251
emul_to_vcpu(ctxt)->arch.halt_request = 1;
52525252
}
52535253

5254-
static void emulator_get_fpu(struct x86_emulate_ctxt *ctxt)
5255-
{
5256-
}
5257-
5258-
static void emulator_put_fpu(struct x86_emulate_ctxt *ctxt)
5259-
{
5260-
}
5261-
52625254
static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
52635255
struct x86_instruction_info *info,
52645256
enum x86_intercept_stage stage)
@@ -5336,8 +5328,6 @@ static const struct x86_emulate_ops emulate_ops = {
53365328
.halt = emulator_halt,
53375329
.wbinvd = emulator_wbinvd,
53385330
.fix_hypercall = emulator_fix_hypercall,
5339-
.get_fpu = emulator_get_fpu,
5340-
.put_fpu = emulator_put_fpu,
53415331
.intercept = emulator_intercept,
53425332
.get_cpuid = emulator_get_cpuid,
53435333
.set_nmi_mask = emulator_set_nmi_mask,

0 commit comments

Comments
 (0)