From: Mike Larkin Subject: Re: SEV-ES guest: Only claim early GHCB pages when we actuall are SEV-ES guest To: Alexander Bluhm Cc: tech@openbsd.org Date: Fri, 11 Jul 2025 09:30:25 -0700 On Thu, Jul 03, 2025 at 12:56:01PM +0200, Alexander Bluhm wrote: > On Wed, Jul 02, 2025 at 11:47:12AM -0700, Mike Larkin wrote: > > On Tue, Jul 01, 2025 at 10:37:57AM +0200, Hans-J?rg H?xer wrote: > > > Hi, > > > > > > as suggested by bluhm@, only claim GHCB pages when we are actually > > > running SEV-ES guest mode. > > > > > > > I think this is overoptimization but ok mlarkin if this is the way > > you want to head. > > When I was reading the code, I was wondering why first_avail is > incremented. For me it is clearer if we put it within the > if(SEV_STAT_ES_ENABLED). > > It is not about saving 8 KB. For me the intension is clearer. But > I don't insist on that if you have the opposit impression. > > bluhm > ok, no worries :) -ml > > > --- > > > commit d2444d09c945baad0e5d9283a50d466d7de7b400 > > > Author: Hans-Joerg Hoexer > > > Date: Mon Jun 30 15:29:35 2025 +0200 > > > > > > SEV-ES guest: Only claim early GHCB pages when we actuall are SEV-ES guest > > > > > > diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c > > > index 9b0badd610d..e0e8862d375 100644 > > > --- a/sys/arch/amd64/amd64/machdep.c > > > +++ b/sys/arch/amd64/amd64/machdep.c > > > @@ -1470,9 +1470,10 @@ init_x86_64(paddr_t first_avail) > > > /* > > > * locore0 mapped 2 pages for use as GHCB before pmap is initialized. > > > */ > > > - if (ISSET(cpu_sev_guestmode, SEV_STAT_ES_ENABLED)) > > > + if (ISSET(cpu_sev_guestmode, SEV_STAT_ES_ENABLED)) { > > > cpu_init_early_vctrap(first_avail); > > > - first_avail += 2 * NBPG; > > > + first_avail += 2 * NBPG; > > > + } > > > > > > /* > > > * locore0 mapped 3 pages for use before the pmap is initialized > > >