From 0f0df0e66ebaf42d1decb7d401eb5f2e590b4ece Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 5 Nov 2016 23:02:24 +0100 Subject: [PATCH] add debug messages, unmap pages after the failed search for the MP tables --- hermit/arch/x86/kernel/apic.c | 16 ++++++++++------ hermit/arch/x86/mm/page.c | 11 +++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hermit/arch/x86/kernel/apic.c b/hermit/arch/x86/kernel/apic.c index 2e3be50e6..42975dc4c 100644 --- a/hermit/arch/x86/kernel/apic.c +++ b/hermit/arch/x86/kernel/apic.c @@ -327,7 +327,7 @@ int apic_timer_is_running(void) int apic_timer_deadline(uint32_t ticks) { if (BUILTIN_EXPECT(apic_is_enabled() && icr, 1)) { - //kprintf("timer oneshot %ld\n", t); + //kprintf("timer oneshot %ld at core %d\n", ticks, CORE_ID); lapic_timer_oneshot(); lapic_timer_set_counter(ticks * icr); @@ -343,6 +343,7 @@ int apic_disable_timer(void) if (BUILTIN_EXPECT(!apic_is_enabled(), 0)) return -EINVAL; + //kprintf("Disable local APIC timer at core %d\n", CORE_ID); lapic_timer_disable(); return 0; @@ -351,6 +352,7 @@ int apic_disable_timer(void) int apic_enable_timer(void) { if (BUILTIN_EXPECT(apic_is_enabled() && icr, 1)) { + //kprintf("Enable local APIC timer at core %d\n", CORE_ID); lapic_timer_periodic(); lapic_timer_set_counter(icr); @@ -378,13 +380,15 @@ static apic_mp_t* search_mptable(size_t base, size_t limit) { vptr = 0; } - if (BUILTIN_EXPECT(!page_map(ptr & PAGE_MASK, ptr & PAGE_MASK, 1, flags), 1)) + if (BUILTIN_EXPECT(!page_map(ptr & PAGE_MASK, ptr & PAGE_MASK, 1, flags), 1)) { vptr = ptr & PAGE_MASK; - else + } else { + kprintf("Failed to map 0x%zx, which is required to search for the MP tables\n", ptr); return NULL; + } - for(i=0; (vptr) && (isignature == MP_FLT_SIGNATURE) { if (!((tmp->version > 4) || (tmp->features[0]))) { vma_add(ptr & PAGE_MASK, (ptr & PAGE_MASK) + PAGE_SIZE, VMA_READ|VMA_WRITE); @@ -983,7 +987,7 @@ int ipi_tlb_flush(void) static void apic_tlb_handler(struct state *s) { - //kputs("Receive IPI to flush the TLB\n"); + //kprintf("Receive IPI at core %d to flush the TLB\n", CORE_ID); write_cr3(read_cr3()); } #endif diff --git a/hermit/arch/x86/mm/page.c b/hermit/arch/x86/mm/page.c index 42ec8fcdb..68612d537 100644 --- a/hermit/arch/x86/mm/page.c +++ b/hermit/arch/x86/mm/page.c @@ -122,6 +122,8 @@ int __page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits, uint8 long first[PAGE_LEVELS], last[PAGE_LEVELS]; int8_t send_ipi = 0; + //kprintf("Map %d pages at 0x%zx\n", npages, viraddr); + /* Calculate index boundaries for page map traversal */ for (lvl=0; lvl> (lvl * PAGE_MAP_BITS); @@ -157,8 +159,10 @@ int __page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits, uint8 int8_t flush = 0; /* do we have to flush the TLB? */ - if (self[lvl][vpn] & PG_PRESENT) + if (self[lvl][vpn] & PG_PRESENT) { + //kprintf("Remap address 0x%zx at core %d\n", viraddr, CORE_ID); send_ipi = flush = 1; + } self[lvl][vpn] = phyaddr | bits | PG_PRESENT | PG_ACCESSED; @@ -168,6 +172,7 @@ int __page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits, uint8 tlb_flush_one_page(vpn << PAGE_BITS, 0); phyaddr += PAGE_SIZE; + //viraddr += PAGE_SIZE; } } } @@ -187,6 +192,8 @@ int page_unmap(size_t viraddr, size_t npages) if (BUILTIN_EXPECT(!npages, 0)) return 0; + //kprintf("Unmap %d pages at 0x%zx\n", npages, viraddr); + spinlock_irqsave_lock(&page_lock); /* Start iterating through the entries. @@ -258,7 +265,7 @@ void page_fault_handler(struct state *s) flags = PG_USER|PG_RW; if (has_nx()) // set no execution flag to protect the heap flags |= PG_XD; - ret = page_map(viraddr, phyaddr, 1, flags); + ret = __page_map(viraddr, phyaddr, 1, flags, 0); if (BUILTIN_EXPECT(ret, 0)) { kprintf("map_region: could not map %#lx to %#lx, task = %u\n", phyaddr, viraddr, task->id);