Fan Yang | 23 Jul 2012 06:00
Picon

How can I change cr0 register in redhat system

hi all:

       when I change the cr0 register I get a "Segmentation fault (core dumped)".
       my code is :
       

.data
.text
.global _start
_start:
        movl %eax, %cr0

      this code can work well in ubuntu system when I use root to run it. So what can I do to work it in redhat system?

     thanks

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies <at> kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Ram Tummala | 23 Jul 2012 06:19
Picon

Re: How can I change cr0 register in redhat system

On Jul 23, 2012, at 9:32 AM, Fan Yang <lljyangfan <at> gmail.com> wrote:

> hi all:
>        when I change the cr0 register I get a "Segmentation fault (core dumped)".
>        my code is :
>
>
> .data
> .text
> .global _start
> _start:
>         movl %eax, %cr0
>
>       this code can work well in ubuntu system when I use root to run it. So what can I do to work it in redhat system?
Changing a control register is a privileged operation. You can't do it
from the user space. You can only do it from ring 0.

Venkatram Tummala
>
>      thanks
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies <at> kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
siddharth saxena | 23 Jul 2012 10:37
Picon

Re: How can I change cr0 register in redhat system

Hi all


I have a certain configuration file which includes other files.
Lets say
#include<asm/arch/fileabc.h>

Now under directory
include/asm/

I'm not having any directory as arch, instead it is arch-omap4 and so I also have a link arch - > arch-omap4

but when I'm building the code, there is error :
fatal error: asm/arch/fileabc.h : No such file or directory

Any problem with the link ?


Regards
Siddharth
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies <at> kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Jonathan Neuschäfer | 23 Jul 2012 13:40
Picon

Re: How can I change cr0 register in redhat system

On Mon, Jul 23, 2012 at 02:07:41PM +0530, siddharth saxena wrote:
> Hi all
> 
> I have a certain configuration file which includes other files.
> Lets say
> *#include<asm/arch/fileabc.h>*

Where is your "configuration file" located?
Is it fileabc.h, or does it include fileabc.h?

> Now under directory
> *include/asm/*

I don't have include/asm/ in my copy of the linux source code (v3.5-rc4),
did you add it yourself?

> I'm not having any directory as *arch*, instead it is *arch-omap4* and so I
> also have a link *arch - > arch-omap4*

The thing that looks the most like what you seem to be trying to do is
arch/arm/mach-*

> but when I'm building the code, there is error :
> *fatal error: asm/arch/fileabc.h : No such file or directory*
> *
> *
> *Any problem with the link ?*

Which link?
If you mean the linker or the linking proccess, then no: It doesn't get
that far.

HTH,
	Jonathan Neuschäfer

PS: Please don't reply to emails on the mailing list if you're starting
    a new discussion.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies <at> kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Peter Teoh | 24 Jul 2012 04:05
Picon
Gravatar

Re: How can I change cr0 register in redhat system

u have to put the asm code in kernel module, and load it via "insmod" and when it execute, it will affect all the processes .....and btw, your version is dangerous....normally people will always query the latest value of Cr0, and then OR with the value they want to modify.   below is one that worked:


http://stackoverflow.com/questions/3962950/how-to-set-control-register-0-cr0-bits-in-x86-64-using-gcc-assembly-on-linux


On Mon, Jul 23, 2012 at 12:00 PM, Fan Yang <lljyangfan <at> gmail.com> wrote:
hi all:
       when I change the cr0 register I get a "Segmentation fault (core dumped)".
       my code is :
       

.data
.text
.global _start
_start:
        movl %eax, %cr0

      this code can work well in ubuntu system when I use root to run it. So what can I do to work it in redhat system?

     thanks


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies <at> kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




--
Regards,
Peter Teoh
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies <at> kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Gmane