execute asm from linux user space

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

execute asm from linux user space

2,009 次查看
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 项奖励
回复
5 回复数

1,603 次查看
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 项奖励
回复

1,603 次查看
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 项奖励
回复

1,603 次查看
scottwood
NXP Employee
NXP Employee

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

0 项奖励
回复

1,603 次查看
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 项奖励
回复

1,603 次查看
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 项奖励
回复