• Suresh E. Warrier's avatar
    KVM: PPC: Book3S HV: Fix inaccuracies in ICP emulation for H_IPI · 5b88cda6
    Suresh E. Warrier authored
    This fixes some inaccuracies in the state machine for the virtualized
    ICP when implementing the H_IPI hcall (Set_MFFR and related states):
    
    1. The old code wipes out any pending interrupts when the new MFRR is
       more favored than the CPPR but less favored than a pending
       interrupt (by always modifying xisr and the pending_pri). This can
       cause us to lose a pending external interrupt.
    
       The correct code here is to only modify the pending_pri and xisr in
       the ICP if the MFRR is equal to or more favored than the current
       pending pri (since in this case, it is guaranteed that that there
       cannot be a pending external interrupt). The code changes are
       required in both kvmppc_rm_h_ipi and kvmppc_h_ipi.
    
    2. Again, in both kvmppc_rm_h_ipi and kvmppc_h_ipi, there is a check
       for whether MFRR is being made less favored AND further if new MFFR
       is also less favored than the current CPPR, we check for any
       resends pending in the ICP. These checks look like they are
       designed to cover the case where if the MFRR is being made less
       favored, we opportunistically trigger a resend of any interrupts
       that had been previously rejected. Although, this is not a state
       described by PAPR, this is an action we actually need to do
       especially if the CPPR is already at 0xFF.  Because in this case,
       the resend bit will stay on until another ICP state change which
       may be a long time coming and the interrupt stays pending until
       then. The current code which checks for MFRR < CPPR is broken when
       CPPR is 0xFF since it will not get triggered in that case.
    
       Ideally, we would want to do a resend only if
    
       	prio(pending_interrupt) < mfrr && prio(pending_interrupt) < cppr
    
       where pending interrupt is the one that was rejected. But we don't
       have the priority of the pending interrupt state saved, so we
       simply trigger a resend whenever the MFRR is made less favored.
    
    3. In kvmppc_rm_h_ipi, where we save state to pass resends to the
       virtual mode, we also need to save the ICP whose need_resend we
       reset since this does not need to be my ICP (vcpu->arch.icp) as is
       incorrectly assumed by the current code. A new field rm_resend_icp
       is added to the kvmppc_icp structure for this purpose.
    Signed-off-by: default avatarSuresh Warrier <warrier@linux.vnet.ibm.com>
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
    5b88cda6
book3s_xics.h 3.07 KB