• R
    target/ppc: Fix system lockups caused by interrupt_request state corruption · 044897ef
    Richard Purdie 提交于
    Occasionally in Linux guests on x86_64 we're seeing logs like:
    
    ppc_set_irq: 0x55b4e0d562f0 n_IRQ 8 level 1 => pending 00000100req 00000004
    
    when they should read:
    
    ppc_set_irq: 0x55b4e0d562f0 n_IRQ 8 level 1 => pending 00000100req 00000002
    
    The "00000004" is CPU_INTERRUPT_EXITTB yet the code calls
    cpu_interrupt(cs, CPU_INTERRUPT_HARD) ("00000002") in this function
    just before the log message. Something is causing the HARD bit setting
    to get lost.
    
    The knock on effect of losing that bit is the decrementer timer interrupts
    don't get delivered which causes the guest to sit idle in its idle handler
    and 'hang'.
    
    The issue occurs due to races from code which sets CPU_INTERRUPT_EXITTB.
    
    Rather than poking directly into cs->interrupt_request, that code needs to:
    
    a) hold BQL
    b) use the cpu_interrupt() helper
    
    This patch fixes the call sites to do this, fixing the hang. The calls
    are made from a variety of contexts so a helper function is added to handle
    the necessary locking. This can likely be improved and optimised in the future
    but it ensures the code is correct and doesn't lockup as it stands today.
    Signed-off-by: NRichard Purdie <richard.purdie@linuxfoundation.org>
    Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
    044897ef
excp_helper.c 38.3 KB