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 B643BAC0471 for ; Wed, 28 Feb 2024 05:51:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Dv57C1gZddjYNXxy1TLdg8k0a3RATuWjIcoEKnEALoc=; 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=1709099511; v=1; b=hv9jGWBBJSBTqyRfe0Y7vx/8ZNoOy1ODEc1cs+lGycme/OyBRV3q9NxK1E9cdLBROJ/qLIr4 XuVAfaGqDYL701KDORXXxSfHeBcZ4HN0XM6A5OVsnCwyzwlEgW4qCxHSNkNbInYp9MOupuKeCmE +OjaMjPQeqUwaS8HK/YrbEoA= X-Received: by 127.0.0.2 with SMTP id hOqOYY7687511xFCVO8uyZpg; Tue, 27 Feb 2024 21:51:51 -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.web10.7180.1709099510631114446 for ; Tue, 27 Feb 2024 21:51:50 -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-122-qgmeI9o9PCKPdDNqRsVbtg-1; Wed, 28 Feb 2024 00:51:46 -0500 X-MC-Unique: qgmeI9o9PCKPdDNqRsVbtg-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 89279185A785; Wed, 28 Feb 2024 05:51:45 +0000 (UTC) X-Received: from [10.39.192.46] (unknown [10.39.192.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E33CE2166B33; Wed, 28 Feb 2024 05:51:43 +0000 (UTC) Message-ID: <5b1cec98-1548-028e-ea07-e41792956e31@redhat.com> Date: Wed, 28 Feb 2024 06:51:42 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 10/10] OvmfPkg/ResetVector: wire up 5-level paging for SEV To: devel@edk2.groups.io, kraxel@redhat.com Cc: Tom Lendacky , Jiewen Yao , Oliver Steffen , Erdem Aktas , Michael Roth , Ard Biesheuvel , Min Xu References: <20240222115435.85794-1-kraxel@redhat.com> <20240222115435.85794-11-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240222115435.85794-11-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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: rUoY10N7wUeBA0pchm3IoLZux7686176AA= 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=hv9jGWBB; 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 2/22/24 12:54, Gerd Hoffmann wrote: > Removes the GetSevCBitMaskAbove31 OneTimeCall because we need that twice > (for 4-level and 5-level paging). Open code the single instruction left > in that function instead. >=20 > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/ResetVector/Ia32/AmdSev.asm | 8 -------- > OvmfPkg/ResetVector/Ia32/PageTables64.asm | 14 +++++++++++++- > 2 files changed, 13 insertions(+), 9 deletions(-) >=20 > diff --git a/OvmfPkg/ResetVector/Ia32/AmdSev.asm b/OvmfPkg/ResetVector/Ia= 32/AmdSev.asm > index 9063ce1080d3..d1e5e8dfae71 100644 > --- a/OvmfPkg/ResetVector/Ia32/AmdSev.asm > +++ b/OvmfPkg/ResetVector/Ia32/AmdSev.asm > @@ -191,14 +191,6 @@ pageTableEntries4kLoop: > SevClearPageEncMaskForGhcbPageExit: > OneTimeCallRet SevClearPageEncMaskForGhcbPage > =20 > -; Get the C-bit mask above 31. > -; Modified: EDX > -; > -; The value is returned in the EDX > -GetSevCBitMaskAbove31: > - mov edx, dword[SEV_ES_WORK_AREA_ENC_MASK + 4] > - OneTimeCallRet GetSevCBitMaskAbove31 > - > %endif > =20 > ; Check if Secure Encrypted Virtualization (SEV) features are enabled. > diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVec= tor/Ia32/PageTables64.asm > index 6e2063430802..55664fa64f62 100644 > --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm > +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm > @@ -243,11 +243,23 @@ SevInit: > ; SEV workflow > ; > ClearOvmfPageTables > +%if PG_5_LEVEL > + Check5LevelPaging Sev4Level > ; If SEV is enabled, the C-bit position is always above 31. > ; The mask will be saved in the EDX and applied during the > ; the page table build below. > - OneTimeCall GetSevCBitMaskAbove31 > + mov edx, dword[SEV_ES_WORK_AREA_ENC_MASK + 4] > + CreatePageTables5Level edx > + Enable5LevelPaging > + jmp SevCommon > +Sev4Level: > +%endif > + ; If SEV is enabled, the C-bit position is always above 31. > + ; The mask will be saved in the EDX and applied during the > + ; the page table build below. > + mov edx, dword[SEV_ES_WORK_AREA_ENC_MASK + 4] > CreatePageTables4Level edx > +SevCommon: > ; Clear the C-bit from the GHCB page if the SEV-ES is enabled. > OneTimeCall SevClearPageEncMaskForGhcbPage > OneTimeCall SevClearVcHandlerAndStack This patch looks fine to me (especially the SevCommon label), but can you please reimplement GetSevCBitMaskAbove31 as a macro, rather than open-coding the mov edx, dword[SEV_ES_WORK_AREA_ENC_MASK + 4] instruction? Thanks! Laszlo -=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 (#116088): https://edk2.groups.io/g/devel/message/116088 Mute This Topic: https://groups.io/mt/104506802/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-