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 BFF0ED811C3 for ; Fri, 1 Mar 2024 07:44:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=D6xEe57L4mtWFD3eQ6bMln4G0/n54371WGi5i2sFlZ0=; 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=1709279053; v=1; b=fWgSdH3BqVq31bR1wCmCVpUKA5rQsUx+cuxYS2l0GULduhEUGJVQakEbhtyITrBxIey0Lb3Q 8vyzwePBHiWSqFeSLD+kFtonkYUwCLRb88U2Ov7PcNakAL1rpYo1bh1283SvtXKLh0C8CleVbmF MbP9bt2AFI6egtQqApdKw5tI= X-Received: by 127.0.0.2 with SMTP id GhylYY7687511xoGl8ExL3Bg; Thu, 29 Feb 2024 23:44:13 -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.17683.1709279052491471257 for ; Thu, 29 Feb 2024 23:44:12 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-533-yAwZH9HUMZK9VhMFpTErag-1; Fri, 01 Mar 2024 02:44:08 -0500 X-MC-Unique: yAwZH9HUMZK9VhMFpTErag-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 C68713806282; Fri, 1 Mar 2024 07:44:07 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A845492B79; Fri, 1 Mar 2024 07:44:07 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E967C1801494; 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 05/10] OvmfPkg/ResetVector: split SEV and non-CoCo workflows Date: Fri, 1 Mar 2024 08:43:57 +0100 Message-ID: <20240301074402.98625-6-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.10 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: l2Y2HFFHBwRwOE3PIvuRhdOdx7686176AA= 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=fWgSdH3B; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) Use separate control flows for SEV and non-CoCo cases. SevClearPageEncMaskForGhcbPage and GetSevCBitMaskAbove31 will now only be called when running in SEV mode, so the SEV check in these functions is not needed any more. No functional change. Signed-off-by: Gerd Hoffmann Reviewed-by: Laszlo Ersek --- OvmfPkg/ResetVector/Ia32/AmdSev.asm | 14 +------------- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/OvmfPkg/ResetVector/Ia32/AmdSev.asm b/OvmfPkg/ResetVector/Ia32/AmdSev.asm index 043c88a7abbe..23e4c5ebbe92 100644 --- a/OvmfPkg/ResetVector/Ia32/AmdSev.asm +++ b/OvmfPkg/ResetVector/Ia32/AmdSev.asm @@ -154,10 +154,6 @@ SevEsUnexpectedRespTerminate: ; If SEV-ES is enabled then initialize and make the GHCB page shared SevClearPageEncMaskForGhcbPage: - ; Check if SEV is enabled - cmp byte[WORK_AREA_GUEST_TYPE], 1 - jnz SevClearPageEncMaskForGhcbPageExit - ; Check if SEV-ES is enabled mov ecx, 1 bt [SEV_ES_WORK_AREA_STATUS_MSR], ecx @@ -195,20 +191,12 @@ pageTableEntries4kLoop: SevClearPageEncMaskForGhcbPageExit: OneTimeCallRet SevClearPageEncMaskForGhcbPage -; Check if SEV is enabled, and get the C-bit mask above 31. +; Get the C-bit mask above 31. ; Modified: EDX ; ; The value is returned in the EDX GetSevCBitMaskAbove31: - xor edx, edx - - ; Check if SEV is enabled - cmp byte[WORK_AREA_GUEST_TYPE], 1 - jnz GetSevCBitMaskAbove31Exit - mov edx, dword[SEV_ES_WORK_AREA_ENC_MASK + 4] - -GetSevCBitMaskAbove31Exit: OneTimeCallRet GetSevCBitMaskAbove31 %endif diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm index 166e80293c89..84a7b4efc019 100644 --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm @@ -118,15 +118,26 @@ SetCr3ForPageTables64: ; Check whether the SEV is active and populate the SevEsWorkArea OneTimeCall CheckSevFeatures + cmp byte[WORK_AREA_GUEST_TYPE], 1 + jz SevInit + ; + ; normal (non-CoCo) workflow + ; + ClearOvmfPageTables + CreatePageTables4Level 0 + jmp SetCr3 + +SevInit: + ; + ; SEV workflow + ; + ClearOvmfPageTables ; 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 - - ClearOvmfPageTables CreatePageTables4Level edx - ; Clear the C-bit from the GHCB page if the SEV-ES is enabled. OneTimeCall SevClearPageEncMaskForGhcbPage jmp SetCr3 -- 2.44.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116218): https://edk2.groups.io/g/devel/message/116218 Mute This Topic: https://groups.io/mt/104660112/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-