From: "Jan Beulich" Subject: Re: Problem with modify CR0 of xen kernel Date: Mon, 14 Dec 2009 08:53:58 +0000 Message-ID: <4B260B360200007800025A07@vpn.id2.novell.com> References: <505b4f530912130044w7564c612jc16be5964debb0ac@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <505b4f530912130044w7564c612jc16be5964debb0ac@mail.gmail.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: errik Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org The only bit a pv kernel may modify in CR0 is CR0.TS. If you looked at the Xen output, you also would have seen a corresponding warning. Jan >>> errik 13.12.09 09:44 >>> Hi All, This is a function of a kernel module, but when I calls this function, = a segment fault error happens, I don't know why because the code works well = on other types of kernel such as PAE and default. unsigned long clear_and_return_cr0(void) { unsigned long cr0 =3D 0; unsigned long ret; #ifdef X86_64 __asm__ __volatile("movq %%cr0, %%rax" : "=3Da"(cr0)); ret =3D cr0; cr0 &=3D 0xfffffffffffeffff; __asm__ __volatile__("movq %%rax, %%cr0" : : "a"(cr0)); #else __asm__ __volatile("mov %%cr0, %%eax" : "=3Da"(cr0)); ret =3D cr0; cr0 &=3D 0xfffeffff; __asm__ __volatile__("mov %%eax, %%cr0" : : "a"(cr0)); #endif return ret; } May anyone give me some suggestions? Thanks a lot! Eric