From: Keir Fraser Subject: Re: xenoprof passive profiling and "mode" setting Date: Wed, 5 Jul 2006 22:56:18 +0100 Message-ID: <56a6b3c43ada77c4c324139d0bc9a4ab@cl.cam.ac.uk> References: <200607051327.58586.raybry@mpdtxmail.amd.com> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <200607051327.58586.raybry@mpdtxmail.amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ray Bryant Cc: Xiaowei , xen-devel@lists.xensource.com, Yang@mpdtxmail.amd.com List-Id: xen-devel@lists.xenproject.org On 5 Jul 2006, at 19:27, Ray Bryant wrote: > So, how is that possibly true for the kernel in an HVM guest? > (Wouldn't guest_kernel_mode(regs) be false in that case since it is = not > running ring_3()?) guest_kernel_mode() does not work for HVM guests. It may need to be=20 fixed -- it had previously only been used in paravirtual-only contexts. It might make sense to invert[*] the predicate and rename to=20 user_mode(). Then definition is simply ring_3(regs) for x86/32 and=20 (ring_3(regs) && !((v)->arch.flags & TF_kernel_mode)) for x86/64. > Also, wouldn't ring_0(regs) be true if we are running in kernel mode=20= > in an HVM > guest? =A0 =A0This code appears to assign such a sample to being part = of=20 > xen, > right? ring_0(regs) should be replaced by !guest_mode(regs). So maybe: int mode =3D 2; if (guest_mode(regs)) mode =3D user_mode(current, regs) ? 0 : 1; -- Keir [*] Not really inversion, as neither guest_kernel_mode() nor=20 user_mode() are true for hypervisor mode.