lkml.org 
[lkml]   [2013]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH, RFC] x86-64: properly handle FPU code/data selectors
On Thu, Oct 17, 2013 at 10:33:33AM +0100, Jan Beulich wrote:
> >>> On 17.10.13 at 11:27, Gleb Natapov <gleb@redhat.com> wrote:
> > On Wed, Oct 16, 2013 at 05:13:40PM +0100, Jan Beulich wrote:
> >> > It preserves *less* state, because the upper 32 bits of rip are now
> >> > corrupted. Any 64-bit application that actually looks at the FP
> >> > rip/rdp fields now get the WRONG VALUES.
> >>
> >> But again - this isn't being done for ordinary 64-bit applications,
> >> this is only happening for KVM guests. And there not being a
> >> protocol for telling the caller whether a certain context hold
> >> 64-bit offsets or selector/offset pairs shouldn't be a reason to
> >> think of a solution to the problem.
> >>
> > KVM knows what mode guest vcpu is in. is_long_mode(vcpu) will tell you
> > if it is in long mode or not. No need to guess it.
>
> So what if that 64-bit guest OS is running a 32-bit app? You can
> only positively know the _current_ guest word size when the
> guest is not in long mode.
>
KVM obviously knows the complete state of virtual CPU. It can figure the
situation above by looking at CS descriptor, not need to check
is_long_mode() at all. Here is how emulator does it:

kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);

ctxt->eflags = kvm_get_rflags(vcpu);
ctxt->mode = (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
(ctxt->eflags & X86_EFLAGS_VM) ? X86EMUL_MODE_VM86 :
cs_l ? X86EMUL_MODE_PROT64 :
cs_db ? X86EMUL_MODE_PROT32 :
X86EMUL_MODE_PROT16;

--
Gleb.


\
 
 \ /
  Last update: 2013-10-17 12:01    [W:0.043 / U:9.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site