* question about "struct kvm_segment"
@ 2014-05-20 2:25 Jidong Xiao
2014-05-30 20:49 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Jidong Xiao @ 2014-05-20 2:25 UTC (permalink / raw)
To: virtualization
Hi,
The structure kvm_segment is defined as follows:
struct kvm_segment {
__u64 base;
__u32 limit;
__u16 selector;
__u8 type;
__u8 present, dpl, db, s, l, g, avl;
__u8 unusable;
__u8 padding;
};
Since the VMX spec defines base is 64 bits, limit is 32bits, selector
is 16bits, understandably, __u64, __u32, __u16 is used for them
respectively.
However, the VMX spec defines that the access rights is 32bits, which
includes a 4 bits type, 2 bits dpl, and 1 bit for the
present,dpl,db,s,l,g,avl. So why here they are all defined as __u8? It
means that, each of them is represented by 8bits? This looks
inconsistent with the VMX spec.
Hope someone can explain this, thanks!
-Jidong
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about "struct kvm_segment"
2014-05-20 2:25 question about "struct kvm_segment" Jidong Xiao
@ 2014-05-30 20:49 ` Paolo Bonzini
2014-06-01 1:41 ` Jidong Xiao
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-05-30 20:49 UTC (permalink / raw)
To: Jidong Xiao, virtualization
Il 20/05/2014 04:25, Jidong Xiao ha scritto:
> Hi,
>
> The structure kvm_segment is defined as follows:
>
> struct kvm_segment {
> __u64 base;
> __u32 limit;
> __u16 selector;
> __u8 type;
> __u8 present, dpl, db, s, l, g, avl;
> __u8 unusable;
> __u8 padding;
> };
>
> Since the VMX spec defines base is 64 bits, limit is 32bits, selector
> is 16bits, understandably, __u64, __u32, __u16 is used for them
> respectively.
>
> However, the VMX spec defines that the access rights is 32bits, which
> includes a 4 bits type, 2 bits dpl, and 1 bit for the
> present,dpl,db,s,l,g,avl. So why here they are all defined as __u8? It
> means that, each of them is represented by 8bits? This looks
> inconsistent with the VMX spec.
This is not a VMX definition, it's part of the ioctl interface between
KVM and user-mode programs.
For the conversion code see vmx_get_segment and vmx_set_segment. These
should be never called in hot paths, except unfortunately when doing
nested virtualization.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about "struct kvm_segment"
2014-05-30 20:49 ` Paolo Bonzini
@ 2014-06-01 1:41 ` Jidong Xiao
0 siblings, 0 replies; 3+ messages in thread
From: Jidong Xiao @ 2014-06-01 1:41 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: virtualization
On Fri, May 30, 2014 at 4:49 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 20/05/2014 04:25, Jidong Xiao ha scritto:
>
>> Hi,
>>
>> The structure kvm_segment is defined as follows:
>>
>> struct kvm_segment {
>> __u64 base;
>> __u32 limit;
>> __u16 selector;
>> __u8 type;
>> __u8 present, dpl, db, s, l, g, avl;
>> __u8 unusable;
>> __u8 padding;
>> };
>>
>> Since the VMX spec defines base is 64 bits, limit is 32bits, selector
>> is 16bits, understandably, __u64, __u32, __u16 is used for them
>> respectively.
>>
>> However, the VMX spec defines that the access rights is 32bits, which
>> includes a 4 bits type, 2 bits dpl, and 1 bit for the
>> present,dpl,db,s,l,g,avl. So why here they are all defined as __u8? It
>> means that, each of them is represented by 8bits? This looks
>> inconsistent with the VMX spec.
>
>
> This is not a VMX definition, it's part of the ioctl interface between KVM
> and user-mode programs.
>
> For the conversion code see vmx_get_segment and vmx_set_segment. These
> should be never called in hot paths, except unfortunately when doing nested
> virtualization.
>
> Paolo
Thanks Paolo. I will try to read the source code and intel manual and
try to understand what you explained.
-Jidong
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-01 1:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 2:25 question about "struct kvm_segment" Jidong Xiao
2014-05-30 20:49 ` Paolo Bonzini
2014-06-01 1:41 ` Jidong Xiao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.