<br clear="all">Hi. This is my first ever post on any kernel mailing list so be gentle :)<br><br>In lguest.c in the function async_hcall the local variable next_call is always 0 and in consequence we always access lguest_data.hcall_status[0] and lguest_data.hcalls[0]. 
<br>Also, why does the next_call variable is incremented at the end of the function considering that it&#39;s a local variable and it will disappear afterwards.<br>This code would be correct only if somehow the value of local variable next_call is remembered across function calls. If this is the case, could you please explain?
<br><br>Sorry if my post is stupid but I promise my posts will get better over time.<br><br>void async_hcall(unsigned long call,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;unsigned long arg1, unsigned long arg2, unsigned long arg3)<br>{<br>&nbsp;&nbsp;&nbsp; /* Note: This code assumes we&#39;re uniprocessor. */
<br>&nbsp;&nbsp;&nbsp; static unsigned int next_call;<br>&nbsp;&nbsp;&nbsp; unsigned long flags;<br><br>&nbsp;&nbsp;&nbsp; /* Disable interrupts if not already disabled: we don&#39;t want an<br>&nbsp;&nbsp;&nbsp; &nbsp;* interrupt handler making a hypercall while we&#39;re already doing
<br>&nbsp;&nbsp;&nbsp; &nbsp;* one! */<br>&nbsp;&nbsp;&nbsp; local_irq_save(flags);<br>&nbsp;&nbsp;&nbsp; if (lguest_data.hcall_status[next_call] != 0xFF) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* Table full, so do normal hcall which will flush table. */<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hcall(call, arg1, arg2, arg3);<br>
&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lguest_data.hcalls[next_call].eax = call;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lguest_data.hcalls[next_call].edx = arg1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lguest_data.hcalls[next_call].ebx = arg2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lguest_data.hcalls[next_call].ecx = arg3;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* Arguments must all be written before we mark it to go */<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wmb();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lguest_data.hcall_status[next_call] = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (++next_call == LHCALL_RING_SIZE)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; next_call = 0;<br>
&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; local_irq_restore(flags);<br>}<br><br>-- <br>Catalin Morosan