16 Nov, 2017

1 commit


06 Nov, 2017

1 commit


25 Oct, 2017

1 commit


24 Oct, 2017

1 commit

  • don't use prettyprint_part_size() in create_gpt_partitions_list()
    that avoid to align offset and size to 1 MiB and increase precision for
    start and size.
    This patch avoid the risk to change partition size and lost data during
    rename or swap.

    Signed-off-by: Patrick Delaunay
    Acked-by: Stephen Warren
    Tested-by: Stephen Warren

    Patrick Delaunay
     

16 Oct, 2017

3 commits

  • As the code currently stands, we first check that the length of the
    given command line, along with ip_str/mac_str along with an additional 1
    for the NULL termination will fit within the buffer we have, and if not,
    we return an error. The way this code was originally written however
    left Coverity "unhappy" due to using strcat rather than strncat.
    Switching this to strncat however causes clang to be unhappy that we
    aren't enforcing the "1" portion within strncat. Rather than further
    re-work the code to include a "- 1" in this case as well, make the
    strcat code only be done within the else side of the length test. This
    keeps both clang and Coverity happy.

    Fixes: 48ee0a87bc46 ("cmd/pxe.c: Rework initrd and bootargs handling slightly")
    Signed-off-by: Tom Rini

    Tom Rini
     
  • Last user of this option went away in commit:

    fdc7718999 ("board: usb_a9263: Update to support DT and DM")

    Signed-off-by: Tuomas Tynkkynen

    Tuomas Tynkkynen
     
  • Last user of this option went away in commit:

    fdc7718999 ("board: usb_a9263: Update to support DT and DM")

    Signed-off-by: Tuomas Tynkkynen

    Tuomas Tynkkynen
     

13 Oct, 2017

2 commits


12 Oct, 2017

1 commit

  • When we don't have a real device/image path, such as 'bootefi hello',
    construct a mem-mapped device-path.

    This fixes 'bootefi hello' after devicepath refactoring.

    Fixes: 95c5553ea2 ("efi_loader: refactor boot device and loaded_image handling")
    Signed-off-by: Rob Clark
    Acked-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Rob Clark
     

11 Oct, 2017

