Page MenuHomeFreeBSD

D14677.id40245.diff
No OneTemporary

D14677.id40245.diff

Index: stand/efi/loader/bootinfo.c
===================================================================
--- stand/efi/loader/bootinfo.c
+++ stand/efi/loader/bootinfo.c
@@ -236,17 +236,45 @@
return(addr);
}
+static EFI_STATUS
+efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver)
+{
+ EFI_MEMORY_DESCRIPTOR *desc, *viter, *vmap;
+ 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);
+ }
+ }
+ return (RS->SetVirtualAddressMap(nset * mmsz, mmsz, mmver, vmap));
+}
+
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 +294,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 +354,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: 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

Mime Type
text/plain
Expires
Sat, Sep 19, 11:17 PM (6 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39257552
Default Alt Text
D14677.id40245.diff (2 KB)

Event Timeline