qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/3] target-i386: fix CPL computation
@ 2014-05-16 19:59 Paolo Bonzini
  2014-05-16 19:59 ` [Qemu-devel] [PATCH 1/3] target-i386: fix segment flags for SMM, user-mode emulation and VM86 mode Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Paolo Bonzini @ 2014-05-16 19:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevin

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.

So this patch fixes the CPL to come from SS.DPL instead, which
requires a couple changes to make access rights correct for VM86
mode, and to override the CPL to CS.RPL during task switches (more
details in patch 2).  The Intel documentation mentions in a couple
places that SS.DPL is indeed the current privilege level.

Tested with FreeDOS (checking with info registers that it runs
in real vs. VM86 mode depending on the chosen boot option),
kvm-unit-tests and runcom.c.

v1->v2: fix user-mode emulation

Paolo Bonzini (3):
  target-i386: fix segment flags for SMM, user-mode emulation and VM86 mode
  target-i386: rework CPL checks during task switch, preparing for next patch
  target-i386: get CPL from SS.DPL

 bsd-user/main.c          |  2 +-
 linux-user/main.c        |  2 +-
 target-i386/cpu.h        |  8 +++-----
 target-i386/gdbstub.c    |  4 +++-
 target-i386/kvm.c        |  2 +-
 target-i386/machine.c    |  8 ++++++++
 target-i386/seg_helper.c | 34 +++++++++++++++++-----------------
 target-i386/smm_helper.c | 24 ++++++++++++++++++------
 8 files changed, 52 insertions(+), 32 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-05-21 14:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-16 19:59 [Qemu-devel] [PATCH v2 0/3] target-i386: fix CPL computation Paolo Bonzini
2014-05-16 19:59 ` [Qemu-devel] [PATCH 1/3] target-i386: fix segment flags for SMM, user-mode emulation and VM86 mode Paolo Bonzini
2014-05-16 19:59 ` [Qemu-devel] [PATCH 2/3] target-i386: rework CPL checks during task switch, preparing for next patch Paolo Bonzini
2014-05-16 19:59 ` [Qemu-devel] [PATCH 3/3] target-i386: get CPL from SS.DPL Paolo Bonzini
2014-05-20 21:54   ` Kevin O'Connor
2014-05-21 11:13     ` Paolo Bonzini
2014-05-21 14:05       ` Kevin O'Connor
2014-05-21 14:18         ` Paolo Bonzini
2014-05-21 14:31           ` Kevin O'Connor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).