diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-11-19 20:33:38 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-11-19 20:40:24 +0300 |
commit | 997b04128d4e07fd59d00fc18e21fd591138627f (patch) | |
tree | a9000b90e25fb5695a13f0db19193bdc4f4407d3 /arch/x86/kvm | |
parent | 01485a2230540c0dacd146e9927ea3d87dcb0fd8 (diff) | |
download | linux-997b04128d4e07fd59d00fc18e21fd591138627f.tar.xz |
KVM: emulator: remove duplicated limit check
The check on the higher limit of the segment, and the check on the
maximum accessible size, is the same for both expand-up and
expand-down segments. Only the computation of "lim" varies.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 43a5b432d06f..f62209e7ad84 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -654,20 +654,15 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, if (!fetch && (desc.type & 8) && !(desc.type & 2)) goto bad; lim = desc_limit_scaled(&desc); - if ((desc.type & 8) || !(desc.type & 4)) { - /* expand-up segment */ - if (addr.ea > lim) - goto bad; - *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea); - } else { + if (!(desc.type & 8) && (desc.type & 4)) { /* expand-down segment */ if (addr.ea <= lim) goto bad; lim = desc.d ? 0xffffffff : 0xffff; - if (addr.ea > lim) - goto bad; - *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea); } + if (addr.ea > lim) + goto bad; + *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea); if (size > *max_size) goto bad; la &= (u32)-1; |