Kernel: Simplify a bunch of dbg() and klog() calls

LogStream can handle VirtualAddress and PhysicalAddress directly.
This commit is contained in:
Andreas Kling 2020-03-06 15:00:44 +01:00
parent b866582d98
commit c6693f9b3a
Notes: sideshowbarker 2024-07-19 08:52:09 +09:00
11 changed files with 32 additions and 33 deletions

View file

@ -168,7 +168,7 @@ namespace ACPI {
if (m_xsdt_supported) {
volatile auto* xsdt = (volatile Structures::XSDT*)sdt;
klog() << "ACPI: Using XSDT, Enumerating tables @ P " << String::format("%p", m_main_system_description_table.get());
klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length;
#ifdef ACPI_DEBUG
dbg() << "ACPI: XSDT pointer @ V " << xsdt;
@ -181,7 +181,7 @@ namespace ACPI {
}
} else {
volatile auto* rsdt = (volatile Structures::RSDT*)sdt;
klog() << "ACPI: Using RSDT, Enumerating tables @ P " << String::format("%p", m_main_system_description_table.get());
klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length;
#ifdef ACPI_DEBUG
dbg() << "ACPI: RSDT pointer @ V " << rsdt;
@ -220,7 +220,7 @@ namespace ACPI {
, m_rsdp(StaticParsing::search_rsdp())
{
if (!m_rsdp.is_null()) {
klog() << "ACPI: Using RSDP @ P " << String::format("%p", m_rsdp);
klog() << "ACPI: Using RSDP @ " << m_rsdp;
m_operable = true;
locate_static_data();
} else {
@ -233,7 +233,7 @@ namespace ACPI {
: Parser(true)
, m_rsdp(rsdp)
{
klog() << "ACPI: Using RSDP @ P " << String::format("%p", rsdp.get());
klog() << "ACPI: Using RSDP @ " << rsdp;
m_operable = true;
locate_static_data();
}

View file

@ -62,7 +62,7 @@ void DMIDecoder::initialize_untrusted()
void DMIDecoder::set_64_bit_entry_initialization_values(PhysicalAddress entry)
{
klog() << "DMIDecoder: SMBIOS 64bit Entry point @ P " << String::format("%p", m_entry64bit_point.get());
klog() << "DMIDecoder: SMBIOS 64bit Entry point @ " << m_entry64bit_point;
m_use_64bit_entry = true;
auto region = MM.allocate_kernel_region(entry.page_base(), PAGE_ROUND_UP(SMBIOS_SEARCH_AREA_SIZE), "DMI Decoder 64 bit Initialization", Region::Access::Read, false, false);
@ -74,7 +74,7 @@ void DMIDecoder::set_64_bit_entry_initialization_values(PhysicalAddress entry)
void DMIDecoder::set_32_bit_entry_initialization_values(PhysicalAddress entry)
{
klog() << "DMIDecoder: SMBIOS 32bit Entry point @ P " << String::format("%p", m_entry32bit_point.get());
klog() << "DMIDecoder: SMBIOS 32bit Entry point @ " << m_entry32bit_point;
m_use_64bit_entry = false;
auto region = MM.allocate_kernel_region(entry.page_base(), PAGE_ROUND_UP(SMBIOS_SEARCH_AREA_SIZE), "DMI Decoder 32 bit Initialization", Region::Access::Read, false, false);
@ -101,7 +101,7 @@ void DMIDecoder::initialize_parser()
} else if (!m_entry32bit_point.is_null()) {
set_32_bit_entry_initialization_values(m_entry32bit_point);
}
klog() << "DMIDecoder: Data table @ P " << String::format("%p", m_structure_table.get());
klog() << "DMIDecoder: Data table @ " << m_structure_table;
enumerate_smbios_tables();
}
@ -264,7 +264,7 @@ u64 DMIDecoder::get_bios_characteristics()
auto* bios_info = (SMBIOS::BIOSInfo*)get_smbios_physical_table_by_type(0).as_ptr();
ASSERT(bios_info != nullptr);
klog() << "DMIDecoder: BIOS info @ P " << String::format("%p", bios_info);
klog() << "DMIDecoder: BIOS info @ " << PhysicalAddress((uintptr_t)bios_info);
return bios_info->bios_characteristics;
}

View file

@ -48,7 +48,7 @@ MultiProcessorParser::MultiProcessorParser()
, m_operable((m_floating_pointer != (uintptr_t) nullptr))
{
if (m_floating_pointer != (uintptr_t) nullptr) {
klog() << "MultiProcessor: Floating Pointer Structure @ P " << String::format("%p", m_floating_pointer);
klog() << "MultiProcessor: Floating Pointer Structure @ " << PhysicalAddress(m_floating_pointer);
parse_floating_pointer_data();
parse_configuration_table();
} else {

View file

@ -246,7 +246,7 @@ void page_fault_handler(RegisterState regs)
bool faulted_in_userspace = (regs.cs & 3) == 3;
if (faulted_in_userspace && !MM.validate_user_stack(*Process::current, VirtualAddress(regs.userspace_esp))) {
dbg() << "Invalid stack pointer: " << String::format("%p", regs.userspace_esp);
dbg() << "Invalid stack pointer: " << VirtualAddress(regs.userspace_esp);
handle_crash(regs, "Bad stack on page fault", SIGSTKFLT);
ASSERT_NOT_REACHED();
}
@ -271,19 +271,19 @@ void page_fault_handler(RegisterState regs)
u32 slab_alloc_scrub_pattern = explode_byte(SLAB_ALLOC_SCRUB_BYTE);
u32 slab_dealloc_scrub_pattern = explode_byte(SLAB_DEALLOC_SCRUB_BYTE);
if ((fault_address & 0xffff0000) == (malloc_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be uninitialized malloc() memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be uninitialized malloc() memory";
} else if ((fault_address & 0xffff0000) == (free_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be recently free()'d memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be recently free()'d memory";
} else if ((fault_address & 0xffff0000) == (kmalloc_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be uninitialized kmalloc() memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be uninitialized kmalloc() memory";
} else if ((fault_address & 0xffff0000) == (kfree_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be recently kfree()'d memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be recently kfree()'d memory";
} else if ((fault_address & 0xffff0000) == (slab_alloc_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be uninitialized slab_alloc() memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be uninitialized slab_alloc() memory";
} else if ((fault_address & 0xffff0000) == (slab_dealloc_scrub_pattern & 0xffff0000)) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like it may be recently slab_dealloc()'d memory";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like it may be recently slab_dealloc()'d memory";
} else if (fault_address < 4096) {
klog() << "Note: Address " << String::format("%p", fault_address) << " looks like a possible nullptr dereference";
klog() << "Note: Address " << VirtualAddress(fault_address) << " looks like a possible nullptr dereference";
}
handle_crash(regs, "Page Fault", SIGSEGV);

View file

@ -160,7 +160,7 @@ u32 BXVGADevice::find_framebuffer_address()
PCI::enumerate_all([&framebuffer_address](const PCI::Address& address, PCI::ID id) {
if (id == bochs_vga_id || id == virtualbox_vga_id) {
framebuffer_address = PCI::get_BAR0(address) & 0xfffffff0;
klog() << "BXVGA: framebuffer @ P " << String::format("%p", framebuffer_address);
klog() << "BXVGA: framebuffer @ " << PhysicalAddress(framebuffer_address);
}
});
return framebuffer_address;

View file

@ -136,7 +136,7 @@ ssize_t FIFO::write(FileDescription&, const u8* buffer, ssize_t size)
return -EPIPE;
}
#ifdef FIFO_DEBUG
dbg() << "fifo: write(" << String::format("%p", buffer) << ", " << size << ")";
dbg() << "fifo: write(" << (const void*)buffer) << ", " << size << ")";
#endif
return m_buffer.write(buffer, size);
}

View file

@ -167,7 +167,7 @@ namespace APIC {
return false;
PhysicalAddress apic_base = get_base();
klog() << "Initializing APIC, base: P " << String::format("%p", apic_base);
klog() << "Initializing APIC, base: " << apic_base;
set_base(apic_base);
g_apic_base = apic_base.as_ptr();

View file

@ -86,7 +86,7 @@ PCI::MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
u32 lower_addr = mcfg.descriptors[index].base_addr;
m_segments.set(index, new PCI::MMIOSegment(PhysicalAddress(lower_addr), start_bus, end_bus));
klog() << "PCI: New PCI segment @ P " << String::format("%p", lower_addr) << ", PCI buses (" << start_bus << "-" << end_bus << ")";
klog() << "PCI: New PCI segment @ " << PhysicalAddress(lower_addr) << ", PCI buses (" << start_bus << "-" << end_bus << ")";
}
mcfg_region->unmap();
klog() << "PCI: MMIO segments - " << m_segments.size();

View file

@ -922,7 +922,7 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
// instead of just non-null. You could totally have a DSO with entry point of
// the beginning of the text segement.
if (!loader->entry().offset(totally_random_offset).get()) {
klog() << "do_exec: Failure loading " << path.characters() << ", entry pointer is invalid! (" << String::format("%p", loader->entry().offset(totally_random_offset).get()) << ")";
klog() << "do_exec: Failure loading " << path.characters() << ", entry pointer is invalid! (" << loader->entry().offset(totally_random_offset) << ")";
return -ENOEXEC;
}

View file

@ -210,11 +210,11 @@ PageTableEntry& MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual
PageDirectoryEntry& pde = pd[page_directory_index];
if (!pde.is_present()) {
#ifdef MM_DEBUG
dbg() << "MM: PDE " << page_directory_index << " not present (requested for V" << String::format("%p", vaddr.get()) << "), allocating";
dbg() << "MM: PDE " << page_directory_index << " not present (requested for " << vaddr << "), allocating";
#endif
auto page_table = allocate_user_physical_page(ShouldZeroFill::Yes);
#ifdef MM_DEBUG
dbg() << "MM: PD K" << &page_directory << " (" << (&page_directory == m_kernel_page_directory ? "Kernel" : "User") << ") at P" << String::format("%p", page_directory.cr3()) << " allocated page table " << String::format("#%u", page_directory_index) << " (for V" << String::format("%p", vaddr.get()) << ") at P" << String::format("%p", page_table->paddr().get());
dbg() << "MM: PD K" << &page_directory << " (" << (&page_directory == m_kernel_page_directory ? "Kernel" : "User") << ") at " << PhysicalAddress(page_directory.cr3()) << " allocated page table #" << page_directory_index << " (for " << vaddr << ") at " << page_table->paddr();
#endif
pde.set_page_table_base(page_table->paddr().get());
pde.set_user_allowed(true);
@ -290,11 +290,11 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
dump_kernel_regions();
}
#ifdef PAGE_FAULT_DEBUG
dbg() << "MM: handle_page_fault(" << String::format("%w", fault.code()) << ") at V" << String::format("%p", fault.vaddr().get());
dbg() << "MM: handle_page_fault(" << String::format("%w", fault.code()) << ") at " << fault.vaddr();
#endif
auto* region = region_from_vaddr(fault.vaddr());
if (!region) {
klog() << "NP(error) fault at invalid address V" << String::format("%p", fault.vaddr().get());
klog() << "NP(error) fault at invalid address " << fault.vaddr();
return PageFaultResponse::ShouldCrash;
}
@ -416,7 +416,7 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
}
#ifdef MM_DEBUG
dbg() << "MM: allocate_user_physical_page vending P" << String::format("%p", page->paddr().get());
dbg() << "MM: allocate_user_physical_page vending " << page->paddr();
#endif
if (should_zero_fill == ShouldZeroFill::Yes) {
@ -468,7 +468,7 @@ RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
}
#ifdef MM_DEBUG
dbg() << "MM: allocate_supervisor_physical_page vending P" << String::format("%p", page->paddr().get());
dbg() << "MM: allocate_supervisor_physical_page vending " << page->paddr();
#endif
fast_u32_fill((u32*)page->paddr().offset(0xc0000000).as_ptr(), 0, PAGE_SIZE / sizeof(u32));
@ -493,7 +493,7 @@ void MemoryManager::flush_entire_tlb()
void MemoryManager::flush_tlb(VirtualAddress vaddr)
{
#ifdef MM_DEBUG
dbg() << "MM: Flush page V" << String::format("%p", vaddr.get());
dbg() << "MM: Flush page " << vaddr;
#endif
asm volatile("invlpg %0"
:

View file

@ -252,7 +252,7 @@ void Region::unmap(ShouldDeallocateVirtualMemoryRange deallocate_range)
MM.flush_tlb(vaddr);
#ifdef MM_DEBUG
auto& physical_page = vmobject().physical_pages()[first_page_index() + i];
dbg() << "MM: >> Unmapped V" << String::format("%p", vaddr.get()) << " => P" << String::format("%p", physical_page ? physical_page->paddr().get() : 0) << " <<";
dbg() << "MM: >> Unmapped " << vaddr << " => P" << String::format("%p", physical_page ? physical_page->paddr().get() : 0) << " <<";
#endif
}
if (deallocate_range == ShouldDeallocateVirtualMemoryRange::Yes)
@ -358,8 +358,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
}
#ifdef PAGE_FAULT_DEBUG
dbg() << " >> ZERO P\n"
<< String::format("%p", physical_page->paddr().get());
dbg() << " >> ZERO " << physical_page->paddr();
#endif
vmobject_physical_page_entry = move(physical_page);
remap_page(page_index_in_region);
@ -394,7 +393,7 @@ PageFaultResponse Region::handle_cow_fault(size_t page_index_in_region)
u8* dest_ptr = MM.quickmap_page(*physical_page);
const u8* src_ptr = vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
#ifdef PAGE_FAULT_DEBUG
dbg() << " >> COW P" << String::format("%p", physical_page->paddr().get()) << " <- P" << String::format("%p", physical_page_to_copy->paddr().get());
dbg() << " >> COW " << physical_page->paddr() << " <- " << physical_page_to_copy->paddr();
#endif
copy_from_user(dest_ptr, src_ptr, PAGE_SIZE);
vmobject_physical_page_entry = move(physical_page);