Skip to content

Commit 3e5d2fd

Browse files
Xiao Guangrongbonzini
Xiao Guangrong
authored andcommitted
KVM: MTRR: simplify kvm_mtrr_get_guest_memory_type
kvm_mtrr_get_guest_memory_type never returns -1 which is implied in the current code since if @type = -1 (means no MTRR contains the range), iter.partial_map must be true Simplify the code to indicate this fact Signed-off-by: Xiao Guangrong <[email protected]> Tested-by: Alex Williamson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 10dc331 commit 3e5d2fd

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

arch/x86/kvm/mtrr.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,16 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn)
672672
if (iter.mtrr_disabled)
673673
return mtrr_disabled_type();
674674

675-
/* It is not covered by MTRRs. */
676-
if (iter.partial_map) {
677-
/*
678-
* We just check one page, partially covered by MTRRs is
679-
* impossible.
680-
*/
681-
WARN_ON(type != -1);
682-
type = mtrr_default_type(mtrr_state);
683-
}
675+
/*
676+
* We just check one page, partially covered by MTRRs is
677+
* impossible.
678+
*/
679+
WARN_ON(iter.partial_map);
680+
681+
/* not contained in any MTRRs. */
682+
if (type == -1)
683+
return mtrr_default_type(mtrr_state);
684+
684685
return type;
685686
}
686687
EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);

0 commit comments

Comments
 (0)