Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153114927
D14677.id40242.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D14677.id40242.diff
View Options
Index: stand/efi/loader/bootinfo.c
===================================================================
--- stand/efi/loader/bootinfo.c
+++ stand/efi/loader/bootinfo.c
@@ -236,6 +236,42 @@
return(addr);
}
+static EFI_STATUS
+efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver)
+{
+ EFI_MEMORY_DESCRIPTOR *desc;
+ EFI_MEMORY_DESCRIPTOR *viter, *vmap;
+ int curr, ndesc, nset;
+
+ nset = 0;
+ desc = mm;
+ ndesc = sz / mmsz;
+#define NEXT_DESC(ptr, sz) \
+ ((EFI_MEMORY_DESCRIPTOR *)(((uint8_t *)(ptr)) + sz))
+ vmap = malloc(sz);
+ if (vmap == NULL)
+ /* This isn't really an EFI error case, but pretend it is */
+ return (EFI_OUT_OF_RESOURCES);
+ viter = vmap;
+ for (curr = 0; curr < ndesc; curr++, desc = NEXT_DESC(desc, mmsz)) {
+ if (desc->Attribute & EFI_MEMORY_RUNTIME) {
+ ++nset;
+ viter->PhysicalStart = desc->PhysicalStart;
+ /* Now set VA=PA, advance */
+ viter->VirtualStart = viter->PhysicalStart;
+ viter = NEXT_DESC(viter, mmsz);
+ /*
+ * Finally, set VA = PA in original memory map to
+ * reflect our change. This memory map will be passed
+ * to the kernel.
+ */
+ desc->VirtualStart = desc->PhysicalStart;
+ }
+ }
+#undef NEXT_DESC
+ return (RS->SetVirtualAddressMap(nset * mmsz, mmsz, mmver, vmap));
+}
+
static int
bi_load_efi_data(struct preloaded_file *kfp)
{
@@ -321,6 +357,7 @@
}
status = BS->ExitBootServices(IH, efi_mapkey);
if (EFI_ERROR(status) == 0) {
+ efi_do_vmap(mm, sz, mmsz, mmver);
efihdr->memory_size = sz;
efihdr->descriptor_size = mmsz;
efihdr->descriptor_version = mmver;
Index: sys/amd64/amd64/efirt_machdep.c
===================================================================
--- sys/amd64/amd64/efirt_machdep.c
+++ sys/amd64/amd64/efirt_machdep.c
@@ -165,7 +165,7 @@
descsz)) {
if ((p->md_attr & EFI_MD_ATTR_RT) == 0)
continue;
- if (p->md_virt != NULL) {
+ if (p->md_virt != NULL && (uint64_t)p->md_virt != p->md_phys) {
if (bootverbose)
printf("EFI Runtime entry %d is mapped\n", i);
goto fail;
Index: sys/arm64/arm64/efirt_machdep.c
===================================================================
--- sys/arm64/arm64/efirt_machdep.c
+++ sys/arm64/arm64/efirt_machdep.c
@@ -169,7 +169,7 @@
descsz)) {
if ((p->md_attr & EFI_MD_ATTR_RT) == 0)
continue;
- if (p->md_virt != NULL) {
+ if (p->md_virt != NULL && (uint64_t)p->md_virt != p->md_phys) {
if (bootverbose)
printf("EFI Runtime entry %d is mapped\n", i);
goto fail;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 6:31 AM (17 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31823495
Default Alt Text
D14677.id40242.diff (2 KB)
Attached To
Mode
D14677: EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services
Attached
Detach File
Event Timeline
Log In to Comment