Skip to content

Commit 45121ad

Browse files
jepioherbertx
authored andcommitted
crypto: ccp - Clear PSP interrupt status register before calling handler
The PSP IRQ is edge-triggered (MSI or MSI-X) in all cases supported by the psp module so clear the interrupt status register early in the handler to prevent missed interrupts. sev_irq_handler() calls wake_up() on a wait queue, which can result in a new command being submitted from a different CPU. This then races with the clearing of isr and can result in missed interrupts. A missed interrupt results in a command waiting until it times out, which results in the psp being declared dead. This is unlikely on bare metal, but has been observed when running virtualized. In the cases where this is observed, sev->cmdresp_reg has PSP_CMDRESP_RESP set which indicates that the command was processed correctly but no interrupt was asserted. The full sequence of events looks like this: CPU 1: submits SEV cmd #1 CPU 1: calls wait_event_timeout() CPU 0: enters psp_irq_handler() CPU 0: calls sev_handler()->wake_up() CPU 1: wakes up; finishes processing cmd #1 CPU 1: submits SEV cmd #2 CPU 1: calls wait_event_timeout() PSP: finishes processing cmd #2; interrupt status is still set; no interrupt CPU 0: clears intsts CPU 0: exits psp_irq_handler() CPU 1: wait_event_timeout() times out; psp_dead=true Fixes: 200664d ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") Cc: [email protected] Signed-off-by: Jeremi Piotrowski <[email protected]> Acked-by: Tom Lendacky <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 9697b32 commit 45121ad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/crypto/ccp/psp-dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ static irqreturn_t psp_irq_handler(int irq, void *data)
4343
/* Read the interrupt status: */
4444
status = ioread32(psp->io_regs + psp->vdata->intsts_reg);
4545

46+
/* Clear the interrupt status by writing the same value we read. */
47+
iowrite32(status, psp->io_regs + psp->vdata->intsts_reg);
48+
4649
/* invoke subdevice interrupt handlers */
4750
if (status) {
4851
if (psp->sev_irq_handler)
4952
psp->sev_irq_handler(irq, psp->sev_irq_data, status);
5053
}
5154

52-
/* Clear the interrupt status by writing the same value we read. */
53-
iowrite32(status, psp->io_regs + psp->vdata->intsts_reg);
54-
5555
return IRQ_HANDLED;
5656
}
5757

0 commit comments

Comments
 (0)