insert_resource(&iomem_resource, &data_resource);
        insert_resource(&iomem_resource, &bss_resource);
 
+       /*
+        * Complain if .text .data and .bss are not marked as E820_RAM and
+        * attempt to fix it by adding the range. We may have a confused BIOS,
+        * or the user may have incorrectly supplied it via memmap=exactmap. If
+        * we really are running on top non-RAM, we will crash later anyways.
+        */
+       if (!e820_all_mapped(code_resource.start, __pa(__brk_limit), E820_RAM)) {
+               pr_warn(".text .data .bss are not marked as E820_RAM!\n");
+
+               e820_add_region(code_resource.start,
+                               __pa(__brk_limit) - code_resource.start + 1,
+                               E820_RAM);
+       }
+
        trim_bios_range();
 #ifdef CONFIG_X86_32
        if (ppro_with_ram_bug()) {