public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "Johnson, Brian" <brian.johnson@hpe.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"kraxel@redhat.com" <kraxel@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>,
	"Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"Dong, Eric" <eric.dong@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Zimmer, Vincent" <vincent.zimmer@intel.com>
Subject: Re: [edk2-devel] [PATCH v3 1/5] UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data
Date: Fri, 3 Feb 2023 03:14:42 +0000	[thread overview]
Message-ID: <MN6PR11MB8244656CDEF150355AF908928CD79@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <525d8100-b306-d1fb-08c4-e5e2cc6204e2@hpe.com>

Gerd,
Can you please explain a bit more on the chunk idea?

Brian,
Page allocation is not preferred in this SMM case because the pointer
in HOB entry points to another memory. StandaloneMmIpl has to
migrate the "another memory" manually to SMRAM. I want to avoid
that.

Thanks,
Ray

> -----Original Message-----
> From: Brian J. Johnson <brian.johnson@hpe.com>
> Sent: Friday, February 3, 2023 6:29 AM
> To: devel@edk2.groups.io; kraxel@redhat.com; Ni, Ray <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Dong,
> Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Zimmer, Vincent <vincent.zimmer@intel.com>
> Subject: Re: [edk2-devel] [PATCH v3 1/5] UefiCpuPkg/SmmBaseHob.h: Add SMM
> Base HOB Data
> 
> On 2/2/23 06:51, Gerd Hoffmann wrote:
> >    Hi,
> >
> >>> - With relatively many elements fitting into a single HOB, on most
> >>> platforms, just one HOB is going to be used. While that may be good for
> >>> performance, it is not good for code coverage (testing). The quirky
> >>> indexing method will not be exercised by most platforms.
> >>
> >> TRUE so I propose that the first version of the code change only expects
> >> the HOB.NumberOfCpus equals to the NumberOfCpus returned from MP
> >> service, meaning the code logic only supports single instance of the HOB.
> >> When a platform that contains >8000 cpu threads resulting in multiple HOBs
> >> produced, the expectation will break and remind us that the CpuSmm driver
> >> needs to update to handle multiple HOBs.
> >
> > Given that this is already the second case where we hit the 64k size
> > limit and I expect it will not be the last one:  I think it makes sense
> > to introduce a generic and reusable concept of chunked HOBs, so you can
> > add helper functions to HobLib for splitting and reassembling, with a
> > struct along the lines of:
> >
> > typedef struct {
> > 	// offset and size of this particular chunk
> > 	UINT32	ChunkOffset;
> > 	UINT32	ChunkSize;
> >
> > 	// number of chunks and size of all chunks combined.
> > 	UINT32	ChunkCount;
> > 	UINT32	TotalSize;
> >
> > 	// chunk data
> > 	UINT8   Data[0];
> > } EFI_HOB_CHUNK;
> >
> > take care,
> >    Gerd
> >
> 
> Gerd's suggestion could be handy.  Here's another approach when data is
> too large to fit in a HOB, which doesn't require splitting up the data:
> 
> PEI tracks page allocations by generating memory allocation HOBs
> (EFI_HOB_TYPE_MEMORY_ALLOCATION.)  The
> EFI_HOB_MEMORY_ALLOCATION_HEADER
> structure in the HOB contains a "Name" field of type EFI_GUID which can
> be used to track the purpose of that particular page allocation.  It's
> zeroed by BuildMemoryAllocationHob(), and not usually used.  But if you
> put your own GUID in there, you can use it to track which memory
> allocation HOB corresponds to your data, without having to manage a
> separate HOB with a pointer.  The allocation will be automatically
> tracked through pre-RAM PEI, post-RAM PEI, and DXE, and the pages
> (although not the HOB) will even persist into Runtime (if you use an
> EfiRuntimeServices memory type.)
> 
> That wouldn't help the OP with SMM, though.  They would still have to
> copy the pages into SMRAM somehow.
> 
> Unfortunately, neither HobLib nor AllocatePages() has an interface for
> setting the "Name" field.  But you can call AllocatePages(), then search
> the HOB list for the resulting HOB, and update it's AllocDescriptor.Name
> field.
> 
> --
> Brian J. Johnson
> Enterprise X86 Lab
> 
> Hewlett Packard Enterprise

  reply	other threads:[~2023-02-03  3:14 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18  9:56 [PATCH v3 0/5] Simplify SMM Relocation Process Wu, Jiaxin
2023-01-18  9:56 ` [PATCH v3 1/5] UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data Wu, Jiaxin
2023-01-18 11:19   ` Gerd Hoffmann
2023-01-18 15:06     ` Ni, Ray
2023-01-19  7:13       ` Gerd Hoffmann
2023-01-29  5:08         ` Wu, Jiaxin
2023-02-01 13:02           ` Gerd Hoffmann
2023-01-20  8:21       ` Laszlo Ersek
2023-01-29  5:24         ` Wu, Jiaxin
2023-02-01 13:14           ` Gerd Hoffmann
2023-02-02  0:44             ` Wu, Jiaxin
2023-02-02  3:54             ` [edk2-devel] " Ni, Ray
2023-02-02  3:52         ` Ni, Ray
2023-02-02 12:51           ` Gerd Hoffmann
2023-02-02 22:29             ` [edk2-devel] " Brian J. Johnson
2023-02-03  3:14               ` Ni, Ray [this message]
2023-02-03  7:54                 ` Gerd Hoffmann
2023-02-03 13:22                   ` Wu, Jiaxin
2023-02-03 13:31                     ` Ni, Ray
2023-02-03 15:00                     ` Gerd Hoffmann
2023-01-18  9:56 ` [PATCH v3 2/5] UefiCpuPkg/PiSmmCpuDxeSmm: Fix invalid InitializeMpSyncData call Wu, Jiaxin
2023-01-18  9:56 ` [PATCH v3 3/5] UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info Wu, Jiaxin
2023-01-18 12:02   ` Gerd Hoffmann
2023-01-29  6:14     ` [edk2-devel] " Wu, Jiaxin
2023-01-18  9:56 ` [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Skip SMBASE configuration Wu, Jiaxin
2023-01-18  9:56 ` [PATCH v3 5/5] OvmfPkg/SmmCpuFeaturesLib: " Wu, Jiaxin
2023-01-18 12:19   ` Gerd Hoffmann
2023-01-18 14:37     ` Ni, Ray
2023-01-19  7:53       ` Gerd Hoffmann
2023-01-29  5:47         ` Wu, Jiaxin
2023-02-01 13:40           ` Gerd Hoffmann
2023-02-02  1:41             ` Wu, Jiaxin
2023-02-02  9:00               ` Gerd Hoffmann
2023-02-02 11:47                 ` Laszlo Ersek
2023-02-02 12:24                   ` Gerd Hoffmann
2023-02-03  3:05                     ` Wu, Jiaxin
2023-02-03  2:47                   ` Wu, Jiaxin
2023-02-03  3:45                   ` Ni, Ray
2023-02-03  7:31                     ` Gerd Hoffmann
2023-02-03  7:43                       ` Ni, Ray
2023-02-03  8:49                         ` Gerd Hoffmann
2023-02-03 11:18                         ` Wu, Jiaxin
     [not found] ` <173B5EAF72B992BD.14781@groups.io>
2023-02-03  8:59   ` [edk2-devel] " Wu, Jiaxin
2023-02-03  9:04     ` Gerd Hoffmann
2023-02-03 11:15       ` 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=MN6PR11MB8244656CDEF150355AF908928CD79@MN6PR11MB8244.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