[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250611040842.2667262-4-aik@amd.com>
Date: Wed, 11 Jun 2025 14:08:41 +1000
From: Alexey Kardashevskiy <aik@....com>
To: <x86@...nel.org>
CC: <linux-kernel@...r.kernel.org>, Thomas Gleixner <tglx@...utronix.de>,
"Ingo Molnar" <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, Dave Hansen
<dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>, Tom Lendacky
<thomas.lendacky@....com>, Nikunj A Dadhania <nikunj@....com>, Ard Biesheuvel
<ardb@...nel.org>, Ashish Kalra <ashish.kalra@....com>, Dionna Glaze
<dionnaglaze@...gle.com>, Michael Roth <michael.roth@....com>, "Kuppuswamy
Sathyanarayanan" <sathyanarayanan.kuppuswamy@...ux.intel.com>, "Alexey
Kardashevskiy" <aik@....com>
Subject: [PATCH v2 3/4] x86/sev: Document requirement for linear mapping of Guest Request buffers
The Guest Request supports 3 types of messages now, the largest is
the extended variant of MSG_REPORT_REQ: sizeof(snp_ext_report_req)==112.
These used to be allocated on stack and then moved to the SNP guest
platform device (snp_guest_dev) for the reason explained in
commit db10cb9b5746 ("virt: sevguest: Fix passing a stack buffer as
a scatterlist target"):
aesgcm_encrypt() and aesgcm_decrypt() are used for guest messages and
might potentially use a crypto accelerator which requires DMA buffers
to be in the linear mapping.
Add a comment, pr_warn() and return -EINVAL when the buffers are not
in linear mapping.
Reviewed-by: Tom Lendacky <thomas.lendacky@....com>
Reviewed-by: Dionna Glaze <dionnaglaze@...gle.com>
Signed-off-by: Alexey Kardashevskiy <aik@....com>
---
Changes:
v2:
* adjust grammar
---
arch/x86/coco/sev/core.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 068653865bfb..b0d423a353ab 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -2008,6 +2008,15 @@ int snp_send_guest_request(struct snp_msg_desc *mdesc, struct snp_guest_req *req
u64 seqno;
int rc;
+ /*
+ * enc_payload() calls aesgcm_encrypt(), which can potentially offload to HW.
+ * The offload's DMA SG list of data to encrypt has to be in linear mapping.
+ */
+ if (!virt_addr_valid(req->req_buf) || !virt_addr_valid(req->resp_buf)) {
+ pr_warn("AES-GSM buffers must be in linear mapping");
+ return -EINVAL;
+ }
+
guard(mutex)(&snp_cmd_mutex);
/* Check if the VMPCK is not empty */
--
2.49.0
Powered by blists - more mailing lists