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 4B93374003C for ; Fri, 1 Mar 2024 12:56:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+XiHtuOLNvwXI7HYKTbyj02VTX/KAPu9nveePYMqyhc=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1709297765; v=1; b=ENwGVtP70h795J5yHfLtLk++swYX4vfurwz6lqxL6J3DNxcngKFT9+I7TrtbSFoC38pRCY+E MaLDN8bnqofE5TLi0VwdS+ybuvPGej5E1eO683rab6Ij1ULSNUaXjoyxz3N6Y18iOHWBsrBOffj Nm7wDin6kFIa7BSnwIbxVGe4= X-Received: by 127.0.0.2 with SMTP id 1ZDXYY7687511x4Y5ktFGXq2; Fri, 01 Mar 2024 04:56:05 -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.web11.21900.1709297764257711452 for ; Fri, 01 Mar 2024 04:56:04 -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-447-OhcovD4iO82hgEpZBB5YAA-1; Fri, 01 Mar 2024 07:56:00 -0500 X-MC-Unique: OhcovD4iO82hgEpZBB5YAA-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 C080688CC45; Fri, 1 Mar 2024 12:55:59 +0000 (UTC) X-Received: from [10.39.194.215] (unknown [10.39.194.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48B2C40C6EBA; Fri, 1 Mar 2024 12:55:58 +0000 (UTC) Message-ID: Date: Fri, 1 Mar 2024 13:55:57 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 08/10] OvmfPkg/ResetVector: wire up 5-level paging for TDX To: devel@edk2.groups.io, kraxel@redhat.com Cc: Jiewen Yao , Oliver Steffen , Michael Roth , Erdem Aktas , Min Xu , Ard Biesheuvel , Tom Lendacky References: <20240301074402.98625-1-kraxel@redhat.com> <20240301074402.98625-9-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240301074402.98625-9-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zjFhO1pPnB61QzWKzai5Sg0ux7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=ENwGVtP7; 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 On 3/1/24 08:44, Gerd Hoffmann wrote: > BSP workflow is quite simliar to the non-coco case. >=20 > TDX_WORK_AREA_PGTBL_READY is used to record the paging mode: > 1 =3D=3D 4-level paging > 2 =3D=3D 5-level paging >=20 > APs will look at TDX_WORK_AREA_PGTBL_READY to figure whenever > they should enable 5-level paging or not. >=20 > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/ResetVector/Ia32/IntelTdx.asm | 13 ++++++++++++- > OvmfPkg/ResetVector/Ia32/PageTables64.asm | 16 ++++++++++++++++ > 2 files changed, 28 insertions(+), 1 deletion(-) >=20 > 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 > =20 > +%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/ResetVec= tor/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 > =20 > %define TDX_BSP 1 > %define TDX_AP 2 > +%define TDX_AP_5_LEVEL 3 > =20 > ; > ; 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 > =20 > +CheckForSev: > ; Check whether the SEV is active and populate the SevEsWorkArea > OneTimeCall CheckSevFeatures > cmp byte[WORK_AREA_GUEST_TYPE], 1 Minor nit: we don't neet the "CheckForSev:" jump label at all if PG_5_LEVEL is absent, so the "CheckForSev:" label definition should still be in the "%if PG_5_LEVEL" scope. (My proposal under v1 patch#6 was: %if PG_5_LEVEL cmp eax, TDX_AP_5_LEVEL jne CheckForSev Enable5LevelPaging jmp SetCr3 CheckForSev: %endif ) Did you place the "CheckForSev:" label intentionally outside of the %if scope? If it was intentional, then I'm OK with it. If it was unintended / an oversight, then next question: do you want me to move the label into the %if's scope for you, upon merge? Or do you like it better as written in your patch, after all? Reviewed-by: Laszlo Ersek Thanks Laszlo > @@ -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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116248): https://edk2.groups.io/g/devel/message/116248 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-