MdePkg: Avoid hardcoded value for number of Page State Change entries
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. Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
		
				
					committed by
					
						
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							5fe9db0f82
						
					
				
				
					commit
					f40c1f2a30
				
			@@ -197,13 +197,14 @@ typedef struct {
 | 
				
			|||||||
  UINT32    Reserved;
 | 
					  UINT32    Reserved;
 | 
				
			||||||
} SNP_PAGE_STATE_HEADER;
 | 
					} SNP_PAGE_STATE_HEADER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SNP_PAGE_STATE_MAX_ENTRY  253
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  SNP_PAGE_STATE_HEADER    Header;
 | 
					  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;
 | 
					} SNP_PAGE_STATE_CHANGE_INFO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define SNP_PAGE_STATE_MAX_ENTRY  \
 | 
				
			||||||
 | 
					  ((sizeof (((GHCB *)0)->SharedBuffer) - sizeof (SNP_PAGE_STATE_HEADER)) / sizeof (SNP_PAGE_STATE_ENTRY))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Get APIC IDs
 | 
					// Get APIC IDs
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user