From nobody Thu Dec 18 02:37:21 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4AD6F2376F4 for ; Wed, 26 Feb 2025 18:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740593718; cv=none; b=inpmHqRnA97xfx2sevhRbyCefj9BCnN2f9u3V/W30JLrvaI10ewEIJ3coLaZiGnkp4rV3FRal0hijjZP/0gP516hiaahB2BYzY28AiecBgv64mE0U9+s6vAyj+TgncU3FcmFQTb5vQd+KLNRdsJ8o3rWvuVHWo5qmbvLheLtC5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740593718; c=relaxed/simple; bh=O9ZzyfOn0JOlkxPGIrSAM2lvehpQC23fCK92ThFUqH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dLOemzTyp46XFLiBNdRIKxzbuTN1fRTMmFnDXCFGGSGzrJdkrI34qqGqaW+jjtcgoQDZoYVceu/DV4I0QacslGs6pIUeJSS0Pvy9Sydyawyahhp23O37U15AcQR/WW35iC80Pd1jL823E/LiRdDwvfvoF4Pl6cENYj2DSourJe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i8Q1Lcrs; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i8Q1Lcrs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740593715; h=from:from: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=eAWo7r+0FJM6VF1NEs5BudGty7K5q5afVeOpseAOVUM=; b=i8Q1Lcrsq//3J7KBQqpBFK4jYD14e0CY8FPPd66tHjLvKS7ASCESX38bGH2z7KO19wd9uJ E+I0cSg1rFUaIqzR9tjkSg9yY7WkR+KEWqOp8vgR3nr/cBj9drQB84CiCc/Uf6F5SbnxqA wVsQHQAqqfx4rglpsVMvBexohPnJM1A= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-Yvt70WBhM6iThZxb3VLzhg-1; Wed, 26 Feb 2025 13:15:13 -0500 X-MC-Unique: Yvt70WBhM6iThZxb3VLzhg-1 X-Mimecast-MFC-AGG-ID: Yvt70WBhM6iThZxb3VLzhg_1740593712 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0332E1903092; Wed, 26 Feb 2025 18:15:12 +0000 (UTC) Received: from virtlab1023.lab.eng.rdu2.redhat.com (virtlab1023.lab.eng.rdu2.redhat.com [10.8.1.187]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 08EE31955BD4; Wed, 26 Feb 2025 18:15:10 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, Yan Zhao , Rick Edgecombe , Kai Huang Subject: [PATCH 10/33] x86/virt/tdx: allocate tdx_sys_info in static memory Date: Wed, 26 Feb 2025 13:14:29 -0500 Message-ID: <20250226181453.2311849-11-pbonzini@redhat.com> In-Reply-To: <20250226181453.2311849-1-pbonzini@redhat.com> References: <20250226181453.2311849-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Adding all the information that KVM needs increases the size of struct tdx_sys_info, to the point that you can get warnings about the stack size of init_tdx_module(). Since KVM also needs to read the TDX metadata after init_tdx_module() returns, make the variable a global. Reviewed-by: Rick Edgecombe Reviewed-by: Kai Huang Signed-off-by: Paolo Bonzini --- arch/x86/virt/vmx/tdx/tdx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 369b264f4d9b..578ad468634b 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -53,6 +53,8 @@ static DEFINE_MUTEX(tdx_module_lock); /* All TDX-usable memory regions. Protected by mem_hotplug_lock. */ static LIST_HEAD(tdx_memlist); =20 +static struct tdx_sys_info tdx_sysinfo; + typedef void (*sc_err_func_t)(u64 fn, u64 err, struct tdx_module_args *arg= s); =20 static inline void seamcall_err(u64 fn, u64 err, struct tdx_module_args *a= rgs) @@ -1061,15 +1063,14 @@ static int init_tdmrs(struct tdmr_info_list *tdmr_l= ist) =20 static int init_tdx_module(void) { - struct tdx_sys_info sysinfo; int ret; =20 - ret =3D get_tdx_sys_info(&sysinfo); + ret =3D get_tdx_sys_info(&tdx_sysinfo); if (ret) return ret; =20 /* Check whether the kernel can support this module */ - ret =3D check_features(&sysinfo); + ret =3D check_features(&tdx_sysinfo); if (ret) return ret; =20 @@ -1090,12 +1091,12 @@ static int init_tdx_module(void) goto out_put_tdxmem; =20 /* Allocate enough space for constructing TDMRs */ - ret =3D alloc_tdmr_list(&tdx_tdmr_list, &sysinfo.tdmr); + ret =3D alloc_tdmr_list(&tdx_tdmr_list, &tdx_sysinfo.tdmr); if (ret) goto err_free_tdxmem; =20 /* Cover all TDX-usable memory regions in TDMRs */ - ret =3D construct_tdmrs(&tdx_memlist, &tdx_tdmr_list, &sysinfo.tdmr); + ret =3D construct_tdmrs(&tdx_memlist, &tdx_tdmr_list, &tdx_sysinfo.tdmr); if (ret) goto err_free_tdmrs; =20 --=20 2.43.5