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 CAD95740041 for ; Thu, 22 Feb 2024 11:54:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=tZ4lqHaEtz9/h1fE5LQRCuxqkIgKABEgTzpgoEvI5bU=; 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=1708602887; v=1; b=KueTn5e4LvKmTwcyFOLFUHPTQholM9Q6ZXyW/0OUM6TFTEXkpPbpCFds2CyZFp989ngSl262 y+iy/FyV2pMEu5FO1AvcP51e4Ir+c5XyPLhrDNQMN2HMel+WaQU3K8Cj2OA5Q9vk2itaFwXewpg 9SjMN10eAeZoh5vuWm4SX2Ss= X-Received: by 127.0.0.2 with SMTP id jTy3YY7687511x0vYPrlETRb; Thu, 22 Feb 2024 03:54:47 -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.11058.1708602886803156188 for ; Thu, 22 Feb 2024 03:54:46 -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-674-pgnziN0YP0y2Vtoguvoa4w-1; Thu, 22 Feb 2024 06:54:42 -0500 X-MC-Unique: pgnziN0YP0y2Vtoguvoa4w-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 404BF38130A3; Thu, 22 Feb 2024 11:54:42 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.237]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45E60112132A; Thu, 22 Feb 2024 11:54:41 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 156221801A84; 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 05/10] OvmfPkg/ResetVector: split SEV and non-CoCo workflows Date: Thu, 22 Feb 2024 12:54:30 +0100 Message-ID: <20240222115435.85794-6-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.3 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: rt2ZYbZZ5mIFpKI5vDUoPvqfx7686176AA= 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=KueTn5e4; 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 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 --- OvmfPkg/ResetVector/Ia32/AmdSev.asm | 16 ++-------------- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/OvmfPkg/ResetVector/Ia32/AmdSev.asm b/OvmfPkg/ResetVector/Ia32/AmdSev.asm index 043c88a7abbe..ed94f1dc668f 100644 --- a/OvmfPkg/ResetVector/Ia32/AmdSev.asm +++ b/OvmfPkg/ResetVector/Ia32/AmdSev.asm @@ -152,12 +152,8 @@ SevEsUnexpectedRespTerminate: %ifdef ARCH_X64 -; If SEV-ES is enabled then initialize and make the GHCB page shared +; 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.43.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115807): https://edk2.groups.io/g/devel/message/115807 Mute This Topic: https://groups.io/mt/104506794/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-