All of lore.kernel.org
 help / color / mirror / Atom feed
* How can I change cr0 register in redhat system
@ 2012-07-23  4:00 Fan Yang
  2012-07-23  4:19 ` Ram Tummala
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Fan Yang @ 2012-07-23  4:00 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120723/95e85dc2/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23  4:00 How can I change cr0 register in redhat system Fan Yang
@ 2012-07-23  4:19 ` Ram Tummala
  2012-07-23  8:37   ` siddharth saxena
       [not found] ` <219833562776487968@unknownmsgid>
  2012-07-24  2:05 ` Peter Teoh
  2 siblings, 1 reply; 8+ messages in thread
From: Ram Tummala @ 2012-07-23  4:19 UTC (permalink / raw)
  To: kernelnewbies

On Jul 23, 2012, at 9:32 AM, Fan Yang <lljyangfan@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23  4:19 ` Ram Tummala
@ 2012-07-23  8:37   ` siddharth saxena
  2012-07-23 11:40     ` Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: siddharth saxena @ 2012-07-23  8:37 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120723/1144a1ff/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23  8:37   ` siddharth saxena
@ 2012-07-23 11:40     ` Jonathan Neuschäfer
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Neuschäfer @ 2012-07-23 11:40 UTC (permalink / raw)
  To: kernelnewbies

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
       [not found] ` <219833562776487968@unknownmsgid>
@ 2012-07-23 13:38   ` Fan Yang
  2012-07-23 14:01     ` Jonathan Neuschäfer
  2012-07-23 17:38     ` Ram Tummala
  0 siblings, 2 replies; 8+ messages in thread
From: Fan Yang @ 2012-07-23 13:38 UTC (permalink / raw)
  To: kernelnewbies

2012/7/23 Ram Tummala <venkatram867@gmail.com>

> On Jul 23, 2012, at 9:32 AM, Fan Yang <lljyangfan@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
>
>
>
May be I can work it by adding a new syscall in the kernel, right?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120723/7c1ff1d8/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23 13:38   ` Fan Yang
@ 2012-07-23 14:01     ` Jonathan Neuschäfer
  2012-07-23 17:38     ` Ram Tummala
  1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Neuschäfer @ 2012-07-23 14:01 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Jul 23, 2012 at 09:38:44PM +0800, Fan Yang wrote:
> May be I can work it by adding a new syscall in the kernel, right?

A sysfs-based interface should do it just as well.


Jonathan Neusch?fer

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23 13:38   ` Fan Yang
  2012-07-23 14:01     ` Jonathan Neuschäfer
@ 2012-07-23 17:38     ` Ram Tummala
  1 sibling, 0 replies; 8+ messages in thread
From: Ram Tummala @ 2012-07-23 17:38 UTC (permalink / raw)
  To: kernelnewbies

On Jul 23, 2012, at 7:08 PM, Fan Yang <lljyangfan@gmail.com> wrote:



2012/7/23 Ram Tummala <venkatram867@gmail.com>

> On Jul 23, 2012, at 9:32 AM, Fan Yang <lljyangfan@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
>
>
>
May be I can work it by adding a new syscall in the kernel, right?

Yes you can add a syscall in the kernel or can use procfs or sysfs but you
should fully understand the consequences. The code will never be accepted
by the kernel community. Exporting such functionality to the user space is
recipe for disaster. It would open up a simple DOS attack and that is just
a start.

Hardware Control registers are just not supposed to be handled by the user
space.

Venkatram Tummala
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120723/455da509/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* How can I change cr0 register in redhat system
  2012-07-23  4:00 How can I change cr0 register in redhat system Fan Yang
  2012-07-23  4:19 ` Ram Tummala
       [not found] ` <219833562776487968@unknownmsgid>
@ 2012-07-24  2:05 ` Peter Teoh
  2 siblings, 0 replies; 8+ messages in thread
From: Peter Teoh @ 2012-07-24  2:05 UTC (permalink / raw)
  To: kernelnewbies

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@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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120724/052c5102/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-24  2:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-23  4:00 How can I change cr0 register in redhat system Fan Yang
2012-07-23  4:19 ` Ram Tummala
2012-07-23  8:37   ` siddharth saxena
2012-07-23 11:40     ` Jonathan Neuschäfer
     [not found] ` <219833562776487968@unknownmsgid>
2012-07-23 13:38   ` Fan Yang
2012-07-23 14:01     ` Jonathan Neuschäfer
2012-07-23 17:38     ` Ram Tummala
2012-07-24  2:05 ` Peter Teoh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.