On Thu, Feb 22, 2024 at 11:29:46AM -0600, Tom Lendacky wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4654
> 
> The SNP_PAGE_STATE_MAX_ENTRY is based on the number of entries that can
> fit in the GHCB shared buffer. As a result, the SNP_PAGE_STATE_CHANGE_INFO
> structure maps the full GHCB shared buffer based on the shared buffer size
> being 2032 bytes.
> 
> Instead of using a hardcoded value for SNP_PAGE_STATE_MAX_ENTRY, use a
> build calculated value. Since the SNP_PAGE_STATE_CHANGE_INFO is used as a
> mapping, eliminate the hardcoded array size so that the structure can be
> used based on any size buffer.
> 
> Signed-off-by: Tom Lendacky <thomas.lenda...@amd.com>
> ---
>  MdePkg/Include/Register/Amd/Ghcb.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/MdePkg/Include/Register/Amd/Ghcb.h 
> b/MdePkg/Include/Register/Amd/Ghcb.h
> index 432d67e3e223..0cdc00627472 100644
> --- a/MdePkg/Include/Register/Amd/Ghcb.h
> +++ b/MdePkg/Include/Register/Amd/Ghcb.h
> @@ -197,13 +197,14 @@ typedef struct {
>    UINT32    Reserved;
>  } SNP_PAGE_STATE_HEADER;
>  
> -#define SNP_PAGE_STATE_MAX_ENTRY  253
> -
>  typedef struct {
>    SNP_PAGE_STATE_HEADER    Header;
> -  SNP_PAGE_STATE_ENTRY     Entry[SNP_PAGE_STATE_MAX_ENTRY];
> +  SNP_PAGE_STATE_ENTRY     Entry[];
>  } SNP_PAGE_STATE_CHANGE_INFO;

Good.

> +#define SNP_PAGE_STATE_MAX_ENTRY  \
> +  ((sizeof (((GHCB *)0)->SharedBuffer) - sizeof (SNP_PAGE_STATE_HEADER)) / 
> sizeof (SNP_PAGE_STATE_ENTRY))

Can be dropped I think, after applying patch #6 BaseMemEncryptSevLib
does not use SNP_PAGE_STATE_MAX_ENTRY any more.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116021): https://edk2.groups.io/g/devel/message/116021
Mute This Topic: https://groups.io/mt/104512946/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to