From nobody Thu Oct 9 06:59:10 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51545224AF0; Thu, 19 Jun 2025 10:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750329608; cv=none; b=Jz0Ffu7hdDj5i0vvMoESL7yq68LupspZI3CknwW0ryM4YPDBKc6DmcZlvh8J0mLBFoAWLe89MeMEpcdifkMN7uAXbwrSTUTgBC9Dv3myYQxXN0BMA/ViOrPJDqq6FtRjX8Um2PQ2cBGuOD88jYsI6XajnVRG1azBM1dwRcbbu3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750329608; c=relaxed/simple; bh=DMGaZkz9pQD1kC1thY3OZTk7PaEVZFMeBJ58gk3kYpQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=hxGZUDOuSyNVlSLODEg+xJvN6B+j2tiYkLMQ7vbClBGyO8ehR7ZbYU0YyOuFInf8F4y04YZSW1SqZvnCDK3SEELsIN6TgdimtosD7puBV+YYOIraf+phaQusFF1EXR/0Z2OWFDMgbJnZ0q1q4U3V7Y7/nJXfC8Jtjcw7FpJj63k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=emb6IaN/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kDzNb3bH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="emb6IaN/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kDzNb3bH" Date: Thu, 19 Jun 2025 10:39:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1750329600; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TBSlEodZjrrKka1/yLufs30uSHqZl0RYfmCz9cTx1Ak=; b=emb6IaN/Fgen0xoLKYafD7pgTSxIYzPvCBr0x54GIAMuIUc7BpxnhWINj5n4ZIAYKW6M66 tHy8mxZUn0/fnH/bqNE24f0ZNb847rWqQgg8m9cq0JiyWbYk+t0mOgIhdUY3znzmRdyqxh lhWivEyAQe7OW529ACU/xwpgmnKxhkEspt3saUnAHqUaECDWcTPWHeXbgJmQeuBC6aLJwx ZqOcRpEstycrSGhkyTZ40vbpKSa8Q2qJwO1DiZcuw1pN504T5LTBgSsAHTDupSa7oDXxZd MhyAOMCtZ/lv7UqZ6YXAL5uHdTsXyeqEQyzUBqy3W7fIZC02pUozN1eZTrec4g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1750329600; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TBSlEodZjrrKka1/yLufs30uSHqZl0RYfmCz9cTx1Ak=; b=kDzNb3bHfpREwtm4j2Ad1QoaLzzzHEe+UMChFqV9Squ2SibiW2XcdqG/26dZnmCcieUYyN bwdIrbxxT9B3ZiAg== From: "tip-bot2 for Alexey Kardashevskiy" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] x86/sev: Allocate request in TSC_INFO_REQ on stack Cc: Alexey Kardashevskiy , "Borislav Petkov (AMD)" , Tom Lendacky , Dionna Glaze , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250611040842.2667262-3-aik@amd.com> References: <20250611040842.2667262-3-aik@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <175032959912.406.12738123807711242663.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/sev branch of tip: Commit-ID: d100016eac21636c8c0507a83bc32d9eb8cd56ab Gitweb: https://git.kernel.org/tip/d100016eac21636c8c0507a83bc32d9eb= 8cd56ab Author: Alexey Kardashevskiy AuthorDate: Wed, 11 Jun 2025 14:08:40 +10:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 18 Jun 2025 22:55:39 +02:00 x86/sev: Allocate request in TSC_INFO_REQ on stack Allocate a 88 byte request structure on stack and skip needless kzalloc/kfree. While at this, correct indent. No functional change intended. Signed-off-by: Alexey Kardashevskiy Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Reviewed-by: Dionna Glaze Link: https://lore.kernel.org/20250611040842.2667262-3-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 cf91cb4..0686538 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 =3D {}; int rc =3D -ENOMEM; =20 tsc_req =3D 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; =20 - req =3D kzalloc(sizeof(*req), GFP_KERNEL); - if (!req) - goto e_free_tsc_resp; - mdesc =3D snp_msg_alloc(); if (IS_ERR_OR_NULL(mdesc)) - goto e_free_req; + goto e_free_tsc_resp; =20 rc =3D snp_msg_init(mdesc, snp_vmpl); if (rc) goto e_free_mdesc; =20 - req->msg_version =3D MSG_HDR_VER; - req->msg_type =3D SNP_MSG_TSC_INFO_REQ; - req->vmpck_id =3D snp_vmpl; - req->req_buf =3D tsc_req; - req->req_sz =3D sizeof(*tsc_req); - req->resp_buf =3D (void *)tsc_resp; - req->resp_sz =3D sizeof(*tsc_resp) + AUTHTAG_LEN; - req->exit_code =3D SVM_VMGEXIT_GUEST_REQUEST; + req.msg_version =3D MSG_HDR_VER; + req.msg_type =3D SNP_MSG_TSC_INFO_REQ; + req.vmpck_id =3D snp_vmpl; + req.req_buf =3D tsc_req; + req.req_sz =3D sizeof(*tsc_req); + req.resp_buf =3D (void *)tsc_resp; + req.resp_sz =3D sizeof(*tsc_resp) + AUTHTAG_LEN; + req.exit_code =3D SVM_VMGEXIT_GUEST_REQUEST; =20 - rc =3D snp_send_guest_request(mdesc, req); + rc =3D snp_send_guest_request(mdesc, &req); if (rc) goto e_request; =20 @@ -2127,9 +2123,7 @@ e_request: 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);