• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Consolidate code that checks reason for wake from nap · e3bbbbfa
    Paul Mackerras authored
    Currently in book3s_hv_rmhandlers.S we have three places where we
    have woken up from nap mode and we check the reason field in SRR1
    to see what event woke us up.  This consolidates them into a new
    function, kvmppc_check_wake_reason.  It looks at the wake reason
    field in SRR1, and if it indicates that an external interrupt caused
    the wakeup, calls kvmppc_read_intr to check what sort of interrupt
    it was.
    
    This also consolidates the two places where we synthesize an external
    interrupt (0x500 vector) for the guest.  Now, if the guest exit code
    finds that there was an external interrupt which has been handled
    (i.e. it was an IPI indicating that there is now an interrupt pending
    for the guest), it jumps to deliver_guest_interrupt, which is in the
    last part of the guest entry code, where we synthesize guest external
    and decrementer interrupts.  That code has been streamlined a little
    and now clears LPCR[MER] when appropriate as well as setting it.
    
    The extra clearing of any pending IPI on a secondary, offline CPU
    thread before going back to nap mode has been removed.  It is no longer
    necessary now that we have code to read and acknowledge IPIs in the
    guest exit path.
    
    This fixes a minor bug in the H_CEDE real-mode handling - previously,
    if we found that other threads were already exiting the guest when we
    were about to go to nap mode, we would branch to the cede wakeup path
    and end up looking in SRR1 for a wakeup reason.  Now we branch to a
    point after we have checked the wakeup reason.
    
    This also fixes a minor bug in kvmppc_read_intr - previously it could
    return 0xff rather than 1, in the case where we find that a host IPI
    is pending after we have cleared the IPI.  Now it returns 1.
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
    e3bbbbfa
book3s_hv_rmhandlers.S 49.6 KB