Skip to content
  • Tejun Heo's avatar
    x86, percpu: setup reserved percpu area for x86_64 · 6b19b0c2
    Tejun Heo authored
    
    
    Impact: fix relocation overflow during module load
    
    x86_64 uses 32bit relocations for symbol access and static percpu
    symbols whether in core or modules must be inside 2GB of the percpu
    segement base which the dynamic percpu allocator doesn't guarantee.
    This patch makes x86_64 reserve PERCPU_MODULE_RESERVE bytes in the
    first chunk so that module percpu areas are always allocated from the
    first chunk which is always inside the relocatable range.
    
    This problem exists for any percpu allocator but is easily triggered
    when using the embedding allocator because the second chunk is located
    beyond 2GB on it.
    
    This patch also changes the meaning of PERCPU_DYNAMIC_RESERVE such
    that it only indicates the size of the area to reserve for dynamic
    allocation as static and dynamic areas can be separate.  New
    PERCPU_DYNAMIC_RESERVED is increased by 4k for both 32 and 64bits as
    the reserved area separation eats away some allocatable space and
    having slightly more headroom (currently between 4 and 8k after
    minimal boot sans module area) makes sense for common case
    performance.
    
    x86_32 can address anywhere from anywhere and doesn't need reserving.
    
    Mike Galbraith first reported the problem first and bisected it to the
    embedding percpu allocator commit.
    
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reported-by: default avatarMike Galbraith <efault@gmx.de>
    Reported-by: default avatarJaswinder Singh Rajput <jaswinder@kernel.org>
    6b19b0c2