Skip to content

Commit

Permalink
KVM: MTRR: simplify kvm_mtrr_get_guest_memory_type
Browse files Browse the repository at this point in the history
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 <guangrong.xiao@intel.com>
Tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Xiao Guangrong authored and bonzini committed Jul 23, 2015
1 parent 10dc331 commit 3e5d2fd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions arch/x86/kvm/mtrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,16 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn)
if (iter.mtrr_disabled)
return mtrr_disabled_type();

/* It is not covered by MTRRs. */
if (iter.partial_map) {
/*
* We just check one page, partially covered by MTRRs is
* impossible.
*/
WARN_ON(type != -1);
type = mtrr_default_type(mtrr_state);
}
/*
* We just check one page, partially covered by MTRRs is
* impossible.
*/
WARN_ON(iter.partial_map);

/* not contained in any MTRRs. */
if (type == -1)
return mtrr_default_type(mtrr_state);

return type;
}
EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);
Expand Down

0 comments on commit 3e5d2fd

Please sign in to comment.