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>,
Ashish Kalra <ashish.kalra@amd.com>,
Dionna Glaze <dionnaglaze@google.com>,
Michael Roth <michael.roth@amd.com>,
"Kuppuswamy Sathyanarayanan"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
"Alexey Kardashevskiy" <aik@amd.com>
Subject: [PATCH v2 2/4] x86/sev: Allocate request in TSC_INFO_REQ on stack
Date: Wed, 11 Jun 2025 14:08:40 +1000 [thread overview]
Message-ID: <20250611040842.2667262-3-aik@amd.com> (raw)
In-Reply-To: <20250611040842.2667262-1-aik@amd.com>
Allocate a 88 byte request structure on stack and skip needless
kzalloc/kfree.
While at this, correct indent.
No functional change intended.
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Dionna Glaze <dionnaglaze@google.com>
Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
arch/x86/coco/sev/core.c | 30 ++++++++------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index cf91cb4e2c47..068653865bfb 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -2069,7 +2069,7 @@ static int __init snp_get_tsc_info(void)
struct snp_tsc_info_resp *tsc_resp;
struct snp_tsc_info_req *tsc_req;
struct snp_msg_desc *mdesc;
- struct snp_guest_req *req;
+ struct snp_guest_req req = {};
int rc = -ENOMEM;
tsc_req = kzalloc(sizeof(*tsc_req), GFP_KERNEL);
@@ -2085,28 +2085,24 @@ static int __init snp_get_tsc_info(void)
if (!tsc_resp)
goto e_free_tsc_req;
- req = kzalloc(sizeof(*req), GFP_KERNEL);
- if (!req)
- goto e_free_tsc_resp;
-
mdesc = snp_msg_alloc();
if (IS_ERR_OR_NULL(mdesc))
- goto e_free_req;
+ goto e_free_tsc_resp;
rc = snp_msg_init(mdesc, snp_vmpl);
if (rc)
goto e_free_mdesc;
- req->msg_version = MSG_HDR_VER;
- req->msg_type = SNP_MSG_TSC_INFO_REQ;
- req->vmpck_id = snp_vmpl;
- req->req_buf = tsc_req;
- req->req_sz = sizeof(*tsc_req);
- req->resp_buf = (void *)tsc_resp;
- req->resp_sz = sizeof(*tsc_resp) + AUTHTAG_LEN;
- req->exit_code = SVM_VMGEXIT_GUEST_REQUEST;
+ req.msg_version = MSG_HDR_VER;
+ req.msg_type = SNP_MSG_TSC_INFO_REQ;
+ req.vmpck_id = snp_vmpl;
+ req.req_buf = tsc_req;
+ req.req_sz = sizeof(*tsc_req);
+ req.resp_buf = (void *)tsc_resp;
+ req.resp_sz = sizeof(*tsc_resp) + AUTHTAG_LEN;
+ req.exit_code = SVM_VMGEXIT_GUEST_REQUEST;
- rc = snp_send_guest_request(mdesc, req);
+ rc = snp_send_guest_request(mdesc, &req);
if (rc)
goto e_request;
@@ -2127,9 +2123,7 @@ static int __init snp_get_tsc_info(void)
memzero_explicit(tsc_resp, sizeof(*tsc_resp) + AUTHTAG_LEN);
e_free_mdesc:
snp_msg_free(mdesc);
-e_free_req:
- kfree(req);
- e_free_tsc_resp:
+e_free_tsc_resp:
kfree(tsc_resp);
e_free_tsc_req:
kfree(tsc_req);
--
2.49.0
next prev parent reply other threads:[~2025-06-11 4:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 4:08 [PATCH v2 0/4] x86/sev: Rework SNP Guest Request Alexey Kardashevskiy
2025-06-11 4:08 ` [PATCH v2 1/4] virt: sev-guest: Contain snp_guest_request_ioctl in sev-guest Alexey Kardashevskiy
2025-06-19 10:40 ` [tip: x86/sev] " tip-bot2 for Alexey Kardashevskiy
2025-06-11 4:08 ` Alexey Kardashevskiy [this message]
2025-06-19 10:39 ` [tip: x86/sev] x86/sev: Allocate request in TSC_INFO_REQ on stack tip-bot2 for Alexey Kardashevskiy
2025-06-11 4:08 ` [PATCH v2 3/4] x86/sev: Document requirement for linear mapping of Guest Request buffers Alexey Kardashevskiy
2025-06-19 10:39 ` [tip: x86/sev] x86/sev: Document requirement for linear mapping of guest request buffers tip-bot2 for Alexey Kardashevskiy
2025-06-11 4:08 ` [PATCH v2 4/4] x86/sev: Drop unnecessary parameter in snp_issue_guest_request Alexey Kardashevskiy
2025-06-19 10:39 ` [tip: x86/sev] x86/sev: Drop unnecessary parameter in snp_issue_guest_request() tip-bot2 for Alexey Kardashevskiy
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=20250611040842.2667262-3-aik@amd.com \
--to=aik@amd.com \
--cc=ardb@kernel.org \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dionnaglaze@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj@amd.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 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.