]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commit
target-i386: get CPL from SS.DPL
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 14 May 2014 08:38:18 +0000 (10:38 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 21 May 2014 16:02:08 +0000 (18:02 +0200)
commit7125c937c97d9ec4a41b3cb6d1b3e805ec53e255
tree9708833c2a12eecd0a52c9c85a0853d0a54784a5
parentd3b5491897456739c6dc21c604ef8bc28e294bfc
target-i386: get CPL from SS.DPL

CS.RPL is not equal to the CPL in the few instructions between
setting CR0.PE and reloading CS.  We get this right in the common
case, because writes to CR0 do not modify the CPL, but it would
not be enough if an SMI comes exactly during that brief period.
Were this to happen, the RSM instruction would erroneously set
CPL to the low two bits of the real-mode selector; and if they are
not 00, the next instruction fetch cannot access the code segment
and causes a triple fault.

However, SS.DPL *is* always equal to the CPL.  In real processors
(AMD only) there is a weird case of SYSRET setting SS.DPL=SS.RPL
from the STAR register while forcing CPL=3, but we do not emulate
that.

Tested-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386/cpu.h
target-i386/kvm.c
target-i386/machine.c