From c1666e663d8443f57c1c6b0acac70c3fbaea9014 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 31 Jan 2008 22:05:43 +0100 Subject: [PATCH 1/8] x86: fix sparse warnings in intel_cacheinfo.c arch/x86/kernel/cpu/intel_cacheinfo.c:355:7: warning: symbol 'i' shadows an earlier one arch/x86/kernel/cpu/intel_cacheinfo.c:296:39: originally declared here arch/x86/kernel/cpu/intel_cacheinfo.c:367:18: warning: incorrect type in argument 2 (different signedness) arch/x86/kernel/cpu/intel_cacheinfo.c:367:18: expected unsigned int *eax arch/x86/kernel/cpu/intel_cacheinfo.c:367:18: got int * arch/x86/kernel/cpu/intel_cacheinfo.c:367:28: warning: incorrect type in argument 3 (different signedness) arch/x86/kernel/cpu/intel_cacheinfo.c:367:28: expected unsigned int *ebx arch/x86/kernel/cpu/intel_cacheinfo.c:367:28: got int * arch/x86/kernel/cpu/intel_cacheinfo.c:367:38: warning: incorrect type in argument 4 (different signedness) arch/x86/kernel/cpu/intel_cacheinfo.c:367:38: expected unsigned int *ecx arch/x86/kernel/cpu/intel_cacheinfo.c:367:38: got int * arch/x86/kernel/cpu/intel_cacheinfo.c:367:48: warning: incorrect type in argument 5 (different signedness) arch/x86/kernel/cpu/intel_cacheinfo.c:367:48: expected unsigned int *edx arch/x86/kernel/cpu/intel_cacheinfo.c:367:48: got int * Signed-off-by: Harvey Harrison Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/intel_cacheinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 8b4507b8469b..1b889860eb73 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c @@ -352,8 +352,8 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) */ if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) { /* supports eax=2 call */ - int i, j, n; - int regs[4]; + int j, n; + unsigned int regs[4]; unsigned char *dp = (unsigned char *)regs; int only_trace = 0; @@ -368,7 +368,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) /* If bit 31 is set, this is an unknown format */ for ( j = 0 ; j < 3 ; j++ ) { - if ( regs[j] < 0 ) regs[j] = 0; + if (regs[j] & (1 << 31)) regs[j] = 0; } /* Byte 0 is level count, not a descriptor */ From 5827040df095d8dd6b5ca155dc4bfb5bafcb6ca2 Mon Sep 17 00:00:00 2001 From: "Huang, Ying" Date: Thu, 31 Jan 2008 22:05:43 +0100 Subject: [PATCH 2/8] x86: change_page_attr_clear fix This patch replaces __change_page_attr_set_clr() with change_page_attr_set_clr() in change_page_attr_clear() to flush the TLB/cache properly. Signed-off-by: Huang Ying Signed-off-by: Ingo Molnar --- arch/x86/mm/pageattr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 1cc6607eacb0..e297bd65e513 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -399,8 +399,7 @@ static inline int change_page_attr_set(unsigned long addr, int numpages, static inline int change_page_attr_clear(unsigned long addr, int numpages, pgprot_t mask) { - return __change_page_attr_set_clr(addr, numpages, __pgprot(0), mask); - + return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask); } int set_memory_uc(unsigned long addr, int numpages) From d4387bd3fa1d27e03bc87533c1650e24417c8016 Mon Sep 17 00:00:00 2001 From: "Huang, Ying" Date: Thu, 31 Jan 2008 22:05:45 +0100 Subject: [PATCH 3/8] x86: c_p_a clflush_cache_range fix Because in i386 early boot stage, boot_cpu_data may be not available, which makes clflush_cach_range() into infinite loop, which is called by change_page_attr(). This patch fixes this by setting boot_cpu_data.x86_clflush_size in early_cpu_detect(). Signed-off-by: Huang Ying Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index db28aa9e2f69..d608c9ebbfe2 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -274,8 +274,10 @@ void __init cpu_detect(struct cpuinfo_x86 *c) if (c->x86 >= 0x6) c->x86_model += ((tfms >> 16) & 0xF) << 4; c->x86_mask = tfms & 15; - if (cap0 & (1<<19)) + if (cap0 & (1<<19)) { c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8; + c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; + } } } static void __cpuinit early_get_cap(struct cpuinfo_x86 *c) @@ -317,6 +319,7 @@ static void __init early_cpu_detect(void) struct cpuinfo_x86 *c = &boot_cpu_data; c->x86_cache_alignment = 32; + c->x86_clflush_size = 32; if (!have_cpuid_p()) return; From 1fd6a53ddc75d02ad0f363cb42f2a1cec6b701c2 Mon Sep 17 00:00:00 2001 From: "Huang, Ying" Date: Thu, 31 Jan 2008 22:05:45 +0100 Subject: [PATCH 4/8] x86: early_ioremap_reset fix 2 This patch fixes a bug of early_ioremap_reset(), which had been fixed before by "convert the boot time page table to the kernels native format" patch. But that patch has been reverted now. Signed-off-by: Huang Ying Signed-off-by: Ingo Molnar --- arch/x86/mm/ioremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index ed795721ca8e..a177d76e1c53 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -340,7 +340,7 @@ void __init early_ioremap_reset(void) for (idx = FIX_BTMAP_BEGIN; idx >= FIX_BTMAP_END; idx--) { addr = fix_to_virt(idx); pte = early_ioremap_pte(addr); - if (!*pte & _PAGE_PRESENT) { + if (*pte & _PAGE_PRESENT) { phys = *pte & PAGE_MASK; set_fixmap(idx, phys); } From 706b7e1573d7b7ad7825e84a6dcfb3d533993b83 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 31 Jan 2008 22:05:45 +0100 Subject: [PATCH 5/8] x86: fix sparse warning in kernel/scx200_32.c arch/x86/kernel/scx200_32.c:68:72: warning: Using plain integer as NULL pointer Signed-off-by: Harvey Harrison Signed-off-by: Ingo Molnar --- arch/x86/kernel/scx200_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/scx200_32.c b/arch/x86/kernel/scx200_32.c index 87bc159d29df..7e004acbe526 100644 --- a/arch/x86/kernel/scx200_32.c +++ b/arch/x86/kernel/scx200_32.c @@ -65,7 +65,7 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_ base = pci_resource_start(pdev, 0); printk(KERN_INFO NAME ": GPIO base 0x%x\n", base); - if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) { + if (!request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO")) { printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n"); return -EBUSY; } From 072b7a58ca534a667f9649ead1628dfb20087e4b Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 31 Jan 2008 22:05:47 +0100 Subject: [PATCH 6/8] x86: fix small sparse warning arch/x86/kernel/ds.c:226:9: warning: Using plain integer as NULL pointer Signed-off-by: Harvey Harrison Signed-off-by: Ingo Molnar --- arch/x86/kernel/ds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c index 1c5ca4d18787..dcd918c1580d 100644 --- a/arch/x86/kernel/ds.c +++ b/arch/x86/kernel/ds.c @@ -223,7 +223,7 @@ int ds_free(void **dsp) if (*dsp) kfree((void *)get_bts_buffer_base(*dsp)); kfree(*dsp); - *dsp = 0; + *dsp = NULL; return 0; } From 5aa0508508e7cd62bec6e3933b86fce03d2e8502 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 31 Jan 2008 22:05:48 +0100 Subject: [PATCH 7/8] x86: uninline __pte_free_tlb() and __pmd_free_tlb() this also removes an include file dependency. Signed-off-by: Ingo Molnar --- arch/x86/mm/pgtable_32.c | 23 +++++++++++++++++++++++ include/asm-x86/pgalloc_32.h | 20 +++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c index 2ae5999a795a..cb3aa470249b 100644 --- a/arch/x86/mm/pgtable_32.c +++ b/arch/x86/mm/pgtable_32.c @@ -376,3 +376,26 @@ void check_pgt_cache(void) { quicklist_trim(0, pgd_dtor, 25, 16); } + +void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte) +{ + paravirt_release_pt(page_to_pfn(pte)); + tlb_remove_page(tlb, pte); +} + +#ifdef CONFIG_X86_PAE + +void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) +{ + /* This is called just after the pmd has been detached from + the pgd, which requires a full tlb flush to be recognized + by the CPU. Rather than incurring multiple tlb flushes + while the address space is being pulled down, make the tlb + gathering machinery do a full flush when we're done. */ + tlb->fullmm = 1; + + paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT); + tlb_remove_page(tlb, virt_to_page(pmd)); +} + +#endif diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h index 10c2b452e64c..7641e7b5d931 100644 --- a/include/asm-x86/pgalloc_32.h +++ b/include/asm-x86/pgalloc_32.h @@ -3,6 +3,7 @@ #include #include /* for struct page */ +#include #include #include @@ -51,11 +52,7 @@ static inline void pte_free(struct page *pte) } -static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte) -{ - paravirt_release_pt(page_to_pfn(pte)); - tlb_remove_page(tlb, pte); -} +extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte); #ifdef CONFIG_X86_PAE /* @@ -72,18 +69,7 @@ static inline void pmd_free(pmd_t *pmd) free_page((unsigned long)pmd); } -static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) -{ - /* This is called just after the pmd has been detached from - the pgd, which requires a full tlb flush to be recognized - by the CPU. Rather than incurring multiple tlb flushes - while the address space is being pulled down, make the tlb - gathering machinery do a full flush when we're done. */ - tlb->fullmm = 1; - - paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT); - tlb_remove_page(tlb, virt_to_page(pmd)); -} +extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd); static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd) { From 62152d0ea7012382cd814c7b361b4ef2029f26e6 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Thu, 31 Jan 2008 22:05:48 +0100 Subject: [PATCH 8/8] asm-generic/tlb.h: build fix bring back the avr32, blackfin, sh, sparc architectures into working order, by reverting the effects of this change that came in via the x86 tree: commit a5a19c63f4e55e32dc0bc3d936d7f94793d8b380 Author: Jeremy Fitzhardinge Date: Wed Jan 30 13:33:39 2008 +0100 x86: demacro asm-x86/pgalloc_32.h Sorry about that! Signed-off-by: Ingo Molnar --- include/asm-generic/tlb.h | 1 + include/linux/swap.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 6ce9f3ab928d..75f2bfab614f 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -15,6 +15,7 @@ #include #include +#include #include /* diff --git a/include/linux/swap.h b/include/linux/swap.h index 2c3ce4c69b25..4f3838adbb30 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include