linux-kernel-test/arch/x86
Ingo Molnar f022bfd582 x86: PAT fix
Adrian Bunk noticed the following Coverity report:

> Commit e7f260a276
> (x86: PAT use reserve free memtype in mmap of /dev/mem)
> added the following gem to arch/x86/mm/pat.c:
>
> <--  snip  -->
>
> ...
> int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
>                                 unsigned long size, pgprot_t *vma_prot)
> {
>         u64 offset = ((u64) pfn) << PAGE_SHIFT;
>         unsigned long flags = _PAGE_CACHE_UC_MINUS;
>         unsigned long ret_flags;
> ...
> ...  (nothing that touches ret_flags)
> ...
>         if (flags != _PAGE_CACHE_UC_MINUS) {
>                 retval = reserve_memtype(offset, offset + size, flags, NULL);
>         } else {
>                 retval = reserve_memtype(offset, offset + size, -1, &ret_flags);
>         }
>
>         if (retval < 0)
>                 return 0;
>
>         flags = ret_flags;
>
>         if (pfn <= max_pfn_mapped &&
>             ioremap_change_attr((unsigned long)__va(offset), size, flags) < 0) {
>                 free_memtype(offset, offset + size);
>                 printk(KERN_INFO
>                 "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n",
>                         current->comm, current->pid,
>                         cattr_name(flags),
>                         offset, offset + size);
>                 return 0;
>         }
>
>         *vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) |
>                              flags);
>         return 1;
> }
>
> <--  snip  -->
>
> If (flags != _PAGE_CACHE_UC_MINUS) we pass garbage from the stack to
> ioremap_change_attr() and/or __pgprot().
>
> Spotted by the Coverity checker.

the fix simplifies the code as we get rid of the 'ret_flags'
complication.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-28 08:15:16 -07:00
..
boot x86, boot: add linked list of struct setup_data 2008-04-26 21:34:42 +02:00
configs x86: add optimized inlining 2008-04-26 17:44:55 +02:00
crypto [CRYPTO] aes-x86-32: Remove unused return code 2008-04-21 10:19:21 +08:00
ia32 x86_64 ia32 ptrace: convert to compat_arch_ptrace 2008-04-26 17:35:47 +02:00
kernel Merge branch 'kvm-updates-2.6.26' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm 2008-04-27 10:13:52 -07:00
kvm KVM: MMU: kvm_pv_mmu_op should not take mmap_sem 2008-04-27 18:21:45 +03:00
lguest x86: replace remaining __FUNCTION__ occurances 2008-04-17 17:40:57 +02:00
lib x86, UML: remove x86-specific implementations of find_first_bit 2008-04-26 19:21:17 +02:00
mach-default
mach-es7000
mach-generic x86: coding style fixes to arch/x86/mach-generic/bigsmp.c 2008-04-17 17:40:48 +02:00
mach-rdc321x x86, rdc321x: remove watchdog file 2008-04-17 17:40:50 +02:00
mach-visws x86: fix compilation error in VisWS 2008-04-24 23:15:44 +02:00
mach-voyager x86: use cpumask function for present, possible, and online cpus 2008-04-26 17:35:47 +02:00
math-emu x86, fpu: split FPU state from task struct - v5 2008-04-19 19:19:55 +02:00
mm x86: PAT fix 2008-04-28 08:15:16 -07:00
oprofile x86: oprofile: remove NR_CPUS arrays in arch/x86/oprofile/nmi_int.c 2008-04-19 19:44:58 +02:00
pci PCI: x86: use generic pci_enable_resources() 2008-04-20 21:47:04 -07:00
power x86: coding style fixes to arch/x86/power/cpu_32.c 2008-04-17 17:40:50 +02:00
vdso x86 vDSO: compile with -g, 64-bit 2008-04-19 19:19:55 +02:00
video x86: remove pointless comments 2008-04-19 19:19:54 +02:00
xen x86: use cpumask function for present, possible, and online cpus 2008-04-26 17:35:47 +02:00
Kconfig x86: KVM guest: add basic paravirt support 2008-04-27 12:00:25 +03:00
Kconfig.cpu x86, bitops: select the generic bitmap search functions 2008-04-26 19:21:17 +02:00
Kconfig.debug x86: add optimized inlining 2008-04-26 17:44:55 +02:00
Makefile x86: add subarch support (for headers) to x86_64 2008-04-17 17:41:01 +02:00
Makefile_32.cpu