27 Apr, 2020

2 commits

  • Previous patch "MLK-21885 lmb: Handle the overlap case for lmb reserve" adds
    the overlap support to lmb reserve. However, u-boot has some places to use the
    lmb_reserve when allocating memory in loading images. If we allowed overlap
    in this function, it means images loading address can overlap each other and
    cause the address check mechanism not work.

    So add another function to allow overlap and only use it for fdt reserved-memory
    nodes. The FDT reserved-memory is ok to merge with other reserved memory, since
    this won't break image loading address check.

    Signed-off-by: Ye Li
    (cherry picked from commit 2109dc2a4da592003ec62820f5bdfb6bd0899805)

    Ye Li
     
  • lmb reserve is used to reserve some memory so that when loading images
    (like kernel, dtb, initrd), images won't be loaded into the reserved memory.

    The problem in current lmb is it does not handle the overlap case. When adding
    a new reserved memory, if the memory region is overlap with regions already been
    added in lmb, it will fail. One example is reserved memory in DTB may overlap with
    u-boot relocate address. lmb reserves the u-boot relocate address firstly, so when
    adding reserved memory from DTB, we will meet failure.

    Actually if we handle the overlap case, we can resolve the overlap by using a max
    common region for the overlap regions. So that this case won't fail.

    Signed-off-by: Ye Li
    Reviewed-by: Peng Fan
    (cherry picked from commit 37d86c68816dffde3dc8dcda5b9d67a195b2f9c2)

    Ye Li
     

06 Feb, 2020

1 commit

  • At present dm/device.h includes the linux-compatible features. This
    requires including linux/compat.h which in turn includes a lot of headers.
    One of these is malloc.h which we thus end up including in every file in
    U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
    which needs to use the system malloc() in some files.

    Move the compatibility features into a separate header file.

    Signed-off-by: Simon Glass

    Simon Glass
     

02 Feb, 2019

1 commit

  • This fixes the automatic lmb initialization and reservation for boards
    with more than one DRAM bank.

    This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load
    files into the firs DRAM bank from fs and via tftp.

    Found-by: Heinrich Schuchardt
    Signed-off-by: Simon Goldschmidt
    Tested-by: Heinrich Schuchardt
    Reviewed-by: Simon Glass

    Simon Goldschmidt
     

26 Jan, 2019

2 commits


17 Jan, 2019

4 commits

  • This fixes CVE-2018-18440 ("insufficient boundary checks in filesystem
    image load") by using lmb to check the load size of a file against
    reserved memory addresses.

    Signed-off-by: Simon Goldschmidt
    Reviewed-by: Simon Glass

    Simon Goldschmidt
     
  • This adds two new functions, lmb_alloc_addr and
    lmb_get_unreserved_size.

    lmb_alloc_addr behaves like lmb_alloc, but it tries to allocate a
    pre-specified address range. Unlike lmb_reserve, this address range
    must be inside one of the memory ranges that has been set up with
    lmb_add.

    lmb_get_unreserved_size returns the number of bytes that can be
    used up to the next reserved region or the end of valid ram. This
    can be 0 if the address passed is reserved.

    Added test for these new functions.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     
  • lmb_add_region handles overlapping regions wrong: instead of merging
    or rejecting to add a new reserved region that overlaps an existing
    one, it just adds the new region.

    Since internally the same function is used for lmb_alloc, change
    lmb_add_region to reject overlapping regions.

    Also, to keep reserved memory correct after 'free', reserved entries
    created by allocating memory must not set their size to a multiple
    of alignment but to the original size. This ensures the reserved
    region is completely removed when the caller calls 'lmb_free', as
    this one takes the same size as passed to 'lmb_alloc' etc.

    Add test to assert this.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     
  • The lmb code fails if base + size of RAM overflows to zero.

    Fix this by calculating end as 'base + size - 1' instead of 'base + size'
    where appropriate.

    Added tests to assert this is fixed.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

25 Oct, 2014

1 commit


09 Aug, 2014

1 commit

  • If a 32-bit system has 2GB of RAM, and the base address of that RAM is
    2GB, then start+size will overflow a 32-bit value (to a value of 0).

    __lmb_alloc_base is affected by this; it calculates the minimum of
    (start+size of RAM) and max_addr. However, when start+size is 0, it
    is always less than max_addr, which causes the value of max_addr not
    to be taken into account when restricting the allocation's location.

    Fix this by calculating start+size separately, and if that calculation
    underflows, using -1 (interpreted as the max unsigned value) as the
    value instead, and then taking the min of that and max_addr. Now that
    start+size doesn't overflow, it's typically large, and max_addr
    dominates the min() call, and is taken into account.

    The user-visible symptom of this bug is that CONFIG_BOOTMAP_SZ is ignored
    on Tegra124 systems with 2GB of RAM, which in turn causes the DT to be
    relocated at the very end of RAM, which the ARM Linux kernel doesn't map
    during early boot, and which causes boot failures. With this fix,
    CONFIG_BOOTMAP_SZ correctly restricts the relocated DT to a much lower
    address, and everything works.

    Signed-off-by: Stephen Warren

    Stephen Warren
     

19 Jul, 2014

1 commit


24 Jul, 2013

1 commit


13 Apr, 2010

1 commit

  • Now that the other architecture-specific lib directories have been
    moved out of the top-level directory there's not much reason to have the
    '_generic' suffix on the common lib directory.

    Signed-off-by: Peter Tyser

    Peter Tyser