execute asm from linux user space

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

execute asm from linux user space

2,010 Views
ramakrishnakatt
Contributor II

I have written simple program and compile with all environment settings which are mentioned in SDK. But still getting error as

Illegal instruction

/opt/fsl-networking/QorIQ-SDK-V1.5/sysroots/i686-fsl_networking_sdk-linux/usr/bin/ppce5500-fsl_networking-linux/powerpc-fsl_networking-linux-gcc asm.c -o myasm

static inline int ppc_get_msr (void)

{

int value;

asm volatile ("mfmsr %0" : "=r" (value));

return (value);

}

int main()

{

unsigned int value;

value =  ppc_get_msr();

printf("value:%x\n",value);

}

0 Kudos
Reply
5 Replies

1,604 Views
marius_grigoras
NXP Employee
NXP Employee

Hi,

Please note that you can't play with mfmsr and mtmsr instructions in user space (these are privileged instructions) - you can use these in a bare-board code (like u-boot for example) or directly in kernel.

Regards,

Marius

0 Kudos
Reply

1,604 Views
ramakrishnakatt
Contributor II

Hi Marius,

we are working on Diag tool, earlier it is based on non-os. Now it is moved to Linux, so we want to use same code in user space. This is mandatory for us other wise we have to rewrite much code. Please suggest some solution to execute this from user space

0 Kudos
Reply

1,604 Views
scottwood
NXP Employee
NXP Employee

Sorry, it's not possible.  What is the code trying to accomplish with MSR?

0 Kudos
Reply

1,604 Views
marius_grigoras
NXP Employee
NXP Employee

Hi again,

Maybe if you tell us what you're trying to do we find out a solution/work-around for you. Basically, for a normal application in user space, you shouldn't need any MSR instructions and let the kernel make this for you (you can use some system calls for this - I'm not very familiar with the SDK and I don;t know if these system calls already exists for MSR, but I'm pretty sure you can define all these). Maybe somebody from SDK team can help better than me.

Marius

0 Kudos
Reply

1,604 Views
scottwood
NXP Employee
NXP Employee

There are no system calls for manipulating MSR, nor should there be.  There's a reason that it is a privileged register.  If userspace could arbitrarily alter MSR, it could disable interrupts and hang the core.

0 Kudos
Reply