linux/drivers/crypto
Jeremi Piotrowski 45121ad4a1 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: 200664d523 ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")
Cc: stable@vger.kernel.org
Signed-off-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2023-04-06 16:19:45 +08:00
..
allwinner crypto: sun8i-ce - Add TRNG clock to the D1 variant 2023-01-13 16:39:04 +08:00
amcc crypto: crypto4xx - remove unnecessary (void*) conversions 2023-03-24 18:22:28 +08:00
amlogic crypto: amlogic - Remove kcalloc without check 2022-12-02 18:12:40 +08:00
aspeed crypto: aspeed - fix uninitialized symbol 'idx' warning 2023-03-14 17:06:45 +08:00
axis crypto: artpec6 - Use request_complete helpers 2023-02-13 18:34:49 +08:00
bcm crypto: bcm - Use request_complete helpers 2023-02-13 18:34:49 +08:00
caam crypto: caam - Clear some memory in instantiate_rng 2023-03-31 17:50:09 +08:00
cavium crypto: cavium/nitrox - remove unnecessary aer.h include 2023-03-17 11:16:43 +08:00
ccp crypto: ccp - Clear PSP interrupt status register before calling handler 2023-04-06 16:19:45 +08:00
ccree crypto: ccree - Use devm_platform_get_and_ioremap_resource() 2023-03-14 17:06:42 +08:00
chelsio crypto: chelsio - Use request_complete helpers 2023-02-13 18:34:49 +08:00
gemini Revert "crypto: gemini - Fix error check for dma_map_sg" 2022-09-02 18:15:53 +08:00
hisilicon crypto: hisilicon/zip - remove unnecessary aer.h include 2023-03-17 11:16:43 +08:00
inside-secure crypto: safexcel - Cleanup ring IRQ workqueues on load failure 2023-03-14 17:06:44 +08:00
keembay crypto: keembay - Drop if with an always false condition 2023-03-24 18:22:28 +08:00
marvell crypto: octeontx2 - Fix objects shared between several modules 2023-02-14 13:39:33 +08:00
nx crypto: nx - Fix sparse warnings 2023-02-14 13:39:33 +08:00
qat crypto: qat - drop redundant adf_enable_aer() 2023-03-17 11:16:43 +08:00
qce crypto: qce - Add a QCE IP family compatible 'qcom,qce' 2023-03-14 17:06:44 +08:00
rockchip crypto: rockchip - Remove surplus dev_err() when using platform_get_irq() 2022-11-11 18:14:59 +08:00
stm32 crypto: stm32 - Use devm_platform_get_and_ioremap_resource() 2023-03-24 18:22:28 +08:00
virtio This update includes the following changes: 2023-02-21 18:10:50 -08:00
vmx Merge branch 'topic/objtool' into next 2022-12-08 23:57:47 +11:00
xilinx crypto: xilinx: prevent probing on non-xilinx hardware 2022-03-09 15:12:31 +12:00
atmel-aes-regs.h
atmel-aes.c crypto: atmel - Use request_complete helpers 2023-02-13 18:34:49 +08:00
atmel-authenc.h crypto: sha - split sha.h into sha1.h and sha2.h 2020-11-20 14:45:33 +11:00
atmel-ecc.c This update includes the following changes: 2023-02-21 18:10:50 -08:00
atmel-i2c.c This update includes the following changes: 2023-02-21 18:10:50 -08:00
atmel-i2c.h This update includes the following changes: 2023-02-21 18:10:50 -08:00
atmel-sha-regs.h
atmel-sha.c crypto: api - Use data directly in completion function 2023-02-13 18:35:14 +08:00
atmel-sha204a.c crypto: atmel-sha204a - Mark OF related data as maybe unused 2023-03-17 11:16:43 +08:00
atmel-tdes-regs.h
atmel-tdes.c crypto: atmel - Use request_complete helpers 2023-02-13 18:34:49 +08:00
exynos-rng.c
geode-aes.c crypto: geode - use DEFINE_SPINLOCK() for spinlock 2021-04-16 21:16:31 +10:00
geode-aes.h
hifn_795x.c crypto: drivers - remove unnecessary (void*) conversions 2023-03-24 18:22:28 +08:00
img-hash.c crypto: img-hash - Fix img_hash_match unused warning 2023-03-31 17:50:09 +08:00
ixp4xx_crypto.c crypto: ixp4xx - Use request_complete helpers 2023-02-13 18:34:49 +08:00
Kconfig crypto: sa2ul - Select CRYPTO_DES 2023-03-31 17:50:09 +08:00
Makefile crypto: ux500/hash - delete driver 2023-02-03 12:55:59 +08:00
mxs-dcp.c crypto: mxs-dcp - Use the devm_clk_get_optional_enabled() helper 2023-03-31 17:50:09 +08:00
n2_asm.S
n2_core.c crypto: n2 - add missing hash statesize 2022-10-21 19:15:35 +08:00
n2_core.h
omap-aes-gcm.c crypto: omap-aes - avoid spamming console with self tests 2020-06-04 22:03:39 +10:00
omap-aes.c crypto: omap-aes - Drop if with an always false condition 2022-07-15 16:43:21 +08:00
omap-aes.h crypto: omap-aes - permit asynchronous skcipher as fallback 2020-07-16 21:49:02 +10:00
omap-crypto.c crypto: omap - Avoid redundant copy when using truncated sg list 2021-08-21 15:44:53 +08:00
omap-crypto.h
omap-des.c crypto: omap-des - Drop if with an always false condition 2022-07-15 16:43:21 +08:00
omap-sham.c crypto: omap-sham - Use pm_runtime_resume_and_get() in omap_sham_probe() 2022-12-02 18:12:40 +08:00
padlock-aes.c crypto: algapi - Remove skbuff.h inclusion 2020-08-20 14:04:28 +10:00
padlock-sha.c crypto: sha - split sha.h into sha1.h and sha2.h 2020-11-20 14:45:33 +11:00
qcom-rng.c crypto: qcom-rng - Fix qcom_rng_of_match unused warning 2022-08-19 18:39:35 +08:00
s5p-sss.c crypto: s5p-sss - Use request_complete helpers 2023-02-13 18:35:14 +08:00
sa2ul.c crypto: drivers - remove unnecessary (void*) conversions 2023-03-24 18:22:28 +08:00
sa2ul.h crypto: sa2ul - Check engine status before enabling 2022-07-15 16:43:22 +08:00
sahara.c crypto: drivers - remove unnecessary (void*) conversions 2023-03-24 18:22:28 +08:00
talitos.c crypto: talitos - Use request_complete helpers 2023-02-13 18:35:14 +08:00
talitos.h crypto: talitos - Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper 2022-10-21 19:05:24 +08:00