[Lguest] is the code in function async_hcall correct?

Morosan Catalin morosancatalin at gmail.com
Wed Sep 5 17:49:06 EST 2007


Hi. This is my first ever post on any kernel mailing list so be gentle :)

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].
Also, why does the next_call variable is incremented at the end of the
function considering that it's a local variable and it will disappear
afterwards.
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?

Sorry if my post is stupid but I promise my posts will get better over time.

void async_hcall(unsigned long call,
         unsigned long arg1, unsigned long arg2, unsigned long arg3)
{
    /* Note: This code assumes we're uniprocessor. */
    static unsigned int next_call;
    unsigned long flags;

    /* Disable interrupts if not already disabled: we don't want an
     * interrupt handler making a hypercall while we're already doing
     * one! */
    local_irq_save(flags);
    if (lguest_data.hcall_status[next_call] != 0xFF) {
        /* Table full, so do normal hcall which will flush table. */
        hcall(call, arg1, arg2, arg3);
    } else {
        lguest_data.hcalls[next_call].eax = call;
        lguest_data.hcalls[next_call].edx = arg1;
        lguest_data.hcalls[next_call].ebx = arg2;
        lguest_data.hcalls[next_call].ecx = arg3;
        /* Arguments must all be written before we mark it to go */
        wmb();
        lguest_data.hcall_status[next_call] = 0;
        if (++next_call == LHCALL_RING_SIZE)
            next_call = 0;
    }
    local_irq_restore(flags);
}

-- 
Catalin Morosan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/lguest/attachments/20070905/a40b9294/attachment.htm>


More information about the Lguest mailing list