<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi, <br>
I try this :<br>
<br>&nbsp;local_irq_save(flags);<br>
&nbsp;kvm_hypercall2 ( 6, 2, 2);<br>
&nbsp;local_irq_restore(flags);<br>
<br>
But I still have my kernel panic with  "divide error: 0000 [#1] SMP" that I don't understand!<br>
with or without lock, nothing change, the same when I change the current state.<br>
<br>
I tried to move my hypercall and I still don't understand why it works just before my test<br>
"if (piga_on == 1)" without any protections (like disable interrupts) and not after..<br>
<br>
<em><strong></strong></em> Thank you for trying to help me<br><br><br>&gt; Date: Thu, 9 Jun 2011 09:46:12 +0800<br>&gt; Subject: Re: Problems with hypercalls<br>&gt; From: htmldeveloper@gmail.com<br>&gt; To: tricheurs@hotmail.fr<br>&gt; CC: kernelnewbies@kernelnewbies.org<br>&gt; <br>&gt; perhaps this example will provide u with more info:<br>&gt; <br>&gt; http://a380.informatik.uni-bremen.de/lxr/source/arch/x86/lguest/boot.c<br>&gt; <br>&gt; I think the correct step is to disable IRQ instead - before every call<br>&gt; to kvm_hypercallX().   The reason is given in the remark:<br>&gt; <br>&gt; 110         /*<br>&gt; 111          * Disable interrupts if not already disabled: we don't want an<br>&gt; 112          * interrupt handler making a hypercall while we're already doing<br>&gt; 113          * one!<br>&gt; 114          */<br>&gt; <br>&gt; On Wed, Jun 8, 2011 at 10:54 PM, emilie lefebvre &lt;tricheurs@hotmail.fr&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; This is my function :<br>&gt; &gt;<br>&gt; &gt; static spinlock_t xgr_learn_lock = SPIN_LOCK_UNLOCKED;<br>&gt; &gt; static int piga_seq_cpt = 1;<br>&gt; &gt;<br>&gt; &gt; /*<br>&gt; &gt; * Function called for each systemcall (Hook SELinux avc function)<br>&gt; &gt; */<br>&gt; &gt; int piga_control(u32 ssid, ...., struct av_decision * avd) {<br>&gt; &gt;<br>&gt; &gt; /*<br>&gt; &gt; * Here my hypercall work but block my vm with this error :<br>&gt; &gt; * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " BUG: scheduling while atomic ... "<br>&gt; &gt; */<br>&gt; &gt;<br>&gt; &gt; spin_lock_bh(&amp;xgr_learn_lock);<br>&gt; &gt; &nbsp; if ( in_atomic())<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned<br>&gt; &gt; long)piga_seq_cpt);<br>&gt; &gt; &nbsp; spin_unlock_bh(&amp;xgr_learn_lock);<br>&gt; &gt;<br>&gt; &gt; &nbsp;if (piga_on == 1) {<br>&gt; &gt; /*<br>&gt; &gt; * Here my hypercall make a kernel panic with this error:<br>&gt; &gt; * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " divide error: 0000 [#1] SMP"<br>&gt; &gt; */<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spin_lock_bh(&amp;xgr_learn_lock);<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set_current_state(TASK_UNINTERRUPTIBLE);<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kvm_hypercall2 ( 6, (unsigned long)2 ,(unsigned<br>&gt; &gt; long)piga_seq_cpt);<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set_current_state(TASK_RUNNING);<br>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spin_lock_bh(&amp;xgr_learn_lock);<br>&gt; &gt; }<br>&gt; &gt; }<br>&gt; &gt;<br>&gt; &gt;<br>&gt; <br>&gt; I think u generally set TASK_UNINTERRUPTIBLE whenever about to modify<br>&gt; the scheduling task list (eg, wait queue manipulation) or about to<br>&gt; call "schedule()" (ie, doing your own scheduling).   The function<br>&gt; set_current_state() literally just set the variable value only, it<br>&gt; does not disable interrupt.<br>&gt; <br>&gt; -- <br>&gt; Regards,<br>&gt; Peter Teoh<br>&gt; <br>&gt; _______________________________________________<br>&gt; Kernelnewbies mailing list<br>&gt; Kernelnewbies@kernelnewbies.org<br>&gt; http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br>                                               </body>
</html>