diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-04-10 11:41:40 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-04-16 15:39:02 +0200 |
commit | 674ea351cdeb01d2740edce31db7f2d79ce6095d (patch) | |
tree | aaabcbffb1ebd5543da17d648b3818e5014b01f9 /arch/x86/kvm/mtrr.c | |
parent | f16cb57be82b20c6a00a6bb1750cb77c08e56c1a (diff) | |
download | linux-stable-674ea351cdeb01d2740edce31db7f2d79ce6095d.tar.gz linux-stable-674ea351cdeb01d2740edce31db7f2d79ce6095d.tar.bz2 linux-stable-674ea351cdeb01d2740edce31db7f2d79ce6095d.zip |
KVM: x86: optimize check for valid PAT value
This check will soon be done on every nested vmentry and vmexit,
"parallelize" it using bitwise operations.
Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mtrr.c')
-rw-r--r-- | arch/x86/kvm/mtrr.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index e9ea2d45ae66..9f72cc427158 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -48,11 +48,6 @@ static bool msr_mtrr_valid(unsigned msr) return false; } -static bool valid_pat_type(unsigned t) -{ - return t < 8 && (1 << t) & 0xf3; /* 0, 1, 4, 5, 6, 7 */ -} - static bool valid_mtrr_type(unsigned t) { return t < 8 && (1 << t) & 0x73; /* 0, 1, 4, 5, 6 */ @@ -67,10 +62,7 @@ bool kvm_mtrr_valid(struct kvm_vcpu *vcpu, u32 msr, u64 data) return false; if (msr == MSR_IA32_CR_PAT) { - for (i = 0; i < 8; i++) - if (!valid_pat_type((data >> (i * 8)) & 0xff)) - return false; - return true; + return kvm_pat_valid(data); } else if (msr == MSR_MTRRdefType) { if (data & ~0xcff) return false; |