• Paul Mackerras's avatar
    [PATCH] sort exception tables · 35b93751
    Paul Mackerras authored
    This patch arranges for the exception tables to be sorted on most
    architectures.  It sorts the main kernel exception table on startup
    and the module exception tables when they get loaded.  The main table
    is sorted reasonably early - just after kmem_cache_init - but that
    could be moved even earlier if necessary.
    
    There is now a lib/extable.c which includes the sort_extable()
    function from arch/ppc/mm/extable.c and the search_extable() function
    from arch/i386/mm/extable.c, which had been copied to many
    architectures.  On many architectures, arch/$(ARCH)/mm/extable.c
    became empty and so I have removed it.
    
    There are four architectures which do things differently from i386:
    alpha, ia64, sparc and sparc64.  Alpha and ia64 store the offset from
    the offset from the exception table entry to the instruction, and
    sparc and sparc64 have range entries in the table.  For those
    architectures I have added empty sort_extable functions.  The
    maintainers for those architectures can implement something better if
    they care to.  As it is they are no worse off than before.
    
    Although it is a moderately sizable patch, it ends up with a net
    reduction of 377 lines in the size of the kernel source. :)
    
    I have tested this on x86 and ppc with a module that uses __get_user
    in an init function, deliberately laid out to get the exception table
    out of order, and it works (whereas it oopsed without this patch).
    35b93751
extable.c 1.22 KB