From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758635AbbEEMsq (ORCPT ); Tue, 5 May 2015 08:48:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbbEEMsi (ORCPT ); Tue, 5 May 2015 08:48:38 -0400 Date: Tue, 5 May 2015 14:48:34 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bsd@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch Message-ID: <20150505124833.GA11121@potion.brq.redhat.com> References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> <1430393772-27208-10-git-send-email-pbonzini@redhat.com> <20150504195902.GA15848@potion.brq.redhat.com> <55488F47.8070904@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <55488F47.8070904@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2015-05-05 11:37+0200, Paolo Bonzini: > On 04/05/2015 21:59, Radim Krčmář wrote: > > > The big ugly one. This patch adds support for switching in and out of > > > system management mode, respectively upon receiving KVM_REQ_SMI and upon > > > executing a RSM instruction. Both 32- and 64-bit formats are supported > > > for the SMM state save area. > > > > > > Signed-off-by: Paolo Bonzini > > > --- > > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > > > +static void rsm_set_desc_flags(struct desc_struct *desc, u16 flags) > > > +{ > > > + desc->g = (flags >> 15) & 1; > > > + desc->d = (flags >> 14) & 1; > > > + desc->l = (flags >> 13) & 1; > > > + desc->avl = (flags >> 12) & 1; > > > + desc->p = (flags >> 7) & 1; > > > + desc->dpl = (flags >> 5) & 3; > > > + desc->s = (flags >> 4) & 1; > > > + desc->type = flags & 15; > > > > I can't find a description of this ... can you point me to a place where > > the gap between 'p' and 'avl' is documented? > > (Not that it matters unless the guest reads it, but it's a bit weird.) > > It turns out that access rights are stored in the same format as the VMX > access rights. Thanks, so it really has a "reserved" space in the middle, to save some processing because the format is horrible (backward compatible). > access rights. However, they are shifted by 8, which my code above > doesn't do (bug). I think you are shifting it right, though ... they wouldn't fit into a word if shifted left. (I'd just shorten it after finding the right name for mask u32 mask = 0x00f0ff00 desc->b = desc->b & ~mask | flags << 8 & mask and maybe define 'attributes' field in desc that is already shifted.) > The documentation is, of course, QEMU and Bochs :) but you can also find > it in http://www.rcollins.org/ftp/source/include/struc.inc. It is not > exactly for SMM, but it is more or less the same. (It's a register hidden from software, so I have some trust issues :])