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 C66CEAC0F7A for ; Tue, 30 Jan 2024 09:14:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wFVah1kXceK6b5R0qHkmOE4Tzu+DheKjdZXHxvDmBUI=; c=relaxed/simple; d=groups.io; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Disposition; s=20140610; t=1706606071; v=1; b=dkVJDJbqpxYgD25Yzhb04nJHAO0r67lTNz8EQUBWeV8xgTI6N+BO9L/aoVyKKO/HIHllX2LT EhHiiLWeGxiIzZAkDJuZOSNh8pEqBgd8hZsv5n7FVbUHrHd5adzC7/P38dNAaRe/t+uMjpTuN4k Ig1G7Rx4DevFtg/GvJp99JX4= X-Received: by 127.0.0.2 with SMTP id EqIkYY7687511x3ZPjKMBe0n; Tue, 30 Jan 2024 01:14:31 -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.14480.1706606070753565119 for ; Tue, 30 Jan 2024 01:14:30 -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-295-LIVBdfBqOxG-qrqOd4jjFA-1; Tue, 30 Jan 2024 04:14:24 -0500 X-MC-Unique: LIVBdfBqOxG-qrqOd4jjFA-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 B5D8E10651E6; Tue, 30 Jan 2024 09:14:23 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.180]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0BB68111F8; Tue, 30 Jan 2024 09:14:21 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EFF56180038B; Tue, 30 Jan 2024 10:14:19 +0100 (CET) Date: Tue, 30 Jan 2024 10:14:19 +0100 From: "Gerd Hoffmann" To: Laszlo Ersek Cc: devel@edk2.groups.io, Oliver Steffen , Ard Biesheuvel , Michael Roth , Min Xu , Tom Lendacky , Erdem Aktas , Jiewen Yao , Liming Gao Subject: Re: [edk2-devel] [PATCH 2/3] OvmfPkg/ResetVector: add 5-level paging support Message-ID: References: <20240129120201.344234-1-kraxel@redhat.com> <20240129120201.344234-3-kraxel@redhat.com> <3416850d-8977-5966-97a0-986e1e623e93@redhat.com> MIME-Version: 1.0 In-Reply-To: <3416850d-8977-5966-97a0-986e1e623e93@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: VAEAGukaQNyuF0pizjXlgT87x7686176AA= Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=dkVJDJbq; 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 Hi, > > + ; > > + ; use 5-level paging with gigabyte pages > > + ; > > + ; level 5 > > + mov dword[PT_ADDR (0)], PT_ADDR (0x1000) + PAGE_PDP_ATTR > > + mov dword[PT_ADDR (4)], edx > > + > > + ; level 4 > > + mov dword[PT_ADDR (0x1000)], PT_ADDR (0x2000) + PAGE_PDP_ATTR > > + mov dword[PT_ADDR (0x1004)], edx > > + > > + ; level 3 > > + mov dword[PT_ADDR (0x2000)], (0 << 30) + PAGE_2M_PDE_ATTR > > + mov dword[PT_ADDR (0x2004)], edx > > + mov dword[PT_ADDR (0x2008)], (1 << 30) + PAGE_2M_PDE_ATTR > > + mov dword[PT_ADDR (0x200c)], edx > > + mov dword[PT_ADDR (0x2010)], (2 << 30) + PAGE_2M_PDE_ATTR > > + mov dword[PT_ADDR (0x2014)], edx > > + mov dword[PT_ADDR (0x2018)], (3 << 30) + PAGE_2M_PDE_ATTR > > + mov dword[PT_ADDR (0x201c)], edx > > (2) So this is my problem. I've found this hard to decipher. The > original (4-level) counterpart is much better commented. > > So you either consulted the documentation to invent this (but then > didn't write up your thought process), or you just "winged it" (which > may still be fine, but you need to explain the setup even more). > > As far as I can tell, we're covering the first 4GB of address space with > 4 pages of 1GB size each, and because of that, we need not go deeper > than level 3. Correct. > That one sentence in a comment (which would have cost you 5 seconds) Well, there is a comment saying it's 5-level paging with gigabyte pages (quoted above). I'll add more details. > (3) While the macro PAGE_2M_PDE_ATTR might expand to just the right > constant here, the "2M" in the name is extremely confusing. Please > introduce a new macro for selecting 1GB pages. I think rename "2M" to "LARGEPAGE" would be better here. The page directory bit essentially says "stop page table walk here, there are no page tables/page directories below this". When set in a 4-level page directory you'll get a 2M page, when set in a 3-level page directory you'll get a 1G page. > > + ; done > > + jmp SetCr3 > > (4) Functionality question: is the 5-level branch compatible with SEV > and/or TDX? Asking because: > > - EDX is still from GetSevCBitMaskAbove31. I don't know what happens if > SEV is enabled and such an EDX is used at level 5. Not fully sure. The 4-level paging code applies edx on all levels, so I did the same for 5-level paging. Tom? > - jumping to the SetCr3 label from here omits the > "SevClearPageEncMaskForGhcbPage" and "TdxPostBuildPageTables" pieces of > logic. Good catch. That is a bug. take care, Gerd -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114767): https://edk2.groups.io/g/devel/message/114767 Mute This Topic: https://groups.io/mt/104029639/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-