From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 65FC274003C for ; Fri, 1 Mar 2024 07:44:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9uImsYM6xSgwmaImzf9qHOmr0NovJ7TacvZJQH6pInU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1709279057; v=1; b=f7BXFkp41qRhv8YzAr6bT1FMFRyWN6E9n/V+Kd177GtfI6WJSEkLG1YMWywIYd5EmIbaBr/z xce8c8U6feVpKSQ4ql5dE/OTQJrZTferDWwRNGY1eJ6kiNOBN+DME8NGk6pDg5YRYKO0bgktkRB zC0PIGz6FpooEIk2BeKf6yGk= X-Received: by 127.0.0.2 with SMTP id YqEoYY7687511xbATdCtSQQ4; Thu, 29 Feb 2024 23:44:17 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.17690.1709279056393803466 for ; Thu, 29 Feb 2024 23:44:16 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-fI0pYi4LN6W16R9k-J0ztQ-1; Fri, 01 Mar 2024 02:44:11 -0500 X-MC-Unique: fI0pYi4LN6W16R9k-J0ztQ-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0DAFA106CFE3; Fri, 1 Mar 2024 07:44:11 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A56062026D0A; Fri, 1 Mar 2024 07:44:10 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EB5E7180149D; Fri, 1 Mar 2024 08:44:02 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Oliver Steffen , Laszlo Ersek , Michael Roth , Erdem Aktas , Gerd Hoffmann , Min Xu , Ard Biesheuvel , Tom Lendacky Subject: [edk2-devel] [PATCH v2 08/10] OvmfPkg/ResetVector: wire up 5-level paging for TDX Date: Fri, 1 Mar 2024 08:44:00 +0100 Message-ID: <20240301074402.98625-9-kraxel@redhat.com> In-Reply-To: <20240301074402.98625-1-kraxel@redhat.com> References: <20240301074402.98625-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: H4BY2EjWvQO36qBPvqKC5QIMx7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=f7BXFkp4; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io BSP workflow is quite simliar to the non-coco case. TDX_WORK_AREA_PGTBL_READY is used to record the paging mode: 1 == 4-level paging 2 == 5-level paging APs will look at TDX_WORK_AREA_PGTBL_READY to figure whenever they should enable 5-level paging or not. Signed-off-by: Gerd Hoffmann --- OvmfPkg/ResetVector/Ia32/IntelTdx.asm | 13 ++++++++++++- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/ResetVector/Ia32/IntelTdx.asm b/OvmfPkg/ResetVector/Ia32/IntelTdx.asm index c6b86019dfb9..7d775591a05b 100644 --- a/OvmfPkg/ResetVector/Ia32/IntelTdx.asm +++ b/OvmfPkg/ResetVector/Ia32/IntelTdx.asm @@ -179,7 +179,7 @@ InitTdx: ; ; Modified: EAX, EDX ; -; 0-NonTdx, 1-TdxBsp, 2-TdxAps +; 0-NonTdx, 1-TdxBsp, 2-TdxAps, 3-TdxAps5Level ; CheckTdxFeaturesBeforeBuildPagetables: xor eax, eax @@ -200,6 +200,17 @@ TdxPostBuildPageTables: mov byte[TDX_WORK_AREA_PGTBL_READY], 1 OneTimeCallRet TdxPostBuildPageTables +%if PG_5_LEVEL + +; +; Set byte[TDX_WORK_AREA_PGTBL_READY] to 2 +; +TdxPostBuildPageTables5Level: + mov byte[TDX_WORK_AREA_PGTBL_READY], 2 + OneTimeCallRet TdxPostBuildPageTables5Level + +%endif + ; ; Check if TDX is enabled ; diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm index e15945da0476..b922c845f297 100644 --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm @@ -44,6 +44,7 @@ BITS 32 %define TDX_BSP 1 %define TDX_AP 2 +%define TDX_AP_5_LEVEL 3 ; ; For OVMF, build some initial page tables at @@ -214,7 +215,14 @@ SetCr3ForPageTables64: je TdxBspInit cmp eax, TDX_AP je SetCr3 +%if PG_5_LEVEL + cmp eax, TDX_AP_5_LEVEL + jne CheckForSev + Enable5LevelPaging + jmp SetCr3 +%endif +CheckForSev: ; Check whether the SEV is active and populate the SevEsWorkArea OneTimeCall CheckSevFeatures cmp byte[WORK_AREA_GUEST_TYPE], 1 @@ -253,6 +261,14 @@ TdxBspInit: ; TDX BSP workflow ; ClearOvmfPageTables +%if PG_5_LEVEL + Check5LevelPaging Tdx4Level + CreatePageTables5Level 0 + OneTimeCall TdxPostBuildPageTables5Level + Enable5LevelPaging + jmp SetCr3 +Tdx4Level: +%endif CreatePageTables4Level 0 OneTimeCall TdxPostBuildPageTables jmp SetCr3 -- 2.44.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116222): https://edk2.groups.io/g/devel/message/116222 Mute This Topic: https://groups.io/mt/104660117/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-