I just remove the statement "msr cpsr_c,r7". But It just doesn't Work. And If I change the code to the following: I set the vcpu_state_t registers as following : vcpu->r()->r[6]=(l4_umword_t)exit_map_addr; vcpu->r()->r[4]=(l4_umword_t)(idle_stack+sizeof(idle_stack)-1); vcpu->r()->ip =(l4_umword_t)super_code_map_addr; vcpu->r()->r[5] = (l4_umword_t)idle_code_map_addr; vcpu->r()->sp = (l4_umword_t)0x30000; and I change the my_super_code : asm ( ".pushsection .text\n" ".p2align 12 \t\n" ".global my_super_code \t\n" "my_super_code: \t\n" " swi 0 \t\n" " mov sp, r4 \t\n"" mov lr, r6 \t\n"" mov pc, r5 \t\n"".popsection"); and still, it doesn't work.And The vcpu upcall function will be called again and again.
2012-08-03
raylei0825ssdut
发件人:l4-hackers-request 发送时间:2012-08-03 18:00 主题:l4-hackers Digest, Vol 112, Issue 3 收件人:"l4-hackers"l4-hackers@os.inf.tu-dresden.de 抄送:
Send l4-hackers mailing list submissions to l4-hackers@os.inf.tu-dresden.de
To subscribe or unsubscribe via the World Wide Web, visit http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers or, via email, send a message with subject or body 'help' to l4-hackers-request@os.inf.tu-dresden.de
You can reach the person managing the list at l4-hackers-owner@os.inf.tu-dresden.de
When replying, please edit your Subject line so it is more specific than "Re: Contents of l4-hackers digest..."
Today's Topics:
1. Re: vcpu example problem (Adam Lackorzynski)
----------------------------------------------------------------------
Message: 1 Date: Thu, 2 Aug 2012 22:14:21 +0200 From: Adam Lackorzynski adam@os.inf.tu-dresden.de To: l4-hackers@os.inf.tu-dresden.de Subject: Re: vcpu example problem Message-ID: 20120802201421.GA7129@os.inf.tu-dresden.de Content-Type: text/plain; charset=iso-8859-1
Hi,
On Thu Aug 02, 2012 at 11:14:34 +0800, ?????? wrote:
Hi, I am trying to modify the vcpu example of l4re-snapshot to switch registers to execute my C function.But It doesn't work. I have read some papers about l4linux tranplantion.and follow it . To switch the process, I fill the vcpu_state_t structure with its registers.and call vcpu_resume_commit action.Then Jump to the ASM Code. But problem arises when I want to jump from asm code to C function. What's the Problem? The Code is as following:
#define SVC_MODE 0x00000013 #define USR_MODE 0x00000010
asm volatile ( ".pushsection .text\n" ".p2align 12 \t\n" ".global my_super_code \t\n" "my_super_code: \t\n" " msr cpsr_c, r7\t\n" " mov lr, r6 \t\n" " mov pc, r5 \t\n" //" b my_super_code \t\n" ".popsection" );
I think the problem is not the jump but the msr, which you cannot do in user-land and which you probably can safely remove.
Adam -- Adam adam@os.inf.tu-dresden.de Lackorzynski http://os.inf.tu-dresden.de/~adam/
------------------------------
_______________________________________________ l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
End of l4-hackers Digest, Vol 112, Issue 3 ******************************************
On Fri Aug 03, 2012 at 19:37:21 +0800, raylei0825ssdut wrote:
I just remove the statement "msr cpsr_c,r7". But It just doesn't Work. And If I change the code to the following: I set the vcpu_state_t registers as following : vcpu->r()->r[6]=(l4_umword_t)exit_map_addr; vcpu->r()->r[4]=(l4_umword_t)(idle_stack+sizeof(idle_stack)-1); vcpu->r()->ip =(l4_umword_t)super_code_map_addr; vcpu->r()->r[5] = (l4_umword_t)idle_code_map_addr; vcpu->r()->sp = (l4_umword_t)0x30000; and I change the my_super_code : asm ( ".pushsection .text\n" ".p2align 12 \t\n" ".global my_super_code \t\n" "my_super_code: \t\n" " swi 0 \t\n" " mov sp, r4 \t\n"" mov lr, r6 \t\n"" mov pc, r5 \t\n"".popsection"); and still, it doesn't work.And The vcpu upcall function will be called again and again.
The first instruction to be executed is the 'swi' which will cause a call of the entry. There it needs to be handled, check for example the pc value you're getting, it should point to the location. After handling the swi, the pc needs to be adapted to point behind the instruction (or whereever you like the code to go on). If the pc is not adapted, a resume will continue on the swi and everything will start again. r4 is also unaligned. There's no need to substract 1 but if you want to you should substract multiple of 4.
Adam
l4-hackers@os.inf.tu-dresden.de