]> xenbits.xensource.com Git - people/royger/linux-2.6.18-xen.git/commit
linux-2.6.18/x86: replace order-based range checking of M2P table by linear one
authorJan Beulich <jbeulich@novell.com>
Mon, 25 Jul 2011 12:48:41 +0000 (13:48 +0100)
committerJan Beulich <jbeulich@novell.com>
Mon, 25 Jul 2011 12:48:41 +0000 (13:48 +0100)
commitedd166a6d82340ff6bd09c70efb052e76e072b11
tree43f53dfa8ee4ffdb852db21ef4514479fa0a507c
parent2a0c5a262fb7555cb0a8c837e2118ad009ccc8f1
linux-2.6.18/x86: replace order-based range checking of M2P table by linear one

The order-based approach is not only less efficient (requiring a shift
and a compare, typical generated code looking like this

        mov     eax, [machine_to_phys_order]
        mov     ecx, eax
        shr     ebx, cl
        test    ebx, ebx
        jnz     ...

whereas a direct check requires just a compare, like in

        cmp     ebx, [machine_to_phys_nr]
        jae     ...

), but also slightly dangerous in the 32-on-64 case - the element
address calculation can wrap if the next power of two boundary is
sufficiently far away from the actual upper limit of the table, and
hence can result in user space addresses being accessed (with it being
unknown what may actually be mapped there).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
arch/i386/mach-xen/setup.c
arch/x86_64/kernel/head64-xen.c
arch/x86_64/mm/init-xen.c
include/asm-i386/mach-xen/asm/maddr.h
include/asm-x86_64/mach-xen/asm/maddr.h