Page MenuHomeFreeBSD

D25201.diff
No OneTemporary

D25201.diff

Index: head/sys/arm64/arm64/machdep.c
===================================================================
--- head/sys/arm64/arm64/machdep.c
+++ head/sys/arm64/arm64/machdep.c
@@ -120,6 +120,7 @@
* passed into the kernel and used by the EFI code to call runtime services.
*/
vm_paddr_t efi_systbl_phys;
+static struct efi_map_header *efihdr;
/* pagezero_* implementations are provided in support.S */
void pagezero_simple(void *);
@@ -1071,11 +1072,52 @@
}
}
+int
+memory_mapping_mode(vm_paddr_t pa)
+{
+ struct efi_md *map, *p;
+ size_t efisz;
+ int ndesc, i;
+
+ if (efihdr == NULL)
+ return (VM_MEMATTR_WRITE_BACK);
+
+ /*
+ * Memory map data provided by UEFI via the GetMemoryMap
+ * Boot Services API.
+ */
+ efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
+ map = (struct efi_md *)((uint8_t *)efihdr + efisz);
+
+ if (efihdr->descriptor_size == 0)
+ return (VM_MEMATTR_WRITE_BACK);
+ ndesc = efihdr->memory_size / efihdr->descriptor_size;
+
+ for (i = 0, p = map; i < ndesc; i++,
+ p = efi_next_descriptor(p, efihdr->descriptor_size)) {
+ if (pa < p->md_phys ||
+ pa >= p->md_phys + p->md_pages * EFI_PAGE_SIZE)
+ continue;
+ if (p->md_type == EFI_MD_TYPE_IOMEM ||
+ p->md_type == EFI_MD_TYPE_IOPORT)
+ return (VM_MEMATTR_DEVICE);
+ else if ((p->md_attr & EFI_MD_ATTR_WB) != 0 ||
+ p->md_type == EFI_MD_TYPE_RECLAIM)
+ return (VM_MEMATTR_WRITE_BACK);
+ else if ((p->md_attr & EFI_MD_ATTR_WT) != 0)
+ return (VM_MEMATTR_WRITE_THROUGH);
+ else if ((p->md_attr & EFI_MD_ATTR_WC) != 0)
+ return (VM_MEMATTR_WRITE_COMBINING);
+ break;
+ }
+
+ return (VM_MEMATTR_DEVICE);
+}
+
void
initarm(struct arm64_bootparams *abp)
{
struct efi_fb *efifb;
- struct efi_map_header *efihdr;
struct pcpu *pcpup;
char *env;
#ifdef FDT
Index: head/sys/arm64/arm64/pmap.c
===================================================================
--- head/sys/arm64/arm64/pmap.c
+++ head/sys/arm64/arm64/pmap.c
@@ -5449,7 +5449,7 @@
/* L3 table is linked */
va = trunc_page(va);
pa = trunc_page(pa);
- pmap_kenter(va, size, pa, VM_MEMATTR_WRITE_BACK);
+ pmap_kenter(va, size, pa, memory_mapping_mode(pa));
}
return ((void *)(va + offset));
Index: head/sys/arm64/include/machdep.h
===================================================================
--- head/sys/arm64/include/machdep.h
+++ head/sys/arm64/include/machdep.h
@@ -56,6 +56,7 @@
#ifdef FDT
void parse_fdt_bootargs(void);
#endif
+int memory_mapping_mode(vm_paddr_t pa);
extern void (*pagezero)(void *);
#endif /* _KERNEL */

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 30, 6:21 PM (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13196473
Default Alt Text
D25201.diff (2 KB)

Event Timeline