From: "Jan Beulich" Subject: Re: [PATCH v3] docs: add PVH specification Date: Mon, 22 Sep 2014 15:08:26 +0100 Message-ID: <5420497A020000780003716C@mail.emea.novell.com> References: <1411060764-4016-1-git-send-email-roger.pau@citrix.com> <20140920191510.GA2882@laptop.dumpdata.com> <542009C9.7000503@citrix.com> <20140922140223.GA20515@konrad-lan.dumpdata.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XW4I5-0006Xy-Ff for xen-devel@lists.xenproject.org; Mon, 22 Sep 2014 14:08:33 +0000 In-Reply-To: <20140922140223.GA20515@konrad-lan.dumpdata.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: roger.pau@citrix.com, Konrad Rzeszutek Wilk Cc: xen-devel@lists.xenproject.org, David Vrabel List-Id: xen-devel@lists.xenproject.org >>> On 22.09.14 at 16:02, wrote: >> >> +`CR0` has the following bits set by Xen: >> >> + >> >> + * PE (bit 0): protected mode enable. >> >> + * ET (bit 4): 387 or newer processor. >> >> + * PG (bit 31): paging enabled. >> > >> > Also TS (at least that is what the Linux code says: >> > >> > /* Some of these are setup in 'secondary_startup_64'. The others: >> > * X86_CR0_TS, X86_CR0_PE, X86_CR0_ET are set by Xen for HVM guests >> > * (which PVH shared codepaths), while X86_CR0_PG is for PVH. */ >> > >> > Perhaps it is incorrect? >> >> I think this comment is outdated/incorrect. This is the CR0 value I see >> on a FreeBSD PVH start-of-day: >> >> 0x80000011 (PE, ET and PG bits set) >> > > Reading the code I see > > construct_vmcs > hvm_update_guest_cr(v, 0); > vmx_update_guest_cr > > Then this code: > 1234 if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) ) > > 1235 { > > 1236 if ( v != current ) > > 1237 hw_cr0_mask |= X86_CR0_TS; > > > ... > 1279 v->arch.hvm_vcpu.hw_cr[0] = > > 1280 v->arch.hvm_vcpu.guest_cr[0] | hw_cr0_mask; > > 1281 __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]); > > > Same logic on the AMD side, albeit less complicated. > > But this is Monday morning so I must be missing something > as your values don't match with this. You're mixing up the hardware CR0 value (hw_cr[0]) and the guest visible one (guest_cr[0]). Jan