]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Stack size is overridden by __linearize
authorNadav Amit <namit@cs.technion.ac.il>
Wed, 19 Nov 2014 15:43:09 +0000 (17:43 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 19 Nov 2014 17:17:10 +0000 (18:17 +0100)
commit569cbb21d97713cf43be7df86141d2c73b883e46
treef8a03ce263b63e50c06266415b193785f5a1ce1a
parent4bbbdd774a70949be391a89e0cf98e215ec37db7
KVM: x86: Stack size is overridden by __linearize

When performing segmented-read/write in the emulator for stack operations, it
ignores the stack size, and uses the ad_bytes as indication for the pointer
size. As a result, a wrong address may be accessed.

To fix this behavior, we can remove the masking of address in __linearize and
perform it beforehand.  It is already done for the operands (so currently it is
inefficiently done twice). It is missing in two cases:
1. When using rip_relative
2. On fetch_bit_operand that changes the address.

This patch masks the address on these two occassions, and removes the masking
from __linearize.

Note that it does not mask EIP during fetch. In protected/legacy mode code
fetch when RIP >= 2^32 should result in #GP and not wrap-around. Since we make
limit checks within __linearize, this is the expected behavior.

Partial revert of commit bdc6fd15dda3 (KVM: x86: Emulator does not
calculate address correctly, 2014-09-30).

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/emulate.c