Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Avi Kivity
On 08/11/2009 11:57 PM, Anthony Liguori wrote: According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR are not normally available in vm86 mode so if they happen to

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Avi Kivity
On 08/11/2009 11:57 PM, Anthony Liguori wrote: According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR are not normally available in vm86 mode so if they happen to

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Avi Kivity
On 08/12/2009 03:11 PM, Avi Kivity wrote: On 08/11/2009 11:57 PM, Anthony Liguori wrote: According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR are not normally

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Anthony Liguori
Avi Kivity wrote: On 08/12/2009 03:11 PM, Avi Kivity wrote: On 08/11/2009 11:57 PM, Anthony Liguori wrote: According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Avi Kivity
On 08/12/2009 04:15 PM, Anthony Liguori wrote: While the code looks nicer with the second patch, the fact that get_rflags() does a vmcs_read() seems 7 times more than before seems unfortunate. We can add kvm_rflags_read(), see kvm_cache_regs.h. In any case, it's purely academic since task

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-12 Thread Anthony Liguori
Avi Kivity wrote: On 08/12/2009 04:15 PM, Anthony Liguori wrote: While the code looks nicer with the second patch, the fact that get_rflags() does a vmcs_read() seems 7 times more than before seems unfortunate. We can add kvm_rflags_read(), see kvm_cache_regs.h. In any case, it's purely

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit

2009-08-11 Thread Avi Kivity
On 08/11/2009 04:00 AM, Anthony Liguori wrote: According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. This fixes an invalid vmentry failure in a custom OS that was happening after a

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit

2009-08-11 Thread Anthony Liguori
Avi Kivity wrote: On 08/11/2009 04:00 AM, Anthony Liguori wrote: kvm_load_segment_descriptor() can already load plain segments: if (!(vcpu-arch.cr0 X86_CR0_PE)) return kvm_load_realmode_segment(vcpu, selector, seg); so we can simplify the patch a bit by extending the check. I

Re: [PATCH] When switching to a vm8086 task, load segments as 16-bit

2009-08-11 Thread Avi Kivity
On 08/11/2009 07:45 PM, Anthony Liguori wrote: Avi Kivity wrote: On 08/11/2009 04:00 AM, Anthony Liguori wrote: kvm_load_segment_descriptor() can already load plain segments: if (!(vcpu-arch.cr0 X86_CR0_PE)) return kvm_load_realmode_segment(vcpu, selector, seg); so we can

[PATCH] When switching to a vm8086 task, load segments as 16-bit (v2)

2009-08-11 Thread Anthony Liguori
According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. The LDTR and TR are not normally available in vm86 mode so if they happen to somehow get loaded, they need to be treated as

[PATCH] When switching to a vm8086 task, load segments as 16-bit

2009-08-10 Thread Anthony Liguori
According to 16.2.5 in the SDM, eflags.vm in the tss is consulted before loading and new segments. If eflags.vm == 1, then the segments are treated as 16-bit segments. This fixes an invalid vmentry failure in a custom OS that was happening after a task switch into vm8086 mode. Since the