Skip to content

Commit 7ffeb2f

Browse files
aikbp3tk0v
authored andcommitted
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 db10cb9 ("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, warn and return an error when the buffers are not in linear mapping. Signed-off-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Reviewed-by: Dionna Glaze <[email protected]> Link: https://lore.kernel.org/[email protected]
1 parent d100016 commit 7ffeb2f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/x86/coco/sev/core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,15 @@ int snp_send_guest_request(struct snp_msg_desc *mdesc, struct snp_guest_req *req
20082008
u64 seqno;
20092009
int rc;
20102010

2011+
/*
2012+
* enc_payload() calls aesgcm_encrypt(), which can potentially offload to HW.
2013+
* The offload's DMA SG list of data to encrypt has to be in linear mapping.
2014+
*/
2015+
if (!virt_addr_valid(req->req_buf) || !virt_addr_valid(req->resp_buf)) {
2016+
pr_warn("AES-GSM buffers must be in linear mapping");
2017+
return -EINVAL;
2018+
}
2019+
20112020
guard(mutex)(&snp_cmd_mutex);
20122021

20132022
/* Check if the VMPCK is not empty */

0 commit comments

Comments
 (0)