All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware
@ 2023-01-23 22:53 Tom Lendacky
  2023-02-03  5:04 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Lendacky @ 2023-01-23 22:53 UTC (permalink / raw)
  To: linux-crypto, linux-kernel; +Cc: Herbert Xu, David Miller, John Allen

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@amd.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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware
  2023-01-23 22:53 [PATCH] crypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware Tom Lendacky
@ 2023-02-03  5:04 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2023-02-03  5:04 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: linux-crypto, linux-kernel, David Miller, John Allen

On Mon, Jan 23, 2023 at 04:53:08PM -0600, Tom Lendacky wrote:
> 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@amd.com>
> ---
>  drivers/crypto/ccp/sev-dev.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-03  5:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 22:53 [PATCH] crypto: ccp - Flush the SEV-ES TMR memory before giving it to firmware Tom Lendacky
2023-02-03  5:04 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.