Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e5d2fdc authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Paolo Bonzini
Browse files

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: default avatarXiao Guangrong <guangrong.xiao@intel.com>
Tested-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 10dc331f
Loading
Loading
Loading
Loading
+10 −9
Original line number Original line Diff line number Diff line
@@ -672,15 +672,16 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn)
	if (iter.mtrr_disabled)
	if (iter.mtrr_disabled)
		return mtrr_disabled_type();
		return mtrr_disabled_type();


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

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

	return type;
	return type;
}
}
EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);
EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);