Skip to content

Commit 70109e7

Browse files
Xiao Guangrongbonzini
authored andcommitted
KVM: MTRR: remove mtrr_state.have_fixed
vMTRR does not depend on any host MTRR feature and fixed MTRRs have always been implemented, so drop this field Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent eb83991 commit 70109e7

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ enum {
342342
KVM_DEBUGREG_RELOAD = 4,
343343
};
344344

345+
struct kvm_mtrr {
346+
struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES];
347+
mtrr_type fixed_ranges[KVM_NR_FIXED_MTRR_REGION];
348+
unsigned char enabled;
349+
mtrr_type def_type;
350+
};
351+
345352
struct kvm_vcpu_arch {
346353
/*
347354
* rip and regs accesses must go through
@@ -472,7 +479,7 @@ struct kvm_vcpu_arch {
472479
bool nmi_injected; /* Trying to inject an NMI this entry */
473480
bool smi_pending; /* SMI queued after currently running handler */
474481

475-
struct mtrr_state_type mtrr_state;
482+
struct kvm_mtrr mtrr_state;
476483
u64 pat;
477484

478485
unsigned switch_db_regs;

arch/x86/kvm/mtrr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ EXPORT_SYMBOL_GPL(kvm_mtrr_valid);
103103

104104
static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr)
105105
{
106-
struct mtrr_state_type *mtrr_state = &vcpu->arch.mtrr_state;
106+
struct kvm_mtrr *mtrr_state = &vcpu->arch.mtrr_state;
107107
unsigned char mtrr_enabled = mtrr_state->enabled;
108108
gfn_t start, end, mask;
109109
int index;
@@ -247,7 +247,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
247247
* The function is based on mtrr_type_lookup() in
248248
* arch/x86/kernel/cpu/mtrr/generic.c
249249
*/
250-
static int get_mtrr_type(struct mtrr_state_type *mtrr_state,
250+
static int get_mtrr_type(struct kvm_mtrr *mtrr_state,
251251
u64 start, u64 end)
252252
{
253253
u64 base, mask;
@@ -262,8 +262,7 @@ static int get_mtrr_type(struct mtrr_state_type *mtrr_state,
262262
end--;
263263

264264
/* Look in fixed ranges. Just return the type as per start */
265-
if (mtrr_state->have_fixed && (mtrr_state->enabled & 0x1) &&
266-
(start < 0x100000)) {
265+
if ((mtrr_state->enabled & 0x1) && (start < 0x100000)) {
267266
int idx;
268267

269268
if (start < 0x80000) {

arch/x86/kvm/x86.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7379,7 +7379,6 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
73797379
{
73807380
int r;
73817381

7382-
vcpu->arch.mtrr_state.have_fixed = 1;
73837382
r = vcpu_load(vcpu);
73847383
if (r)
73857384
return r;

0 commit comments

Comments
 (0)