DTB: ensure the `dtb_ptr` is an HHDM address

* Ensure that the `dtb_ptr` is an HHDM address
* If DTB is not found, do not generate the response

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
This commit is contained in:
Andy-Python-Programmer 2022-09-12 16:51:00 +10:00
parent 4fb558fe81
commit 528be7230f
No known key found for this signature in database
GPG Key ID: 80E0357347554B89
2 changed files with 9 additions and 6 deletions

View File

@ -1079,5 +1079,7 @@ struct limine_dtb_response {
* `dtb_ptr` - Virtual pointer to the device tree blob.
Note: If the DTB cannot be found, the response will *not* be generated.
Note: Information contained in the `/chosen` node may not reflect the information
given by bootloader tags, and as such the `/chosen` node properties should be ignored.

View File

@ -540,9 +540,6 @@ FEAT_START
}
#if defined (UEFI)
struct limine_dtb_response *dtb_response =
ext_mem_alloc(sizeof(struct limine_dtb_response));
// TODO: Looking for the DTB should be moved out of here and into lib/, because:
// 1. We will need it for core bring-up for the SMP request.
// 2. We will need to patch it for the Linux boot protocol to set the initramfs
@ -555,11 +552,15 @@ FEAT_START
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
EFI_CONFIGURATION_TABLE *cur_table = &gST->ConfigurationTable[i];
if (memcmp(&cur_table->VendorGuid, &dtb_guid, sizeof(EFI_GUID)) == 0)
dtb_response->dtb_ptr = (uint64_t)(uintptr_t)cur_table->VendorTable;
if (memcmp(&cur_table->VendorGuid, &dtb_guid, sizeof(EFI_GUID)) == 0) {
struct limine_dtb_response *dtb_response =
ext_mem_alloc(sizeof(struct limine_dtb_response));
dtb_response->dtb_ptr = reported_addr((void *)cur_table->VendorTable);
dtb_request->response = reported_addr(dtb_response);
break;
}
}
dtb_request->response = reported_addr(dtb_response);
#endif
FEAT_END