Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <guangrong.xiao@intel.com>
Tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Xiao Guangrong and committed by
Paolo Bonzini
3e5d2fdc 10dc331f

+10 -9
+10 -9
arch/x86/kvm/mtrr.c
··· 672 672 if (iter.mtrr_disabled) 673 673 return mtrr_disabled_type(); 674 674 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 + 684 685 return type; 685 686 } 686 687 EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type);