From: Alexey Kardashevskiy <aik@amd.com>
To: <x86@kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>,
Ard Biesheuvel <ardb@kernel.org>,
Brijesh Singh <brijesh.singh@amd.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Michael Roth <michael.roth@amd.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Liam Merwick <liam.merwick@oracle.com>,
Alexey Kardashevskiy <aik@amd.com>
Subject: [PATCH 3/4] x86/sev: Document requirement for linear mapping of Guest Request buffers
Date: Tue, 6 May 2025 00:12:37 +1000 [thread overview]
Message-ID: <20250505141238.4179623-4-aik@amd.com> (raw)
In-Reply-To: <20250505141238.4179623-1-aik@amd.com>
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.
Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
Changes:
v4:
* ditched BUG_ON and ifdef
---
arch/x86/coco/sev/core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 818ae7b1694b..0b714df62445 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -1941,6 +1941,16 @@ int snp_send_guest_request(struct snp_msg_desc *mdesc, struct snp_guest_req *req
u64 seqno;
int rc;
+ /*
+ * enc_payload() calling aesgcm_encrypt() can potentially offload to HW
+ * which involves DMA so the data to encrypt in the SG list 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
next prev parent reply other threads:[~2025-05-05 14:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 14:12 [PATCH 0/4] x86/sev: Rework SNP Guest Request Alexey Kardashevskiy
2025-05-05 14:12 ` [PATCH 1/4] virt: sev-guest: Contain snp_guest_request_ioctl in sev-guest Alexey Kardashevskiy
2025-05-05 15:11 ` Dionna Amalie Glaze
2025-05-05 14:12 ` [PATCH 2/4] x86/sev: Allocate request in TSC_INFO_REQ on stack Alexey Kardashevskiy
2025-05-05 15:13 ` Dionna Amalie Glaze
2025-05-05 16:03 ` Dave Hansen
2025-05-06 2:05 ` Alexey Kardashevskiy
2025-05-05 14:12 ` Alexey Kardashevskiy [this message]
2025-05-05 15:18 ` [PATCH 3/4] x86/sev: Document requirement for linear mapping of Guest Request buffers Dionna Amalie Glaze
2025-05-05 14:12 ` [PATCH 4/4] x86/sev: Drop unnecessary parameter in snp_issue_guest_request Alexey Kardashevskiy
2025-05-05 15:19 ` Dionna Amalie Glaze
2025-05-06 18:55 ` [PATCH 0/4] x86/sev: Rework SNP Guest Request Tom Lendacky
2025-06-05 2:40 ` Alexey Kardashevskiy
2025-06-06 12:57 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250505141238.4179623-4-aik@amd.com \
--to=aik@amd.com \
--cc=ardb@kernel.org \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=liam.merwick@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox