Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168223785
D14677.id40253.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.id40253.diff
View Options
Index: head/stand/efi/loader/bootinfo.c
===================================================================
--- head/stand/efi/loader/bootinfo.c
+++ head/stand/efi/loader/bootinfo.c
@@ -236,17 +236,48 @@
return(addr);
}
+static EFI_STATUS
+efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver)
+{
+ EFI_MEMORY_DESCRIPTOR *desc, *viter, *vmap;
+ EFI_STATUS ret;
+ int curr, ndesc, nset;
+
+ nset = 0;
+ desc = mm;
+ ndesc = sz / mmsz;
+ 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 = NextMemoryDescriptor(desc, mmsz)) {
+ if ((desc->Attribute & EFI_MEMORY_RUNTIME) != 0) {
+ ++nset;
+ desc->VirtualStart = desc->PhysicalStart;
+ *viter = *desc;
+ viter = NextMemoryDescriptor(viter, mmsz);
+ }
+ }
+ ret = RS->SetVirtualAddressMap(nset * mmsz, mmsz, mmver, vmap);
+ free(vmap);
+ return (ret);
+}
+
static int
bi_load_efi_data(struct preloaded_file *kfp)
{
EFI_MEMORY_DESCRIPTOR *mm;
EFI_PHYSICAL_ADDRESS addr;
EFI_STATUS status;
+ const char *efi_novmap;
size_t efisz;
UINTN efi_mapkey;
UINTN mmsz, pages, retry, sz;
UINT32 mmver;
struct efi_map_header *efihdr;
+ bool do_vmap;
#if defined(__amd64__) || defined(__aarch64__)
struct efi_fb efifb;
@@ -266,6 +297,11 @@
}
#endif
+ do_vmap = true;
+ efi_novmap = getenv("efi_disable_vmap");
+ if (efi_novmap != NULL)
+ do_vmap = strcasecmp(efi_novmap, "YES") != 0;
+
efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
/*
@@ -321,6 +357,13 @@
}
status = BS->ExitBootServices(IH, efi_mapkey);
if (EFI_ERROR(status) == 0) {
+ /*
+ * This may be disabled by setting efi_disable_vmap in
+ * loader.conf(5). By default we will setup the virtual
+ * map entries.
+ */
+ if (do_vmap)
+ efi_do_vmap(mm, sz, mmsz, mmver);
efihdr->memory_size = sz;
efihdr->descriptor_size = mmsz;
efihdr->descriptor_version = mmver;
Index: head/sys/amd64/amd64/efirt_machdep.c
===================================================================
--- head/sys/amd64/amd64/efirt_machdep.c
+++ head/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: head/sys/arm64/arm64/efirt_machdep.c
===================================================================
--- head/sys/arm64/arm64/efirt_machdep.c
+++ head/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
Fri, Aug 28, 12:42 AM (6 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37425674
Default Alt Text
D14677.id40253.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