From e8bff74afbdb4ad72bf6135c84289c47cf557892 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 13 Feb 2008 20:21:06 +0100 Subject: x86: fix "BUG: sleeping function called from invalid context" in print_vma_addr() Jiri Kosina reported the following deadlock scenario with show_unhandled_signals enabled: [ 68.379022] gnome-settings-[2941] trap int3 ip:3d2c840f34 sp:7fff36f5d100 error:0<3>BUG: sleeping function called from invalid context at kernel/rwsem.c:21 [ 68.379039] in_atomic():1, irqs_disabled():0 [ 68.379044] no locks held by gnome-settings-/2941. [ 68.379050] Pid: 2941, comm: gnome-settings- Not tainted 2.6.25-rc1 #30 [ 68.379054] [ 68.379056] Call Trace: [ 68.379061] <#DB> [] ? __debug_show_held_locks+0x13/0x30 [ 68.379109] [] __might_sleep+0xe5/0x110 [ 68.379123] [] down_read+0x20/0x70 [ 68.379137] [] print_vma_addr+0x3a/0x110 [ 68.379152] [] do_trap+0xf5/0x170 [ 68.379168] [] do_int3+0x7b/0xe0 [ 68.379180] [] int3+0x9f/0xd0 [ 68.379203] <> [ 68.379229] in libglib-2.0.so.0.1505.0[3d2c800000+dc000] and tracked it down to: commit 03252919b79891063cf99145612360efbdf9500b Author: Andi Kleen Date: Wed Jan 30 13:33:18 2008 +0100 x86: print which shared library/executable faulted in segfault etc. messages the problem is that we call down_read() from an atomic context. Solve this by returning from print_vma_addr() if the preempt count is elevated. Update preempt_conditional_sti / preempt_conditional_cli to unconditionally lift the preempt count even on !CONFIG_PREEMPT. Reported-by: Jiri Kosina Signed-off-by: Ingo Molnar --- arch/x86/kernel/traps_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c index efc66df728b..04546668191 100644 --- a/arch/x86/kernel/traps_64.c +++ b/arch/x86/kernel/traps_64.c @@ -84,7 +84,7 @@ static inline void conditional_sti(struct pt_regs *regs) static inline void preempt_conditional_sti(struct pt_regs *regs) { - preempt_disable(); + inc_preempt_count(); if (regs->flags & X86_EFLAGS_IF) local_irq_enable(); } @@ -95,7 +95,7 @@ static inline void preempt_conditional_cli(struct pt_regs *regs) local_irq_disable(); /* Make sure to not schedule here because we could be running on an exception stack. */ - preempt_enable_no_resched(); + dec_preempt_count(); } int kstack_depth_to_print = 12; -- cgit v1.2.3 From cae30f8270005940902c5807146fbaa36875e6e9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 13 Feb 2008 23:31:31 +0200 Subject: x86: make dump_pagetable() static dump_pagetable() can now become static. Signed-off-by: Adrian Bunk Acked-by: Arjan van de Ven Signed-off-by: Ingo Molnar --- arch/x86/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 621afb6343d..fdc667422df 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -186,7 +186,7 @@ static int bad_address(void *p) } #endif -void dump_pagetable(unsigned long address) +static void dump_pagetable(unsigned long address) { #ifdef CONFIG_X86_32 __typeof__(pte_val(__pte(0))) page; -- cgit v1.2.3 From 3223f59f9cd9d69a4344eeac8b16a262c5f373f1 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 14 Feb 2008 14:21:32 +0100 Subject: x86: EFI set_memory_x()/set_memory_uc() fixes The EFI-runtime mapping code changed a larger memory area than it should have, due to a pages/bytes parameter mixup. noticed by Andi Kleen. Signed-off-by: Ingo Molnar --- arch/x86/kernel/efi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c index cbdf9bacc57..0c0eeb163d9 100644 --- a/arch/x86/kernel/efi.c +++ b/arch/x86/kernel/efi.c @@ -391,7 +391,7 @@ static void __init runtime_code_page_mkexec(void) if (md->type != EFI_RUNTIME_SERVICES_CODE) continue; - set_memory_x(md->virt_addr, md->num_pages << EFI_PAGE_SHIFT); + set_memory_x(md->virt_addr, md->num_pages); } } @@ -434,7 +434,7 @@ void __init efi_enter_virtual_mode(void) } if (!(md->attribute & EFI_MEMORY_WB)) - set_memory_uc(md->virt_addr, size); + set_memory_uc(md->virt_addr, md->num_pages); systab = (u64) (unsigned long) efi_phys.systab; if (md->phys_addr <= systab && systab < end) { -- cgit v1.2.3 From 184652eb6f68050af48a2ce3d5cf0537c208bee2 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 14 Feb 2008 23:30:20 +0100 Subject: x86: fix gart_iommu_init() When the GART table is unmapped from the kernel direct mappings during early bootup, make sure we have no leftover cachelines in it. Note: the clflush done by set_memory_np() was not enough, because clflush does not work on unmapped pages. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- arch/x86/kernel/pci-gart_64.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c index 65f6acb025c..faf3229f8fb 100644 --- a/arch/x86/kernel/pci-gart_64.c +++ b/arch/x86/kernel/pci-gart_64.c @@ -749,6 +749,15 @@ void __init gart_iommu_init(void) */ set_memory_np((unsigned long)__va(iommu_bus_base), iommu_size >> PAGE_SHIFT); + /* + * Tricky. The GART table remaps the physical memory range, + * so the CPU wont notice potential aliases and if the memory + * is remapped to UC later on, we might surprise the PCI devices + * with a stray writeout of a cacheline. So play it sure and + * do an explicit, full-scale wbinvd() _after_ having marked all + * the pages as Not-Present: + */ + wbinvd(); /* * Try to workaround a bug (thanks to BenH) -- cgit v1.2.3 From 7bfeab9af95565e38a97fbcfb631e5b140241187 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 12 Feb 2008 12:12:01 -0800 Subject: x86: include proper prototypes for rodata_test extern should not appear in C files. Also, the definitions do not match the prototype currently, not sure what way you want to go with this, I've switched the prototype to return int, but I can see going to the void return as well. Signed-off-by: Harvey Harrison Signed-off-by: Ingo Molnar --- arch/x86/kernel/test_rodata.c | 2 +- arch/x86/mm/init_32.c | 1 + arch/x86/mm/init_64.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/x86/kernel/test_rodata.c b/arch/x86/kernel/test_rodata.c index 4c163772000..c29e235792a 100644 --- a/arch/x86/kernel/test_rodata.c +++ b/arch/x86/kernel/test_rodata.c @@ -10,8 +10,8 @@ * of the License. */ #include +#include #include -extern int rodata_test_data; int rodata_test(void) { diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 8106bba41ec..ee1091a4696 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -47,6 +47,7 @@ #include #include #include +#include unsigned int __VMALLOC_RESERVE = 128 << 20; diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index b59fc238151..a4a9cccdd4f 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -45,6 +45,7 @@ #include #include #include +#include const struct dma_mapping_ops *dma_ops; EXPORT_SYMBOL(dma_ops); -- cgit v1.2.3 From 69b1415e934fc1a796a817e32d84162ae65962f5 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 13 Feb 2008 11:04:50 +0100 Subject: x86: cpa: ensure page alignment the cpa API is page aligned - warn about any weird alignments. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/mm/pageattr.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arch') diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index bd61ed13f9c..5d2259468d3 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -688,6 +688,15 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages, if (!pgprot_val(mask_set) && !pgprot_val(mask_clr)) return 0; + /* Ensure we are PAGE_SIZE aligned */ + if (addr & ~PAGE_MASK) { + addr &= PAGE_MASK; + /* + * People should not be passing in unaligned addresses: + */ + WARN_ON_ONCE(1); + } + cpa.vaddr = addr; cpa.numpages = numpages; cpa.mask_set = mask_set; -- cgit v1.2.3 From 7d8330a563b00040326084f933f5bee06675ac54 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Sun, 10 Feb 2008 12:46:28 +0530 Subject: KVM is not seen under X86 config with latest git (32 bit compile) The KVM configuration is no longer visible in the latest git tree. It looks like it is selected by HAVE_SETUP_PER_CPU_AREA. I've moved HAVE_KVM to under CONFIG_X86. Signed-off-by: Balbir Singh Acked-by: Avi Kivity Signed-off-by: Ingo Molnar --- arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index aaed1a3b92d..3be2305709b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -21,6 +21,8 @@ config X86 select HAVE_IDE select HAVE_OPROFILE select HAVE_KPROBES + select HAVE_KVM + config GENERIC_LOCKBREAK def_bool n @@ -119,8 +121,6 @@ config ARCH_HAS_CPU_RELAX config HAVE_SETUP_PER_CPU_AREA def_bool X86_64 -select HAVE_KVM - config ARCH_HIBERNATION_POSSIBLE def_bool y depends on !SMP || !X86_VOYAGER -- cgit v1.2.3 From f8d8406bcb58ff70e97b71c35ff5be90c54fc3d0 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 13 Feb 2008 14:09:53 +0100 Subject: x86: cpa, fix out of date comment Signed-off-by: Ingo Molnar --- arch/x86/mm/pageattr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 5d2259468d3..4119379f80f 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -870,8 +870,12 @@ void kernel_map_pages(struct page *page, int numpages, int enable) return; /* - * The return value is ignored - the calls cannot fail, - * large pages are disabled at boot time: + * The return value is ignored as the calls cannot fail. + * Large pages are kept enabled at boot time, and are + * split up quickly with DEBUG_PAGEALLOC. If a splitup + * fails here (due to temporary memory shortage) no damage + * is done because we just keep the largepage intact up + * to the next attempt when it will likely be split up: */ if (enable) __set_pages_p(page, numpages); -- cgit v1.2.3