1 commit

  • Having this as a 'default y' is rather annoying because it doesn't
    actually compile unless other options are defined in the board header:

    ../cmd/bootm.c: In function 'do_imls_nor':
    ../cmd/bootm.c:330:7: error: 'CONFIG_SYS_MAX_FLASH_BANKS' undeclared (first use in this function); did you mean 'CONFIG_SYS_MAX_FLASH_SECT'?
    i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {

    Make it 'default n' so people who develop new boards that start from a
    blank defconfig have one less compilation failure to debug.

    Signed-off-by: Tuomas Tynkkynen

    Tuomas Tynkkynen
     

09 Oct, 2017

3 commits


07 Oct, 2017

1 commit

  • The recent changes to these files did not completely fix the previous
    issues, or introduced different (minor) issues. In cmd/gpt.c we need to
    dereference str_disk_guid to be sure that malloc worked. In
    cmd/nvedit.c we need to be careful that we can also fit in that leading
    space when adding to the string. And in tools/fit_image.c we need to
    re-work the error handling slightly in fit_import_data() so that we only
    call munmap() once. We have two error paths here, one where we have an
    fd to close and one where we do not. Adjust labels to match this.

    Reported-by: Coverity (CID: 167366, 167367, 167370)
    Signed-off-by: Tom Rini

    Tom Rini
     

06 Oct, 2017

4 commits

  • We cannot leave this uninitialized, set it to 0.

    Reported-by: Coverity (CID: 144426)
    Signed-off-by: Tom Rini

    Tom Rini
     
  • For the initrd portion of handling our bootm arguments we do not have a
    sufficiently long enough buffer for some improbable 64bit cases. Expand
    this buffer to allow for a 64bit address and almost 256MB initrd to be
    used. Make use of strncpy/strncat when constructing the values here
    since we know what the worst case valid values are, length wise.

    Similarly for bootargs themselves, we need to make use of strlen/sizeof
    and strncpy/strncat to ensure that we don't overflow bootargs itself.

    Cc: Simon Glass
    Cc: Alexander Graf
    Reported-by: Coverity (CID: 131256)
    Signed-off-by: Tom Rini

    Tom Rini
     
  • When we have multiple messages provided, we need to be sure that we do
    not exceed the length of our 'message' buffer. In the for loop, make
    sure that pos is not larger than message. Only copy in at most however
    much of the message buffer remains. Finally, if we have not reached the
    end of the message buffer, put in a space and NULL, and if we have,
    ensure the buffer is now NULL termined.

    Reported-by: Coverity (CID: 165116)
    Signed-off-by: Tom Rini

    Tom Rini
     
  • Create a common exit for most of the error handling code in
    do_rename_gpt_parts. Delete the list elements in disk_partitions
    before calling INIT_LIST_HEAD from get_gpt_info() a second time.

    The SIZEOF_MISMATCH error is not addressed, since that problem was
    already fixed by "GPT: incomplete initialization in
    allocate_disk_part".

    Signed-off-by: Alison Chaiken
    Reported-by: Coverity (CID: 167222, 167235, 167237)
    Reviewed-by: Tom Rini

    Alison Chaiken
     

05 Oct, 2017

1 commit


04 Oct, 2017

4 commits

  • U-Boot widely uses error() as a bit noisier variant of printf().

    This macro causes name conflict with the following line in
    include/linux/compiler-gcc.h:

    # define __compiletime_error(message) __attribute__((error(message)))

    This prevents us from using __compiletime_error(), and makes it
    difficult to fully sync BUILD_BUG macros with Linux. (Notice
    Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

    Let's convert error() into now treewide-available pr_err().

    Done with the help of Coccinelle, excluing tools/ directory.

    The semantic patch I used is as follows:

    //
    @@@@
    -error
    +pr_err
    (...)
    //

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Simon Glass
    [trini: Re-run Coccinelle]
    Signed-off-by: Tom Rini

    Masahiro Yamada
     
  • The current code, if there's both an eMMC and an MMC slot available on the
    board, will swap the MMC indices based on whether we booted from the eMMC
    or the MMC. This way, the MMC we're supposed to boot on will always have
    the index 0.

    However, this causes various issues, for example when using other
    components that base their behaviour on the MMC index, such as fastboot.

    Let's remove that hack, and take the opposite approach. The MMC will always
    have the same index, but the bootcmd will pick the same device than the one
    we booted from. This is done through the introduction of the mmc_bootdev
    environment variable that will be filled by the board code based on the
    boot device informations we can get from the SoC.

    In order to not introduce regressions, we also need to adjust the fastboot
    MMC device and the environment device in order to set it to the eMMC, over
    the MMC, like it used to be the case.

    Tested-by: Chen-Yu Tsai
    Signed-off-by: Maxime Ripard

    Maxime Ripard
     
  • CONFIG_RANDOM_UUID is used by the GPT command to generate random UUID when
    none are provided.

    Move that option to Kconfig.

    Reviewed-by: Tom Rini
    Reviewed-by: Jagan Teki
    Signed-off-by: Maxime Ripard

    Maxime Ripard
     
  • Fastboot need a bunch of options to be operating properly, such as the
    g_dnl gadget, the fastboot command, and some options that make sense. Since
    fastboot is now part of Kconfig, make sure we have them right.

    That will also reduce the boilerplate in the defconfigs.

    Reviewed-by: Łukasz Majewski
    Reviewed-by: Simon Glass
    Signed-off-by: Maxime Ripard

    Maxime Ripard
     

03 Oct, 2017

1 commit


01 Oct, 2017

1 commit


27 Sep, 2017

1 commit

  • memset(newpart, '\0', sizeof(newpart));
    only initializes the firest 4 or 8 bytes of *newpart and not the whole
    structure disk_part.

    We should use sizeof(struct disk_part).

    Instead of malloc and memset we can use calloc.

    Identified by cppcheck.

    Fixes: 09a49930e41 GPT: read partition table from device into a data structure
    Reported-by: Coverity (CID: 167228)
    Cc: Stefan Roese
    Signed-off-by: Heinrich Schuchardt
    Reviewed-by: Stefan Roese
    Reviewed-by: Simon Glass

    Heinrich Schuchardt
     

21 Sep, 2017

2 commits

  • efi_exit() already restores gd, so we shouldn't EFI_EXIT() on the
    otherside of the longjmp().

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • ad503ffe9c6 efi_loader: refactor boot device and loaded_image handling
    leads to an error when building with CONFIG_CMD_BOOTEFI_SELFTEST=y
    This patch fixes the problem.

    Fixes: ad503ffe9c6 efi_loader: refactor boot device and loaded_image handling
    Signed-off-by: Heinrich Schuchardt
    Reviewed-by: Rob Clark
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

20 Sep, 2017

3 commits

  • Similar to a "real" UEFI implementation, the bootmgr looks at the
    BootOrder and BootXXXX variables to try to find an EFI payload to load
    and boot. This is added as a sub-command of bootefi.

    The idea is that the distro bootcmd would first try loading a payload
    via the bootmgr, and then if that fails (ie. first boot or corrupted
    EFI variables) it would fallback to loading bootaa64.efi. (Which
    would then load fallback.efi which would look for \EFI\*\boot.csv and
    populate BootOrder and BootXXXX based on what it found.)

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • Add EFI variable support, mapping to u-boot environment variables.
    Variables are pretty important for setting up boot order, among other
    things. If the board supports saveenv, then it will be called in
    ExitBootServices() to persist variables set by the efi payload. (For
    example, fallback.efi configuring BootOrder and BootXXXX load-option
    variables.)

    Variables are *not* currently exposed at runtime, post ExitBootServices.
    On boards without a dedicated device for storage, which the loaded OS
    is not trying to also use, this is rather tricky. One idea, at least
    for boards that can persist RAM across reboot, is to keep a "journal"
    of modified variables in RAM, and then turn halt into a reboot into
    u-boot, plus store variables, plus halt. Whatever the solution, it
    likely involves some per-board support.

    Mapping between EFI variables and u-boot variables:

    efi_$guid_$varname = {attributes}(type)value

    For example:

    efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported=
    "{ro,boot,run}(blob)0000000000000000"
    efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_BootOrder=
    "(blob)00010000"

    The attributes are a comma separated list of these possible
    attributes:

    + ro - read-only
    + boot - boot-services access
    + run - runtime access

    NOTE: with current implementation, no variables are available after
    ExitBootServices, and all are persisted (if possible).

    If not specified, the attributes default to "{boot}".

    The required type is one of:

    + utf8 - raw utf8 string
    + blob - arbitrary length hex string

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • Get rid of the hacky fake boot-device and duplicate device-path
    constructing (which needs to match what efi_disk and efi_net do).
    Instead convert over to use efi_device_path helpers to construct
    device-paths, and use that to look up the actual boot device.

    Also, extract out a helper to plug things in properly to the
    loaded_image. In a following patch we'll want to re-use this in
    efi_load_image() to handle the case of loading an image from a
    file_path.

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     

19 Sep, 2017

3 commits

  • A testing framework for the EFI API is provided.
    It can be executed with the 'bootefi selftest' command.

    It is coded in a way that at a later stage we may turn it
    into a standalone EFI application. The current build system
    does not allow this yet.

    All tests use a driver model and are run in three phases:
    setup, execute, teardown.

    A test may be setup and executed at boottime,
    it may be setup at boottime and executed at runtime,
    or it may be setup and executed at runtime.

    After executing all tests the system is reset.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • In scripts/Makefile.lib we build section including helloworld.efi.
    This allows to load the EFI binary with command 'bootefi hello'.

    scripts/Makefile.lib contains explicit references to strings
    containing helloworld and hello_world. This makes it impossible
    to generalize the coding to accomodate additional built in
    EFI binaries.

    Let us rename the variables __efi_hello_world_* to
    __efi_helloworld_*.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Command 'bootefi hello' currently uses CONFIG_SYS_LOAD_ADDR
    as loading address.

    qemu machines have by default 128 MiB RAM.
    CONFIG_SYS_LOAD_ADDR for x86 is 0x20000000 (512 MiB).
    This causes 'bootefi hello' to fail.

    We should use the environment variable loadaddr if available.
    It defaults to 0x1000000 (16 MiB) on qemu_x86.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

16 Sep, 2017

1 commit


15 Sep, 2017

4 commits