Received: from eggs.gnu.org ([2001:4830:134:3::10]:51995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkKr0-0003IJ-8J for qemu-devel@nongnu.org; Tue, 13 May 2014 18:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkKqs-0005dG-Pt for qemu-devel@nongnu.org; Tue, 13 May 2014 18:07:18 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:51041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkKqs-0005d4-Ke for qemu-devel@nongnu.org; Tue, 13 May 2014 18:07:10 -0400 Received: by mail-pb0-f48.google.com with SMTP id rr13so791328pbb.21 for ; Tue, 13 May 2014 15:07:09 -0700 (PDT) Date: Tue, 13 May 2014 18:07:06 -0400 From: Kevin O'Connor Message-ID: <20140513220705.GA7084@morn.localdomain> References: <20140425171718.GA1591@morn.localdomain> <535B772D.1020602@redhat.com> <1398601366.21309.33.camel@localhost.localdomain> <535D1445.3040905@redhat.com> <20140427172524.GB28385@morn.localdomain> <5372636F.8080101@redhat.com> <20140513183920.GA23439@morn.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140513183920.GA23439@morn.localdomain> Subject: Re: [Qemu-devel] [PATCH] SMI handler should set the CPL to zero and save and restore it on rsm. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, marcel.a@redhat.com, Gerd Hoffmann , Richard Henderson On Tue, May 13, 2014 at 02:39:20PM -0400, Kevin O'Connor wrote: > On Tue, May 13, 2014 at 08:24:47PM +0200, Paolo Bonzini wrote: > > Il 27/04/2014 19:25, Kevin O'Connor ha scritto: > > > I was wondering about that as well. The Intel docs state that the CPL > > > is bits 0-1 of the CS.selector register, and that protected mode > > > starts immediately after setting the PE bit. The CS.selector field > > > should be the value of %cs in real mode, which is the value added to > > > eip (after shifting right by 4). > > > > > > I guess that means that the real mode code that enables the PE bit > > > must run with a code segment aligned to a value of 4. (Which > > > effectively means code alignment of 64 bytes because of the segment > > > shift.) > > > > It turns out that this is not a requirement; which means that the > > protected mode transition is exactly the only place where CPL is not > > redundant. The CPL remains zero until you reload CS with a long jump. > > That doesn't sound right. FYI, I ran a couple of tests on a real machine where I set protected mode while %cs=0xf003 and I can confirm that it doesn't cause faults. So, you are correct - the CPL appears to be stored separately from %cs[1:0] and it appears CPL isn't altered until CS is reloaded. -Kevin