mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	UefiCpuPkg/CpuDxe: fix page table walk in confidential VM
`PageStartAddress` variable was not set correctly because the encryption bit was not considered, which broke the page walk logic. Get the bitmask and mask the encryption bit. Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
This commit is contained in:
		 Luigi Leonardi
					Luigi Leonardi
				
			
				
					committed by
					
						 Ard Biesheuvel
						Ard Biesheuvel
					
				
			
			
				
	
			
			
			 Ard Biesheuvel
						Ard Biesheuvel
					
				
			
						parent
						
							44214c0cdf
						
					
				
				
					commit
					f64b4065b7
				
			| @ -975,6 +975,7 @@ RefreshGcdMemoryAttributesFromPaging ( | ||||
|   UINT64                           Capabilities; | ||||
|   UINT64                           NewAttributes; | ||||
|   UINTN                            Index; | ||||
|   UINT64                           AddressEncMask; | ||||
|  | ||||
|   // | ||||
|   // Assuming that memory space map returned is sorted already; otherwise sort | ||||
| @ -1055,10 +1056,18 @@ RefreshGcdMemoryAttributesFromPaging ( | ||||
|           break; | ||||
|         } | ||||
|  | ||||
|         // | ||||
|         // Get the mask for the memory encryption bit for Tdx and Sev | ||||
|         // | ||||
|         AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask); | ||||
|         if (AddressEncMask == 0) { | ||||
|           AddressEncMask = PcdGet64 (PcdTdxSharedBitMask); | ||||
|         } | ||||
|  | ||||
|         // | ||||
|         // Note current memory space might start in the middle of a page | ||||
|         // | ||||
|         PageStartAddress = (*PageEntry) & (UINT64)PageAttributeToMask (PageAttribute); | ||||
|         PageStartAddress = (*PageEntry) & (UINT64)PageAttributeToMask (PageAttribute) & ~AddressEncMask; | ||||
|         PageLength       = PageAttributeToLength (PageAttribute) - (BaseAddress - PageStartAddress); | ||||
|         Attributes       = GetAttributesFromPageEntry (PageEntry); | ||||
|       } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user