From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: question about "struct kvm_segment" Date: Fri, 30 May 2014 22:49:51 +0200 Message-ID: <5388EEEF.8080108@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Jidong Xiao , virtualization@lists.linux-foundation.org List-Id: virtualization@lists.linuxfoundation.org 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