* Problems with hypercalls @ 2011-06-07 8:39 emilie lefebvre 2011-06-08 9:55 ` Mulyadi Santosa 0 siblings, 1 reply; 8+ messages in thread From: emilie lefebvre @ 2011-06-07 8:39 UTC (permalink / raw) To: kernelnewbies Hi all, I try to do hypercalls but I always have a kernel panic that I don't understand. I have Scentific Linux 6 installed on kvm and my computer has ubuntu. I try to modify the SL6 kernel to do hypercalls. I have a function in that kernel which check all syscalls in the VM. When I put the hypercall at the beginning of this function, it perfectly works, but when I try to put it in the middle of the function I have a kernel panic with this error: "divide error: 0000 [#1] SMP ... [<ffffffff813f8cdd>] panic+0x78/0x137 [<ffffffff813fcb94>] oops_end+0xe4/0x100 [<ffffffff8101021b>] die+0x5b/0x90 [<ffffffff813fc444>] do_trap+0xc4/0x160 [<ffffffff8100df2f>] do_divide_error+0x8f/0xb0 [<ffffffff811f974c>] ? my_function+0xdc/0xe70 " Could you have any suggestions ? With regards, Emilie -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110607/01e508ed/attachment.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-07 8:39 Problems with hypercalls emilie lefebvre @ 2011-06-08 9:55 ` Mulyadi Santosa 2011-06-08 10:22 ` Rajat Sharma 0 siblings, 1 reply; 8+ messages in thread From: Mulyadi Santosa @ 2011-06-08 9:55 UTC (permalink / raw) To: kernelnewbies On Tue, Jun 7, 2011 at 15:39, emilie lefebvre <tricheurs@hotmail.fr> wrote: > "divide error: 0000 [#1] SMP > ... > ?[<ffffffff813f8cdd>] panic+0x78/0x137 > ?[<ffffffff813fcb94>] oops_end+0xe4/0x100 > ?[<ffffffff8101021b>] die+0x5b/0x90 > ?[<ffffffff813fc444>] do_trap+0xc4/0x160 > ?[<ffffffff8100df2f>] do_divide_error+0x8f/0xb0 > ?[<ffffffff811f974c>] ? my_function+0xdc/0xe70 " > > Could you have any suggestions ? Could you show us your code? perhaps by pasting them somewhere? >From what I guess, sounds like your code did some math (directly or indirectly) that fiddle with floating point numbers? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-08 9:55 ` Mulyadi Santosa @ 2011-06-08 10:22 ` Rajat Sharma 2011-06-08 14:54 ` emilie lefebvre 0 siblings, 1 reply; 8+ messages in thread From: Rajat Sharma @ 2011-06-08 10:22 UTC (permalink / raw) To: kernelnewbies are you doing 64bit devision on 32 bit arch? If that is the case, do_div is worth considering. On Wed, Jun 8, 2011 at 3:25 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com> wrote: > On Tue, Jun 7, 2011 at 15:39, emilie lefebvre <tricheurs@hotmail.fr> wrote: >> "divide error: 0000 [#1] SMP >> ... >> ?[<ffffffff813f8cdd>] panic+0x78/0x137 >> ?[<ffffffff813fcb94>] oops_end+0xe4/0x100 >> ?[<ffffffff8101021b>] die+0x5b/0x90 >> ?[<ffffffff813fc444>] do_trap+0xc4/0x160 >> ?[<ffffffff8100df2f>] do_divide_error+0x8f/0xb0 >> ?[<ffffffff811f974c>] ? my_function+0xdc/0xe70 " >> >> Could you have any suggestions ? > > Could you show us your code? perhaps by pasting them somewhere? > > >From what I guess, sounds like your code did some math (directly or > indirectly) that fiddle with floating point numbers? > > > -- > regards, > > Mulyadi Santosa > Freelance Linux trainer and consultant > > blog: the-hydra.blogspot.com > training: mulyaditraining.blogspot.com > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-08 10:22 ` Rajat Sharma @ 2011-06-08 14:54 ` emilie lefebvre 2011-06-08 16:46 ` Mulyadi Santosa 2011-06-09 1:46 ` Peter Teoh 0 siblings, 2 replies; 8+ messages in thread From: emilie lefebvre @ 2011-06-08 14:54 UTC (permalink / raw) To: kernelnewbies This is my function : static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED; static int piga_seq_cpt = 1; /* * Function called for each systemcall (Hook SELinux avc function) */ int piga_control(u32 ssid, ...., struct av_decision * avd) { /* * Here my hypercall work but block my vm with this error : * " BUG: scheduling while atomic ... " */ spin_lock_bh(&xgr_learn_lock); if ( in_atomic()) kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned long)piga_seq_cpt); spin_unlock_bh(&xgr_learn_lock); if (piga_on == 1) { /* * Here my hypercall make a kernel panic with this error: * " divide error: 0000 [#1] SMP" */ spin_lock_bh(&xgr_learn_lock); set_current_state(TASK_UNINTERRUPTIBLE); kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned long)piga_seq_cpt); set_current_state(TASK_RUNNING); spin_lock_bh(&xgr_learn_lock); } } > Date: Wed, 8 Jun 2011 15:52:33 +0530 > Subject: Re: Problems with hypercalls > From: fs.rajat at gmail.com > To: mulyadi.santosa at gmail.com > CC: tricheurs at hotmail.fr; kernelnewbies at kernelnewbies.org > > are you doing 64bit devision on 32 bit arch? If that is the case, > do_div is worth considering. > > On Wed, Jun 8, 2011 at 3:25 PM, Mulyadi Santosa > <mulyadi.santosa@gmail.com> wrote: > > On Tue, Jun 7, 2011 at 15:39, emilie lefebvre <tricheurs@hotmail.fr> wrote: > >> "divide error: 0000 [#1] SMP > >> ... > >> [<ffffffff813f8cdd>] panic+0x78/0x137 > >> [<ffffffff813fcb94>] oops_end+0xe4/0x100 > >> [<ffffffff8101021b>] die+0x5b/0x90 > >> [<ffffffff813fc444>] do_trap+0xc4/0x160 > >> [<ffffffff8100df2f>] do_divide_error+0x8f/0xb0 > >> [<ffffffff811f974c>] ? my_function+0xdc/0xe70 " > >> > >> Could you have any suggestions ? > > > > Could you show us your code? perhaps by pasting them somewhere? > > > > >From what I guess, sounds like your code did some math (directly or > > indirectly) that fiddle with floating point numbers? > > > > > > -- > > regards, > > > > Mulyadi Santosa > > Freelance Linux trainer and consultant > > > > blog: the-hydra.blogspot.com > > training: mulyaditraining.blogspot.com > > > > _______________________________________________ > > Kernelnewbies mailing list > > Kernelnewbies at kernelnewbies.org > > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110608/f040c726/attachment.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-08 14:54 ` emilie lefebvre @ 2011-06-08 16:46 ` Mulyadi Santosa 2011-06-09 1:46 ` Peter Teoh 1 sibling, 0 replies; 8+ messages in thread From: Mulyadi Santosa @ 2011-06-08 16:46 UTC (permalink / raw) To: kernelnewbies Hi... On Wed, Jun 8, 2011 at 21:54, emilie lefebvre <tricheurs@hotmail.fr> wrote: > > This is my function : > > static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED; > static int piga_seq_cpt = 1; > > /* > * Function called for each systemcall (Hook SELinux avc function) > */ > int piga_control(u32 ssid, ...., struct av_decision * avd) { > > /* > * Here my hypercall work but block my vm with this error : > * ?????????????? " BUG: scheduling while atomic ... " > */ > > spin_lock_bh(&xgr_learn_lock); > ? if ( in_atomic()) > ?????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > long)piga_seq_cpt); AFAIK, anything that trigger context switching, usually trigger rescheduling too....or in other word, does blocking. Therefore, grabbing lock must be avoided IMHO > ? spin_unlock_bh(&xgr_learn_lock); > > ?if (piga_on == 1) { > /* > * Here my hypercall make a kernel panic with this error: > * ??????????? " divide error: 0000 [#1] SMP" > */ > ??????????????? spin_lock_bh(&xgr_learn_lock); > ??????????????? set_current_state(TASK_UNINTERRUPTIBLE); wait wait, why setting as uninterruptible? > ??????????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > long)piga_seq_cpt); > ??????????????? set_current_state(TASK_RUNNING); > ??????????????? spin_lock_bh(&xgr_learn_lock); > } > } > > > > > >> Date: Wed, 8 Jun 2011 15:52:33 +0530 >> Subject: Re: Problems with hypercalls >> From: fs.rajat at gmail.com >> To: mulyadi.santosa at gmail.com >> CC: tricheurs at hotmail.fr; kernelnewbies at kernelnewbies.org >> >> are you doing 64bit devision on 32 bit arch? If that is the case, >> do_div is worth considering. >> >> On Wed, Jun 8, 2011 at 3:25 PM, Mulyadi Santosa >> <mulyadi.santosa@gmail.com> wrote: >> > On Tue, Jun 7, 2011 at 15:39, emilie lefebvre <tricheurs@hotmail.fr> >> > wrote: >> >> "divide error: 0000 [#1] SMP >> >> ... >> >> ?[<ffffffff813f8cdd>] panic+0x78/0x137 >> >> ?[<ffffffff813fcb94>] oops_end+0xe4/0x100 >> >> ?[<ffffffff8101021b>] die+0x5b/0x90 >> >> ?[<ffffffff813fc444>] do_trap+0xc4/0x160 >> >> ?[<ffffffff8100df2f>] do_divide_error+0x8f/0xb0 >> >> ?[<ffffffff811f974c>] ? my_function+0xdc/0xe70 " >> >> >> >> Could you have any suggestions ? >> > >> > Could you show us your code? perhaps by pasting them somewhere? >> > >> > >From what I guess, sounds like your code did some math (directly or >> > indirectly) that fiddle with floating point numbers? >> > >> > >> > -- >> > regards, >> > >> > Mulyadi Santosa >> > Freelance Linux trainer and consultant >> > >> > blog: the-hydra.blogspot.com >> > training: mulyaditraining.blogspot.com >> > >> > _______________________________________________ >> > Kernelnewbies mailing list >> > Kernelnewbies at kernelnewbies.org >> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> > >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-08 14:54 ` emilie lefebvre 2011-06-08 16:46 ` Mulyadi Santosa @ 2011-06-09 1:46 ` Peter Teoh 2011-06-09 8:35 ` emilie lefebvre 1 sibling, 1 reply; 8+ messages in thread From: Peter Teoh @ 2011-06-09 1:46 UTC (permalink / raw) To: kernelnewbies perhaps this example will provide u with more info: http://a380.informatik.uni-bremen.de/lxr/source/arch/x86/lguest/boot.c I think the correct step is to disable IRQ instead - before every call to kvm_hypercallX(). The reason is given in the remark: 110 /* 111 * Disable interrupts if not already disabled: we don't want an 112 * interrupt handler making a hypercall while we're already doing 113 * one! 114 */ On Wed, Jun 8, 2011 at 10:54 PM, emilie lefebvre <tricheurs@hotmail.fr> wrote: > > This is my function : > > static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED; > static int piga_seq_cpt = 1; > > /* > * Function called for each systemcall (Hook SELinux avc function) > */ > int piga_control(u32 ssid, ...., struct av_decision * avd) { > > /* > * Here my hypercall work but block my vm with this error : > * ?????????????? " BUG: scheduling while atomic ... " > */ > > spin_lock_bh(&xgr_learn_lock); > ? if ( in_atomic()) > ?????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > long)piga_seq_cpt); > ? spin_unlock_bh(&xgr_learn_lock); > > ?if (piga_on == 1) { > /* > * Here my hypercall make a kernel panic with this error: > * ??????????? " divide error: 0000 [#1] SMP" > */ > ??????????????? spin_lock_bh(&xgr_learn_lock); > ??????????????? set_current_state(TASK_UNINTERRUPTIBLE); > ??????????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > long)piga_seq_cpt); > ??????????????? set_current_state(TASK_RUNNING); > ??????????????? spin_lock_bh(&xgr_learn_lock); > } > } > > I think u generally set TASK_UNINTERRUPTIBLE whenever about to modify the scheduling task list (eg, wait queue manipulation) or about to call "schedule()" (ie, doing your own scheduling). The function set_current_state() literally just set the variable value only, it does not disable interrupt. -- Regards, Peter Teoh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-09 1:46 ` Peter Teoh @ 2011-06-09 8:35 ` emilie lefebvre 2011-06-09 16:46 ` Peter Teoh 0 siblings, 1 reply; 8+ messages in thread From: emilie lefebvre @ 2011-06-09 8:35 UTC (permalink / raw) To: kernelnewbies Hi, I try this : local_irq_save(flags); kvm_hypercall2 ( 6, 2, 2); local_irq_restore(flags); But I still have my kernel panic with "divide error: 0000 [#1] SMP" that I don't understand! with or without lock, nothing change, the same when I change the current state. I tried to move my hypercall and I still don't understand why it works just before my test "if (piga_on == 1)" without any protections (like disable interrupts) and not after.. Thank you for trying to help me > Date: Thu, 9 Jun 2011 09:46:12 +0800 > Subject: Re: Problems with hypercalls > From: htmldeveloper at gmail.com > To: tricheurs at hotmail.fr > CC: kernelnewbies at kernelnewbies.org > > perhaps this example will provide u with more info: > > http://a380.informatik.uni-bremen.de/lxr/source/arch/x86/lguest/boot.c > > I think the correct step is to disable IRQ instead - before every call > to kvm_hypercallX(). The reason is given in the remark: > > 110 /* > 111 * Disable interrupts if not already disabled: we don't want an > 112 * interrupt handler making a hypercall while we're already doing > 113 * one! > 114 */ > > On Wed, Jun 8, 2011 at 10:54 PM, emilie lefebvre <tricheurs@hotmail.fr> wrote: > > > > This is my function : > > > > static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED; > > static int piga_seq_cpt = 1; > > > > /* > > * Function called for each systemcall (Hook SELinux avc function) > > */ > > int piga_control(u32 ssid, ...., struct av_decision * avd) { > > > > /* > > * Here my hypercall work but block my vm with this error : > > * " BUG: scheduling while atomic ... " > > */ > > > > spin_lock_bh(&xgr_learn_lock); > > if ( in_atomic()) > > kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > > long)piga_seq_cpt); > > spin_unlock_bh(&xgr_learn_lock); > > > > if (piga_on == 1) { > > /* > > * Here my hypercall make a kernel panic with this error: > > * " divide error: 0000 [#1] SMP" > > */ > > spin_lock_bh(&xgr_learn_lock); > > set_current_state(TASK_UNINTERRUPTIBLE); > > kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned > > long)piga_seq_cpt); > > set_current_state(TASK_RUNNING); > > spin_lock_bh(&xgr_learn_lock); > > } > > } > > > > > > I think u generally set TASK_UNINTERRUPTIBLE whenever about to modify > the scheduling task list (eg, wait queue manipulation) or about to > call "schedule()" (ie, doing your own scheduling). The function > set_current_state() literally just set the variable value only, it > does not disable interrupt. > > -- > Regards, > Peter Teoh > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110609/875b6475/attachment-0001.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with hypercalls 2011-06-09 8:35 ` emilie lefebvre @ 2011-06-09 16:46 ` Peter Teoh 0 siblings, 0 replies; 8+ messages in thread From: Peter Teoh @ 2011-06-09 16:46 UTC (permalink / raw) To: kernelnewbies I guessed the cause of the error is really somewhere else - nothing to do with this part. But without a full view of the entire source - it is hard to diagnose the bugs. (Perhaps even more difficult if full view is available). But I have no problem insmod lg.ko in drivers/lguest directory (after CONFIG_LGUEST is set to "m"), and lguest is not a simple example I must say. And to get a better understanding on how to use the kvm_hypercall APIs, just go to the kernel source's drivers/lguest directory and enter "make" and it will churns lots of information (totalling about 7000+ lines) teaching you the basic of KVM - both how the KVM hypervisor works, and how the lguest work. And if u are lazy to do a "make" this is my version: https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B1hg6_FvnEa8ZjFjMDQxNzAtZDAyZC00MDA2LTk3YmMtNGE5YjdjZDM0Nzc3&hl=en_US On Thu, Jun 9, 2011 at 4:35 PM, emilie lefebvre <tricheurs@hotmail.fr> wrote: > Hi, > I try this : > > ?local_irq_save(flags); > ?kvm_hypercall2 ( 6, 2, 2); > ?local_irq_restore(flags); > > But I still have my kernel panic with "divide error: 0000 [#1] SMP" that I > don't understand! > with or without lock, nothing change, the same when I change the current > state. > > I tried to move my hypercall and I still don't understand why it works just > before my test > "if (piga_on == 1)" without any protections (like disable interrupts) and > not after.. > > Thank you for trying to help me > > >> Date: Thu, 9 Jun 2011 09:46:12 +0800 >> Subject: Re: Problems with hypercalls >> From: htmldeveloper at gmail.com >> To: tricheurs at hotmail.fr >> CC: kernelnewbies at kernelnewbies.org >> >> perhaps this example will provide u with more info: >> >> http://a380.informatik.uni-bremen.de/lxr/source/arch/x86/lguest/boot.c >> >> I think the correct step is to disable IRQ instead - before every call >> to kvm_hypercallX(). The reason is given in the remark: >> >> 110 /* >> 111 * Disable interrupts if not already disabled: we don't want an >> 112 * interrupt handler making a hypercall while we're already doing >> 113 * one! >> 114 */ >> >> On Wed, Jun 8, 2011 at 10:54 PM, emilie lefebvre <tricheurs@hotmail.fr> >> wrote: >> > >> > This is my function : >> > >> > static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED; >> > static int piga_seq_cpt = 1; >> > >> > /* >> > * Function called for each systemcall (Hook SELinux avc function) >> > */ >> > int piga_control(u32 ssid, ...., struct av_decision * avd) { >> > >> > /* >> > * Here my hypercall work but block my vm with this error : >> > * ?????????????? " BUG: scheduling while atomic ... " >> > */ >> > >> > spin_lock_bh(&xgr_learn_lock); >> > ? if ( in_atomic()) >> > ?????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned >> > long)piga_seq_cpt); >> > ? spin_unlock_bh(&xgr_learn_lock); >> > >> > ?if (piga_on == 1) { >> > /* >> > * Here my hypercall make a kernel panic with this error: >> > * ??????????? " divide error: 0000 [#1] SMP" >> > */ >> > ??????????????? spin_lock_bh(&xgr_learn_lock); >> > ??????????????? set_current_state(TASK_UNINTERRUPTIBLE); >> > ??????????????? kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned >> > long)piga_seq_cpt); >> > ??????????????? set_current_state(TASK_RUNNING); >> > ??????????????? spin_lock_bh(&xgr_learn_lock); >> > } >> > } >> > >> > >> >> I think u generally set TASK_UNINTERRUPTIBLE whenever about to modify >> the scheduling task list (eg, wait queue manipulation) or about to >> call "schedule()" (ie, doing your own scheduling). The function >> set_current_state() literally just set the variable value only, it >> does not disable interrupt. >> >> -- >> Regards, >> Peter Teoh >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -- Regards, Peter Teoh ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-06-09 16:46 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-06-07 8:39 Problems with hypercalls emilie lefebvre 2011-06-08 9:55 ` Mulyadi Santosa 2011-06-08 10:22 ` Rajat Sharma 2011-06-08 14:54 ` emilie lefebvre 2011-06-08 16:46 ` Mulyadi Santosa 2011-06-09 1:46 ` Peter Teoh 2011-06-09 8:35 ` emilie lefebvre 2011-06-09 16:46 ` Peter Teoh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).