|
@@ -607,3 +607,34 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
|
|
|
attr & EFI_MEMORY_UC ? "UC" : "");
|
|
|
return buf;
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+ * efi_mem_attributes - lookup memmap attributes for physical address
|
|
|
+ * @phys_addr: the physical address to lookup
|
|
|
+ *
|
|
|
+ * Search in the EFI memory map for the region covering
|
|
|
+ * @phys_addr. Returns the EFI memory attributes if the region
|
|
|
+ * was found in the memory map, 0 otherwise.
|
|
|
+ *
|
|
|
+ * Despite being marked __weak, most architectures should *not*
|
|
|
+ * override this function. It is __weak solely for the benefit
|
|
|
+ * of ia64 which has a funky EFI memory map that doesn't work
|
|
|
+ * the same way as other architectures.
|
|
|
+ */
|
|
|
+u64 __weak efi_mem_attributes(unsigned long phys_addr)
|
|
|
+{
|
|
|
+ efi_memory_desc_t *md;
|
|
|
+ void *p;
|
|
|
+
|
|
|
+ if (!efi_enabled(EFI_MEMMAP))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
|
|
|
+ md = p;
|
|
|
+ if ((md->phys_addr <= phys_addr) &&
|
|
|
+ (phys_addr < (md->phys_addr +
|
|
|
+ (md->num_pages << EFI_PAGE_SHIFT))))
|
|
|
+ return md->attribute;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|