3 msgproblem with my account

regarding privilege levels of pentium 4
\ ranjith kumar (30 Sep 2006)
. \ Sven Eschenberg (30 Sep 2006)
. . \ ranjith kumar (30 Sep 2006)
. . . \ ArtÅ«ras Moskvinas (30 Sep 2006)
. . . . \ Tim Prince (1 Oct 2006)
. . . \ Sven Eschenberg (30 Sep 2006)

6 msghow to generate code-loops
1 msgHow to get address and size of a section
2 msgStill can't build C++ for xscale-elf
1 msgMac OS X: sudo gcc_select 4.0: Error trying to ...
1 msgENQUIRY
1 msgRe: Trampoline implementation for MIPS
2 msgAdding -R to specs, need assistance
2 msgproblems building ARM compiler
1 msgautovect and autoparallel
1 msgCompiling from alternate root prefix.
3 msgRe: How do I build C++ for xscale-elf?
2 msgbinary compatibility between gcc 3.4.3 and 4.x
2 msgHiding constructior is required while no direct...
2 msgCan conditional compilation test strings?
5 msgHelp with gcc installation on AIX 5.3
2 msgcollect2: ld returned 1 exit status
7 msgAssembly constraints - offset?
2 msgrtl.def
Subject:Re: regarding privilege levels of pentium 4
Group:Gcc-help
From:Sven Eschenberg
Date:30 Sep 2006


Again, this is not a gcc question, but a linxu question. The right place
might be kerneltrap etc., but for now, try digging google for CPU rings
/ CPU ring levels ...

For x86, ring level 0 is the only ring allowing cli/sti among some other
calls. In Linux those are exclusive for KERNEL SPACE, thus, no user
program can perform these instructions, it will trigger a segmentation
fault, since it tries to cross the limits of the ring it is run in (I
assume ring 3, I am not sure though) ....

Regards

-Sven

P.S.: You certainly will have to write a kernel driver/module to use
those calls - I assume that's why there is a kernel profiling
infrastructure (Read the kernel's documentation) ...

P.P.S.: Further Reading I recommend, aside from the kernel docs: CPU
Manual on Protected Mode and Rings, general Books on Operating systems ...

ranjith kumar wrote:
> --- Sven Eschenberg <eschenb>
> wrote:
>
>
>> Hi Ranjith,
>>
>> I might be wrong on this, but I think the question
>> is, if the Operating
>> System permits it or under which circumstances. It's
>> neither a question
>> of what gcc or the hardware does, but what the OS
>> you are using allows
>> to which processes.
>>
> Thanks. I am sending more details of my problem.
>
> The OS I am using : Linux.
> The language in which the program is written : C(I am
> attaching the program)
> The compiler : gcc 3.2.3
> Processor : Pentium 4
> I know password for root login. I logged in as root
> and compiled my program. When compiled no errors were
> reported. But when I run the program it simply shows
> "Segmentation fault".
>
> My goal is to measure performance parameters (for
> example the number of branch instructions that were
> mispredicted), on Pentium 4, using "RDMSR" and "WRMSR"
> instructions. Also I want to disble interrupts while
> running my program.
> The problem is that those instructions can be run only
> at privilege level zero.
>
> Can you help me.
> Thanks.
>
>
>
>> It might be, you need 'just' root priviledges, but
>> I'd rather assume,
>> that you need to be within the kernel's context,
>> since a cli command
>> endangers system stability (it could lead to a lock
>> up) ...
>>
>> Regards
>>
>> -Sven
>>
>> ranjith kumar wrote:
>>
>>> Hi,
>>>
>>>
>>> How can we tell at what privilege level a
>>>
>> program is
>>
>>> running.
>>> Is it possible to run a program at privilege
>>>
>> level
>>
>>> 'zero' on a processor
>>> like Pentium 4.
>>>
>>> Actually I want to disable interrupts while
>>>
>> running
>>
>>> my program. This
>>> can be done by "cli" instruction. Using "asm
>>>
>> inline"
>>
>>> feature of GCC, we
>>> can include assembly instructions in programs of
>>>
>> C,
>>
>>> C++...etc.
>>>
>>> But the problem is that "cli" instruction can
>>>
>> be
>>
>>> executed only at
>>> privilege level "zero".
>>>
>>> Can anyone help me.
>>>
>>>
>>>
>>>
>>> Thanking you.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
> ___________________________________________________________
>
>>> All new Yahoo! Mail "The new Interface is stunning
>>>
>> in its simplicity and ease of use." - PC Magazine
>>
>>> http://uk.docs.yahoo.com/nowyoucan.html
>>>
>>>
>>
>
>
>
>
>
> ___________________________________________________________
> All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine
> http://uk.docs.yahoo.com/nowyoucan.html
> ------------------------------------------------------------------------
>
> #include<stdio.h>
> int main(void)
> {
> unsigned int p1;
> asm volatile ("cli;");
>
>
> asm volatile (" movl $0x300, %%ecx;"
> "RDPMC;"
> "movl %%eax, %0;"
> :"=r"(p1)
> :
> :"%ecx","%edx","%eax");
>
> printf("\n %u\n",p1);
>
>
> asm volatile ("sti;");
>
> }
>
>



© 2004-2008 readlist.com