public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	"Ni, Ray" <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH v3 08/13] OvmfPkg/PlatformInitLib: Create gEfiSmmSmramMemoryGuid
Date: Tue, 23 Apr 2024 15:59:04 +0000	[thread overview]
Message-ID: <MN0PR11MB61588DD1979B564B8CE187E8FE112@MN0PR11MB6158.namprd11.prod.outlook.com> (raw)
In-Reply-To: sh4cfpocpd7ihqnkv5vhzub3o67meyf255ngo7nxo4no7vein3@pemivw2eg4tk

Hi Gerd,

There was the issue in my patch to change the smm access driver: SmmAccessPeiOpen(), I removed below code due to the comment in original code that indicate the DescriptorIndex is not considered at all:

  ...
  if (DescriptorIndex >= DescIdxCount) {
    return EFI_INVALID_PARAMETER;
  }
  //
  // According to current practice, *DescriptorIndex is not considered at all*,
  // beyond validating it.
  //
  ...

But it's important for smmlockboxpeilib to check the return status of SmmAccessPeiOpen (EFI_INVALID_PARAMETER) to continue the RestoreLockBox():
    for (Index = 0; !EFI_ERROR (Status); Index++) {
      Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index);
    }

So, it hangs at for() loop once I removed above code in the SmmAccessPeiOpen!!!

After that fix, I still found S3 doesn't work, I checked the master code without my patch. It also can't work for S3, which means S3 broken on latest master code. You can also double confirm the log that stop as below:

...
S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE
S3BootScriptDone - Success
Call AsmDisablePaging64() to return to S3 Resume in PEI Phase
Install PPI: 88C9D306-0900-4EB5-8260-3E2DBEDA1F89
Install PPI: 605EA650-C65C-42E1-BA80-91A52AB618C6
Notify: PPI Guid: 605EA650-C65C-42E1-BA80-91A52AB618C6, Peim notify entry point: 82B5B0
Signal EndOfS3Resume
Signal 96F5296D-05F7-4F3C-8467-E456890E0CB5 to SMM - Enter
Locate Smm Communicate Ppi failed (Not Found)!
Transfer to 16bit OS waking vector - 991F0 ----> hang here!!!

Thanks,
Jiaxin 

> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Tuesday, April 23, 2024 9:20 PM
> To: Gerd Hoffmann <kraxel@redhat.com>
> Cc: devel@edk2.groups.io; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao,
> Jiewen <jiewen.yao@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: RE: [PATCH v3 08/13] OvmfPkg/PlatformInitLib: Create
> gEfiSmmSmramMemoryGuid
> 
> More info:
> I quick dump the SMRAM info with original SmmAccess implementation, it's
> same as I produced in the gEfiSmmSmramMemoryGuid HOB.
> 
> SmmAccess:
> SmmAccessPeiEntryPoint: SMRAM map follows, 2 entries
> SmmAccessPeiEntryPoint:             7F000000                 1000             7F000000
> 1A    ---> for the S3 Resume in gEfiAcpiVariableGuid
> SmmAccessPeiEntryPoint:             7F001000               FFF000             7F001000
> A
> 
> Smram map in the gEfiSmmSmramMemoryGuid:
> PlatformQemuInitializeRam:             7F000000                 1000             7F000000
> 1A    --> ---> for the S3 Resume in gEfiAcpiVariableGuid
> PlatformQemuInitializeRam:             7F001000               FFF000             7F001000
> A
> 
> 
> Thanks,
> Jiaxin
> 
> > -----Original Message-----
> > From: Wu, Jiaxin
> > Sent: Tuesday, April 23, 2024 8:19 PM
> > To: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: devel@edk2.groups.io; Ard Biesheuvel <ardb+tianocore@kernel.org>;
> Yao,
> > Jiewen <jiewen.yao@intel.com>; Ni, Ray <ray.ni@intel.com>
> > Subject: RE: [PATCH v3 08/13] OvmfPkg/PlatformInitLib: Create
> > gEfiSmmSmramMemoryGuid
> >
> > >
> > > > +    SmramHobDescriptorBlock                             =
> > > (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)(Hob.Raw);
> > >
> > > > +    SmramHobDescriptorBlock->Descriptor[0].PhysicalStart =
> > > PlatformInfoHob->LowMemory - TsegSize;
> > > > +    SmramHobDescriptorBlock->Descriptor[0].CpuStart      =
> > > PlatformInfoHob->LowMemory - TsegSize;
> > > > +    SmramHobDescriptorBlock->Descriptor[0].PhysicalSize  =
> > EFI_PAGE_SIZE;
> > > > +    SmramHobDescriptorBlock->Descriptor[0].RegionState   =
> > > EFI_SMRAM_CLOSED | EFI_CACHEABLE | EFI_ALLOCATED;
> > >
> > > > +    SmramHobDescriptorBlock->Descriptor[1].PhysicalStart =
> > > SmramHobDescriptorBlock->Descriptor[0].PhysicalStart + EFI_PAGE_SIZE;
> > > > +    SmramHobDescriptorBlock->Descriptor[1].CpuStart      =
> > > SmramHobDescriptorBlock->Descriptor[0].CpuStart + EFI_PAGE_SIZE;
> > > > +    SmramHobDescriptorBlock->Descriptor[1].PhysicalSize  = TsegSize -
> > > EFI_PAGE_SIZE;
> > > > +    SmramHobDescriptorBlock->Descriptor[1].RegionState   =
> > > EFI_SMRAM_CLOSED | EFI_CACHEABLE;
> > >
> > > This is not going to fly.
> > >
> > > First, smram allocation doesn't work that way.  Have a look at
> > > OvmfPkg/SmmAccess.  I guess that easily explains why this series
> > > breaks S3 suspend.
> > >
> >
> > Oh? Could you explain a bit more for 1) how smram allocation works? 2)
> > what's the possible reason break the S3? I haven't check yet.
> >
> > > Second, storing these descriptors in a HOB (which is PEI memory)
> > > is questionable from a security point of view.
> > >
> >
> > HOB is only to expose the SMRAM address and size, not the contents in
> > smram, what's the security concern?
> >
> >
> > Thanks,
> > Jiaxin


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118174): https://edk2.groups.io/g/devel/message/118174
Mute This Topic: https://groups.io/mt/105593577/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-04-23 15:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18  6:55 [edk2-devel] [PATCH v3 00/13] Add SmmRelocationLib Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 01/13] UefiCpuPkg: Add SmmRelocationLib class Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 02/13] UefiCpuPkg/SmmRelocationLib: Add SmmRelocationLib library instance Wu, Jiaxin
2024-04-18  7:32   ` Ni, Ray
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 03/13] UefiCpuPkg/SmmRelocationLib: Rename global variables Wu, Jiaxin
2024-04-18  7:33   ` Ni, Ray
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 04/13] UefiCpuPkg/SmmRelocationLib: Avoid unnecessary memory allocation Wu, Jiaxin
2024-04-18  7:40   ` Ni, Ray
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 05/13] UefiCpuPkg/SmmRelocationLib: Remove unnecessary global variable Wu, Jiaxin
2024-04-18  7:48   ` Ni, Ray
2024-04-18  7:57     ` Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 06/13] UefiCpuPkg/SmmRelocationLib: Add library instance for AMD Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 07/13] OvmfPkg/SmmRelocationLib: Add library instance for OVMF Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 08/13] OvmfPkg/PlatformInitLib: Create gEfiSmmSmramMemoryGuid Wu, Jiaxin
2024-04-23  9:25   ` Gerd Hoffmann
2024-04-23 12:18     ` Wu, Jiaxin
2024-04-24 12:35       ` Gerd Hoffmann
2024-04-25  1:54         ` Wu, Jiaxin
2024-04-25  7:20           ` Gerd Hoffmann
2024-04-25  7:41             ` Wu, Jiaxin
2024-04-23 13:20     ` Wu, Jiaxin
2024-04-23 15:59     ` Wu, Jiaxin [this message]
2024-04-24 12:38       ` Gerd Hoffmann
2024-04-25  0:54         ` Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 09/13] OvmfPkg: Refine SmmAccess implementation Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 10/13] OvmfPkg/SmmCpuFeaturesLib: Check Smbase Relocation is done or not Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 11/13] OvmfPkg/PlatformPei: Relocate SmBases in PEI phase Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 12/13] UefiPayloadPkg/UefiPayloadPkg.dsc: Include SmmRelocationLib Wu, Jiaxin
2024-04-18  6:55 ` [edk2-devel] [PATCH v3 13/13] UefiCpuPkg/PiSmmCpuDxeSmm: Remove SmBases relocation logic Wu, Jiaxin
2024-04-18  8:15   ` Ni, Ray
2024-04-19  2:06     ` Wu, Jiaxin

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=MN0PR11MB61588DD1979B564B8CE187E8FE112@MN0PR11MB6158.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