]> xenbits.xensource.com Git - xen.git/commit
x86emul: limit-check branch targets
authorJan Beulich <jbeulich@suse.com>
Fri, 26 Feb 2016 11:14:39 +0000 (12:14 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 26 Feb 2016 11:14:39 +0000 (12:14 +0100)
commit81d3a0b26c1672c60b2a54dd8780e6f6472d2328
treeff9c18b7fbb0bf59966d4c677bdd6bf798052386
parentabf8824fe530bcf060c757596f68663c87546a6a
x86emul: limit-check branch targets

All branches need to #GP when their target violates the segment limit
(in 16- and 32-bit modes) or is non-canonical (in 64-bit mode). For
near branches facilitate this via a zero-byte instruction fetch from
the target address (resulting in address translation and validation
without an actual read from memory), while far branches get dealt with
by breaking up the segment register loading into a read-and-validate
part and a write one. The latter at once allows correcting some
ordering issues in how the individual emulation steps get carried out:
Before updating machine state, all exceptions unrelated to that state
updating should have got raised (i.e. the only ones possibly resulting
in partly updated state are faulting memory writes [pushes]).

Note that while not immediately needed here, write and distinct read
emulation routines get updated to deal with zero byte accesses too, for
overall consistency.

Reported-by: 刘令 <liuling-it@360.cn>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
tools/tests/x86_emulator/x86_emulate.c
xen/arch/x86/hvm/emulate.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/mm.c
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/x86_emulate/x86_emulate.c