static void __meminit phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end) { int i = pud_index(addr); for (; i < PTRS_PER_PUD; i++, addr = (addr & PUD_MASK) + PUD_SIZE ) { unsigned long pmd_phys; pud_t *pud = pud_page + pud_index(addr); pmd_t *pmd; if (addr >= end) break; if (!after_bootmem && !e820_any_mapped(addr,addr+PUD_SIZE,0)) { set_pud(pud, __pud(0)); continue; } if (pud_val(*pud)) { phys_pmd_update(pud, addr, end); continue; } pmd = alloc_low_page(&pmd_phys); spin_lock(&init_mm.page_table_lock); set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE)); phys_pmd_init(pmd, addr, end); spin_unlock(&init_mm.page_table_lock); unmap_low_page(pmd); } __flush_tlb(); }
void __init tboot_probe(void) { /* Look for valid page-aligned address for shared page. */ if (!boot_params.tboot_addr) return; /* * also verify that it is mapped as we expect it before calling * set_fixmap(), to reduce chance of garbage value causing crash */ if (!e820_any_mapped(boot_params.tboot_addr, boot_params.tboot_addr, E820_RESERVED)) { pr_warning("non-0 tboot_addr but it is not of type E820_RESERVED\n"); return; } /* only a natively booted kernel should be using TXT */ if (paravirt_enabled()) { pr_warning("non-0 tboot_addr but pv_ops is enabled\n"); return; } /* Map and check for tboot UUID. */ set_fixmap(FIX_TBOOT_BASE, boot_params.tboot_addr); tboot = (struct tboot *)fix_to_virt(FIX_TBOOT_BASE); if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { pr_warning("tboot at 0x%llx is invalid\n", boot_params.tboot_addr); tboot = NULL; return; } if (tboot->version < 5) { pr_warning("tboot version is invalid: %u\n", tboot->version); tboot = NULL; return; } pr_info("found shared page at phys addr 0x%llx:\n", boot_params.tboot_addr); pr_debug("version: %d\n", tboot->version); pr_debug("log_addr: 0x%08x\n", tboot->log_addr); pr_debug("shutdown_entry: 0x%x\n", tboot->shutdown_entry); pr_debug("tboot_base: 0x%08x\n", tboot->tboot_base); pr_debug("tboot_size: 0x%x\n", tboot->tboot_size); }
static phys_addr_t check_cbmem(void) { struct sysinfo sysi; phys_addr_t top_of_ram, scan_addr; /* Get CBMEM TOC address from ACPI if available. */ scan_addr = get_address_from_acpi(CBMEM_TOC_ACPI_NAME); /* * Otherwise determine where to start looking for CBMEM signature: * take the top of usable memory and align it up to 128K boundary. */ if (!scan_addr) { si_meminfo(&sysi); top_of_ram = (phys_addr_t) sysi.totalram << PAGE_SHIFT; scan_addr = ALIGN(top_of_ram, CBMEM_ALIGNMENT) + CBMEM_ALIGNMENT; } while (scan_addr % MEMORY_BOUNDARY) { struct cbmem_entry __iomem *pcbm; int i, remap_size = sizeof(struct cbmem_entry) * 16; /* * See if we reached reserved memory. Bail out if so, as it is * not mappable and is above the region where the CBMEM could * be. */ if (e820_any_mapped(scan_addr, scan_addr + remap_size, E820_RESERVED)) break; pcbm = ioremap_cache(scan_addr, remap_size); if (!pcbm) { scan_addr += CBMEM_ALIGNMENT; continue; } if (pcbm->magic != CBMEM_ENTRY_MAGIC) { iounmap(pcbm); scan_addr += CBMEM_ALIGNMENT; continue; } /* CBMEM found. Is the console log there? */ for (i = 1; i < MAX_CBMEM_ENTRIES; i++) { if ((pcbm[i].magic == CBMEM_ENTRY_MAGIC) && (pcbm[i].id == CBMEM_CONSOLE_ID)) { /* Yes, return its address. */ phys_addr_t ret = pcbm[i].base; iounmap(pcbm); return ret; } } iounmap(pcbm); break; } pr_warn("memconsole: CBMEM console structure not found!\n"); return 0; }
static bool check_cbmem(void) { struct sysinfo sysi; phys_addr_t top_of_ram, scan_addr = 0; acpi_handle handle; acpi_status status; unsigned long long value; /* * Attempt to use defined ACPI name to locate CBMEM TOC. */ status = acpi_get_handle(NULL, CBMEM_ACPI_NAME, &handle); if (ACPI_SUCCESS(status)) { status = acpi_evaluate_integer(handle, CBMEM_ACPI_NAME, NULL, &value); /* Start scan at this address */ if (ACPI_SUCCESS(status) && value > 0) scan_addr = (phys_addr_t) value; } /* * Otherwise determine where to start looking for CBMEM signature: * take the top of usable memory and align it up to 128K boundary. */ if (!scan_addr) { si_meminfo(&sysi); top_of_ram = (phys_addr_t) sysi.totalram << PAGE_SHIFT; scan_addr = ALIGN(top_of_ram, CBMEM_ALIGNMENT) + CBMEM_ALIGNMENT; } while (scan_addr % MEMORY_BOUNDARY) { struct cbmem_entry __iomem *pcbm; int i, remap_size = sizeof(struct cbmem_entry) * 16; /* * See if we reached reserved memory. Bail out if so, as it is * not mappable and is above the region where the CBMEM could * be. */ if (e820_any_mapped(scan_addr, scan_addr + remap_size, E820_RESERVED)) break; pcbm = ioremap(scan_addr, remap_size); if (!pcbm) { scan_addr += CBMEM_ALIGNMENT; continue; } if (pcbm->magic != CBMEM_ENTRY_MAGIC) { iounmap(pcbm); scan_addr += CBMEM_ALIGNMENT; continue; } /* CBMEM found. Is the console log there? */ for (i = 1; i < MAX_CBMEM_ENTRIES; i++) { if ((pcbm[i].magic == CBMEM_ENTRY_MAGIC) && (pcbm[i].id == CBMEM_CONSOLE_ID)) { /* Yes, map the log. */ cbmem_console = ioremap(pcbm[i].base, pcbm[i].size); break; } } iounmap(pcbm); break; } if (cbmem_console) { memconsole_baseaddr = cbmem_console->buffer_body; memconsole_length = min(cbmem_console->buffer_cursor, cbmem_console->buffer_size); return true; } printk(KERN_INFO "CBMEM console structure not found!\n"); return false; }