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 5A251AC10CD for ; Thu, 22 Feb 2024 11:54:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WThCogLiSSysKQ05Wzacj9mUe/LF6aLxwoxyzFmRcQg=; 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=1708602888; v=1; b=UCwaC1ZrhRV8uDwJcIw/aA12GtKXWiI5EgI0Ea/BdWDF34SoQH5KH/wGyYTTa6jRBwIvxyUE Igg6lxAsZlgrJF/9OHDCbLAQXoSeB1gNqSoRs5RQ3M6D2QtAxX94lBr8UOwHP7qKpQ2DjAWR68X f4dZ2kXBjWSCY8fJ+rdKG3oA= X-Received: by 127.0.0.2 with SMTP id sucPYY7687511xHCpydN2hMu; Thu, 22 Feb 2024 03:54:48 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.11059.1708602887299653762 for ; Thu, 22 Feb 2024 03:54:47 -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-12-Ls5h0kcnOOOLqIEjy8SENQ-1; Thu, 22 Feb 2024 06:54:45 -0500 X-MC-Unique: Ls5h0kcnOOOLqIEjy8SENQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 B340F85A596; Thu, 22 Feb 2024 11:54:44 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.237]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08C351C060AF; Thu, 22 Feb 2024 11:54:44 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 32D131801EA8; Thu, 22 Feb 2024 12:54:36 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Tom Lendacky , Jiewen Yao , Oliver Steffen , Laszlo Ersek , Erdem Aktas , Michael Roth , Ard Biesheuvel , Gerd Hoffmann , Min Xu Subject: [edk2-devel] [PATCH 08/10] OvmfPkg/ResetVector: wire up 5-level paging for TDX Date: Thu, 22 Feb 2024 12:54:33 +0100 Message-ID: <20240222115435.85794-9-kraxel@redhat.com> In-Reply-To: <20240222115435.85794-1-kraxel@redhat.com> References: <20240222115435.85794-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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: iaSBmbKIyXRGZ1vWjY8CQXxsx7686176AA= 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=UCwaC1Zr; 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 | 12 ++++++++++++ 2 files changed, 24 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 d736db028277..ada3dc0ffbe0 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,6 +215,10 @@ SetCr3ForPageTables64: je TdxBspInit cmp eax, TDX_AP je SetCr3 +%if PG_5_LEVEL + cmp eax, TDX_AP_5_LEVEL + je SetCr3La57 +%endif ; Check whether the SEV is active and populate the SevEsWorkArea OneTimeCall CheckSevFeatures @@ -252,6 +257,13 @@ TdxBspInit: ; TDX BSP workflow ; ClearOvmfPageTables +%if PG_5_LEVEL + Check5LevelPaging Tdx4Level + CreatePageTables5Level 0 + OneTimeCall TdxPostBuildPageTables5Level + jmp SetCr3La57 +Tdx4Level: +%endif CreatePageTables4Level 0 OneTimeCall TdxPostBuildPageTables jmp SetCr3 -- 2.43.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115808): https://edk2.groups.io/g/devel/message/115808 Mute This Topic: https://groups.io/mt/104506795/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-