[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <9d112c35bf613a42453e05c69ec0c96a32ba6078.1674514388.git.thomas.lendacky@amd.com>
Date: Mon, 23 Jan 2023 16:53:08 -0600
From: Tom Lendacky <thomas.lendacky@....com>
To: <linux-crypto@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Herbert Xu <herbert@...dor.apana.org.au>,
David Miller <davem@...emloft.net>,
John Allen <john.allen@....com>
Subject: [PATCH] crypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware
Perform a cache flush on the SEV-ES TMR memory after allocation to prevent
any possibility of the firmware encountering an error should dirty cache
lines be present. Use clflush_cache_range() to flush the SEV-ES TMR memory.
Fixes: 97f9ac3db661 ("crypto: ccp - Add support for SEV-ES to the PSP driver")
Signed-off-by: Tom Lendacky <thomas.lendacky@....com>
---
drivers/crypto/ccp/sev-dev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 06fc7156c04f..04059b705db4 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -26,6 +26,7 @@
#include <linux/fs_struct.h>
#include <asm/smp.h>
+#include <asm/cacheflush.h>
#include "psp-dev.h"
#include "sev-dev.h"
@@ -1327,7 +1328,10 @@ void sev_pci_init(void)
/* Obtain the TMR memory area for SEV-ES use */
sev_es_tmr = sev_fw_alloc(SEV_ES_TMR_SIZE);
- if (!sev_es_tmr)
+ if (sev_es_tmr)
+ /* Must flush the cache before giving it to the firmware */
+ clflush_cache_range(sev_es_tmr, SEV_ES_TMR_SIZE);
+ else
dev_warn(sev->dev,
"SEV: TMR allocation failed, SEV-ES support unavailable\n");
--
2.39.0
Powered by blists - more mailing lists