public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Min Xu" <min.m.xu@intel.com>
To: "kraxel@redhat.com" <kraxel@redhat.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	"Justen, Jordan L" <jordan.l.justen@intel.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Erdem Aktas <erdemaktas@google.com>,
	James Bottomley <jejb@linux.ibm.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [edk2-devel] [PATCH V5 2/2] OvmfPkg/ResetVector: Enable Intel TDX in ResetVector of Ovmf
Date: Thu, 9 Sep 2021 13:54:26 +0000	[thread overview]
Message-ID: <PH0PR11MB5064BE0D4516AF86D8E211FAC5D59@PH0PR11MB5064.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210903053919.ybkq7imveuxbufao@sirius.home.kraxel.org>

On September 3, 2021 1:39 PM, Gerd Hoffmann wrote:
> On Fri, Sep 03, 2021 at 03:03:50AM +0000, Yao, Jiewen wrote:
> > HI Min/Gerd
> > I think we have multiple ways to enable 5 level paging.
> >
> > 1) We do not change to 5 level in initial paging in reset vector.
> > We can switch from 4 level to 5 level later when permanent memory is
> available.
> > We don't need change flash layout.
> 
> Does that work with tdx?
> 
> I had the impression that ovmf can't choose whenever it uses 4-level or 5-level
> paging in case tdx is enabled, but instead has to use what the tdx firmware (or
> hardware?) dictates.  And this being the reason why we have to deal with that
> in the reset vector in the first place.
> 
> But maybe I'm wrong here.
> 
> If we can use 4-level paging initially, then we surely should go for option (1)
> and simply not touch the reset vectors paging code.
After PoC I find this option is not a good one. Though the reset vectors is not touched, there are tricky changes in DxeIpl. To set up 5-level paging in an 4-level paging, it should first be switched from 64-bit long mode to 32 protected mode, then turn off the Paging, disable IA32_ERER.LME, then set the Cr4. The tricky thing is that in TDX IA32_EFER is not changeable. MdeModulePkg/.../DxeIpl is widely used and  it is high risk to make such changes.
> 
> > 2) We can enable 5 level paging in initial paging.
> > 2.1) We can enable 5 level paging with 1G paging support.
> > We don't need change flash layout. Only 3 pages is needed. (12K) I
> > don't know if we can real case that a CPU support 5 level but without 1G
> paging.
According to Intel SDM Volume 3 Section 4.1.1.
Quote "6. Processors that support 4-level paging or 5-level paging do not necessarily support 1-GByte page; see Section 4.1.4"
So option 2.1 is not feasible.
> >
> > 2.2) We can still enable 5 level paging with 2M paging.
> > 2.2.1) We can change flash layout to increase 6 pages (24K) memory to 7
> pages (28K).
> > So the CR3 in 5 level is same as the CR3 in 4 level.
> >
> > 2.2.2) We don't change flash layout but steal another page in
> > somewhere else - PcdOvmfPml5Base That means CR3 in 5 level is different
> with CR4 in 4 level.
> > Personally, I don't like the idea to create PcdOvmfPml5Base/Size Other
> > AP MUST check 5 level and 4 level to get right CR3 location. That is tricky and
> unnecessary.
> >
> > In current patch, 2.2.2) is used.
> >
> > I suggest we also evaluate option 1), 2.1) and 2.2.1).
> 
> My idea is 2.2.1 with a fixed, 5-level layout.
> Then use 4-level-cr3 == 5-level-cr3 + PAGE_SIZE
Agree. 5-level-cr3 = PT_ADDR (0), 4-level-cr3 = PT_ADDR (0x1000)
2.2.1 is preferred.
> 
> 2.1 looks good too.
As I explained above, 2.1 is not feasible.
> 

I will use 2.2.1 to implement 5-level paging in OvmfPkgX64.

Thanks!
Min

  reply	other threads:[~2021-09-09 13:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  2:35 [PATCH V5 0/2] Add Intel TDX support in OvmfPkg/ResetVector Min Xu
2021-08-30  2:35 ` [PATCH V5 1/2] OvmfPkg: Introduce Tdx BFV/CFV PCDs and PcdOvmfImageSizeInKb Min Xu
2021-08-30  7:03   ` Gerd Hoffmann
2021-08-31  3:29     ` [edk2-devel] " Min Xu
2021-08-31  5:13       ` Gerd Hoffmann
2021-08-31  6:17         ` Min Xu
2021-08-31 10:21           ` Gerd Hoffmann
2021-09-01  5:18             ` Min Xu
2021-09-01  6:10               ` Gerd Hoffmann
2021-09-01  6:57                 ` Ard Biesheuvel
2021-09-01  7:19                   ` Min Xu
2021-09-01  7:44                     ` Gerd Hoffmann
2021-09-01  8:59                     ` Yao, Jiewen
2021-09-01 16:53                       ` James Bottomley
2021-09-01 19:19                         ` Andrew Fish
2021-09-10 17:03                           ` Erdem Aktas
2021-08-30  2:35 ` [PATCH V5 2/2] OvmfPkg/ResetVector: Enable Intel TDX in ResetVector of Ovmf Min Xu
2021-08-30  7:40   ` Gerd Hoffmann
2021-08-31  3:09     ` [edk2-devel] " Min Xu
2021-08-31  5:35       ` Gerd Hoffmann
2021-09-02  0:05         ` Min Xu
2021-09-02  7:18           ` Gerd Hoffmann
2021-09-02  7:49             ` Min Xu
2021-09-03  3:03               ` Yao, Jiewen
2021-09-03  5:39                 ` Gerd Hoffmann
2021-09-09 13:54                   ` Min Xu [this message]
2021-09-10  8:19                     ` Gerd Hoffmann
2021-09-14  3:54                       ` Yao, Jiewen
2021-09-11  1:17   ` Erdem Aktas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR11MB5064BE0D4516AF86D8E211FAC5D59@PH0PR11MB5064.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox