summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* bootm: Fix duplicate debugging in bootm_process_cmdline()Simon Glass2021-03-021-1/+1
| | | | | | | These two returns use the same string so are not distinguishable with LOG_ERROR_RETURN. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: Drop duplicate 'Jumping to U-Boot' messageSimon Glass2021-03-021-2/+1
| | | | | | | | | This is printed twice but we only need one message, since there is very little processing in between them. Drop the second one, since all branches of the switch() already have output. Update the U-Boot message to include the phase being jumped to. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: kbd: Also accept keyboards with Interrupt OUT endpointStefan Brüns2021-02-261-9/+14
| | | | | | | | | | | | The OUT endpoint can just be ignored as it is not used, just as the corresponding Set_Report request for IN-only interfaces. E.g. the Linux gadget hid keyboard also provides an interrupt endpoint. Also cleanup confusing debug messages like "found set protocol", which is printed when a keyboard device is found, while the Set_Protocol request is issued quite some time later. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* Kconfig: SPL_FIT_SIGNATURE requires SPL_LOAD_FITKlaus Heinrich Kiwi2021-02-241-0/+1
| | | | | | | | Having the ability to support firmware FIT signatures on the SPL sounds not so useful if the SPL is not supporting to load a (U-boot) firmware as a FIT image. Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
* Kconfig: SPL_FIT_SIGNATURE selects FIT_SIGNATUREKlaus Heinrich Kiwi2021-02-241-0/+1
| | | | | | | | | Selecting SPL_FIT_SIGNATURE (without selecting U-boot proper verified boot first) breaks the build due to CONFIG_FIT_SIGNATURE_MAX_SIZE being undefined, in addition to Kconfig warnings on RSA and IMAGE_SIGN_INFO unmet dependencies. Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
* cmd: fdt: skip board specific fixup using env variableWasim Khan2021-02-241-5/+12
| | | | | | | | | | Sometimes it is useful to boot OS with already fixed-up device tree. Check for env variable 'skip_board_fixup' before calling ft_board_setup(). Current behaviour is unchanged, additionally user can set skip_board_fixup to 1 to skip the fixup. Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
* Merge tag 'video-for-v2021.04-rc3' of ↵Tom Rini2021-02-221-2/+2
|\ | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-video - splash_source warning fix when building with 64-bit toolchains - lq123p1jx31 and nv101wxmn51 compatible in simple panel driver - remove not used mb862xx driver - add Himax HX8238D panel driver - s/video_uc_platdata/video_uc_plat/
| * common: splash_source: fix -Wint-to-pointer-cast warningJaehoon Chung2021-02-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix -Wint-to-pointer-cast warning common/splash_source.c: In function 'splash_load_raw': common/splash_source.c:100:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 100 | bmp_hdr = (struct bmp_header *)bmp_load_addr; | ^ common/splash_source.c: In function 'splash_sf_read_raw': common/splash_source.c:39:47: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 39 | return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr); | ^ Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | fdt/sunxi: Remove OF_STDOUT_PATHAndre Przywara2021-02-191-8/+1
|/ | | | | | | | | | | | | | | | | | | | | | OF_STDOUT_PATH was meant to hold the devicetree path to the serial console, to be put into the linux,stdout-path property of the chosen node. The only user of that was sunxi, and it was actually wrong for years there: the paths hardcoded in sunxi_common.h were not matching the DTs, evident by the leading 0's in nodenames, which have been removed years ago. On top of that, "linux,stdout-path" is now deprecated for a while (Linux commit 2a9d832cc9aae from November 2014), and also all modern DTs (including those included in U-Boot) carry a "stdout-path" property already. So remove the stanza from sunxi_common.h, and, since this was the last user, also remove the associated bits from the rest of U-Boot. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge branch '2021-02-18-SPL-FIT-OP-TEE-Linux-improvements'Tom Rini2021-02-181-125/+136
|\ | | | | | | - Improve interactions between SPL / OP-TEE and Linux in FIT images
| * spl: fit: Load devicetree when a Linux payload is foundAlexandru Gagniuc2021-02-171-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a FIT config specifies a devicetree, we should load it, no questions asked. In the case of the "simple" FIT loading path, a difficulty arises in selecting the load address of the FDT. The default FDT location is right after the "kernel" or "firmware" image. However, if that is an OP-TEE image, then the FDT may end up in secure DRAM, and not be accessible to normal world kernels. Although the best solution is to be more careful about the FDT address, a viable workaround is to only append the FDT after a u-boot or Linux image. This is identical to the previous logic, except that FDT loading is extended to IH_OS_LINUX images. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
| * spl: fit: Replace #ifdef blocks with more readable constructsAlexandru Gagniuc2021-02-171-29/+24
| | | | | | | | | | | | | | | | | | | | Use the IS_ENABLED() macro to control code flow, instead of the caveman approach of sprinkling #ifdefs. Code size is not affected, as the linker garbage-collects unused functions. However, readability is improved significantly. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * spl: fit: Only look up FIT configuration node onceAlexandru Gagniuc2021-02-171-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | The configuration node a sub node under "/configurations", which describes the components to load from "/images". We only need to locate this node once. However, for each component, spl_fit_get_image_name() would parse the FIT image, looking for the correct node. Such work duplication is not necessary. Instead, once the node is found, cache it, and re-use it. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * spl: fit: Remove useless loop in spl_fit_get_image_name()Alexandru Gagniuc2021-02-171-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a desired configuration is not found, conf_node will have a negative value. Thus the for loop will start at the root "/" node of the image, print the "/description" property, and stop. It appears the intent of the loop was to print the names of the subnodes under "/configurations". We would need the offset to the "/configurations" node, which is abstracted by fit_find_config_node(). This change agrees that abstracting the node offset is the correct design, and we shouldn't be parsing the configurations manually. Thus the loop in spl_fit_get_image_name() is useless. Remove it. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * spl: fit: Pass FIT context via a structure pointerAlexandru Gagniuc2021-02-171-58/+43
| | | | | | | | | | | | | | | | | | | | | | | | Several loose arguments describe the FIT image. They are thus related, and it makes sense to pass them together, in a structure. Examples include the FIT blob pointer, offset to FDT nodes, and the offset to external data. Use a spl_fit_info structure to group these parameters. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * spl: fit: Factor out FIT parsing and use a context structAlexandru Gagniuc2021-02-171-30/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logical steps in spl_load_simple_fit() are difficult to follow. I think the long comments, ifdefs, and ungodly number of variables seriously affect the readability. In particular, it violates section 6 of the coding style, paragraphs (3), and (4). The purpose of this patch is to improve the situation by - Factoring out initialization and parsing to separate functions - Reduce the number of variables by using a context structure This change introduces no functional changes. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * spl: fit: Drop 'length' argument to board_spl_fit_post_load()Alexandru Gagniuc2021-02-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The size is derived from the FIT image itself. Any alignment requirements are machine-specific and known by the board code. Thus the total length can be derived from the FIT image and knowledge of the platform. The 'length' argument is redundant. Remove it. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org> CC: Matt Porter <mporter@konsulko.com>
* | dm: Introduce xxx_get_dma_range()Nicolas Saenz Julienne2021-02-181-0/+73
|/ | | | | | | | | | | | | | | | Add the following functions to get a specific device's DMA ranges: - dev_get_dma_range() - ofnode_get_dma_range() - of_get_dma_range() - fdt_get_dma_range() They are specially useful in oder to be able validate a physical address space range into a bus's and to convert addresses from and to address spaces. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
* usb: kbd: destroy device after console is stoppedAndy Shevchenko2021-02-161-8/+8
| | | | | | | | | | | | | | | | In case of IOMUX enabled it assumes that console devices in the list are available to get them stopped properly via ->stop() callback. However, the USB keyboard driver violates this assumption and tries to play tricks so the device get destroyed while being listed as an active console. Swap the order of device deregistration and IOMUX update along with converting to use iomux_replace_device() jelper to avoid the use-after-free. Fixes: 3cbcb2892809 ("usb: Fix usb_kbd_deregister when console-muxing is used") Fixes: 8a8348703081 ("dm: usb: Add a remove() method for USB keyboards") Reported-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* IOMUX: Introduce iomux_replace_device()Andy Shevchenko2021-02-161-0/+33
| | | | | | | | Some console devices may appear or disappear at run time. In order to support such a hotplug mechanism introduce a new iomux_replace_device() helper to update the list of devices without altering environment. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* IOMUX: Split out for_each_console_dev() helper macroAndy Shevchenko2021-02-162-13/+6
| | | | | | | | It is not only less lines of code, but also better readability when new macro is being in use. Introduce for_each_console_dev() helper macro and convert current users to it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* IOMUX: Split out iomux_match_device() helperAndy Shevchenko2021-02-162-17/+17
| | | | | | Deduplicate the code used in a few places by splitting out a common helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* IOMUX: Switch to use stdio_file_to_flags()Andy Shevchenko2021-02-161-9/+2
| | | | | | Deduplicate code by replacing with stdio_file_to_flags() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* console: Set file and devices at one goAndy Shevchenko2021-02-161-10/+12
| | | | | | | Logical continuation of the change that brought console_devices_set() is to unify console_setfile() with it and replace in the callers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* console: Set console device counter in console_devices_set()Andy Shevchenko2021-02-161-0/+1
| | | | | | | | console_devices_set() missed the console device counter to be set correctly. Fixes: 45375adc9799 ("console: add function console_devices_set") Cc: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* console: Switch to use stdio_file_to_flags()Andy Shevchenko2021-02-161-11/+3
| | | | | | Deduplicate code by replacing with stdio_file_to_flags() helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* stdio: Introduce a new helper stdio_file_to_flags()Andy Shevchenko2021-02-161-0/+13
| | | | | | Let's deduplicate existing copies by splitting off to a new helper. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* stdio: Split out nulldev_register() and move it under #ifAndy Shevchenko2021-02-161-12/+21
| | | | | | | It's possible that NULLDEV can be disabled while it makes leftovers, move entire device under #if. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* stdio: Get rid of dead code, i.e. stdio_deregister()Andy Shevchenko2021-02-161-11/+0
| | | | | | | | | Nobody is using stdio_deregister(), remove for good. Note, even its parameters are not consistent with stdio_register(). So, if anyone want to introduce this again, better with some consistency. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* image: Check for unit addresses in FITsSimon Glass2021-02-151-4/+52
| | | | | | | | | | | | Using unit addresses in a FIT is a security risk. Add a check for this and disallow it. CVE-2021-27138 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
* image: Add an option to do a full check of the FITSimon Glass2021-02-152-0/+36
| | | | | | | | | | | | | | Some strange modifications of the FIT can introduce security risks. Add an option to check it thoroughly, using libfdt's fdt_check_full() function. Enable this by default if signature verification is enabled. CVE-2021-27097 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
* image: Adjust the workings of fit_check_format()Simon Glass2021-02-154-32/+26
| | | | | | | | | | | | | | | | | At present this function does not accept a size for the FIT. This means that it must be read from the FIT itself, introducing potential security risk. Update the function to include a size parameter, which can be invalid, in which case fit_check_format() calculates it. For now no callers pass the size, but this can be updated later. Also adjust the return value to an error code so that all the different types of problems can be distinguished by the user. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
* fit: Don't allow verification of images with @ nodesSimon Glass2021-02-152-7/+35
| | | | | | | | | | | | | | | | | | When searching for a node called 'fred', any unit address appended to the name is ignored by libfdt, meaning that 'fred' can match 'fred@1'. This means that we cannot be sure that the node originally intended is the one that is used. Disallow use of nodes with unit addresses. Update the forge test also, since it uses @ addresses. CVE-2021-27138 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
* fdt_region: Check for a single root node of the correct nameSimon Glass2021-02-151-0/+11
| | | | | | | | | | | | | | | | | At present fdt_find_regions() assumes that the FIT is a valid devicetree. If the FIT has two root nodes this is currently not detected in this function, nor does libfdt's fdt_check_full() notice. Also it is possible for the root node to have a name even though it should not. Add checks for these and return -FDT_ERR_BADSTRUCTURE if a problem is detected. CVE-2021-27097 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
* common: Drop asm/global_data.h from common headerSimon Glass2021-02-0240-1/+40
| | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* common: Kconfig.boot: Add FIT_PRINT config optionRavik Hasija2021-02-012-2/+8
| | | | | | | Config allows to disable printing contents of fitImage to optimize boottime. Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* x86: spl: Add a function to find the text baseSimon Glass2021-02-011-0/+6
| | | | | | | | | | | It is useful to know the TEXT_BASE value for the image being loaded in TPL/SPL. Add a new spl_get_image_text_base() function to handle this. Make use of this in the x86 SPL handler, instead of having the logic there. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dfu: add support for the dfu_alt_info reintialization from the flashed scriptMarek Szyprowski2021-01-311-0/+3
| | | | | | | | | Reinitialize DFU USB gadget after flashing the 'SCRIPT' entity to ensure that the potential changes to the 'dfu_alt_info' environment variable are applied. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> [lukma - I've moved the bool retry to avoid build (CI) errors]
* avb: AVB_VERIFY depends on MMCHeinrich Schuchardt2021-01-291-0/+1
| | | | | | | AVB Verified Boot uses functions related to MMC. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Igor Opaniuk <igor.opaniuk@foundries.io>
* autoboot: fix illegal memory access when stop key and delay key are emptyYuezhang.Mo@sony.com2021-01-271-3/+3
| | | | | | | | | | If both stop key and delay key are empty, the length of these keys is 0. The subtraction operation will cause the u_int type variable to overflow, will cause illegal memory access in key input loop. This commit fixes this bug by using int type instead of u_init. Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* bloblist: Add missing tag namesSimon Glass2021-01-271-0/+6
| | | | | | | Add tag names for recently added types. Fixes: d2cb7a22da0 (x86: Allow putting some tables in the bloblist) Signed-off-by: Simon Glass <sjg@chromium.org>
* bloblist: Support relocating to a larger spaceSimon Glass2021-01-273-4/+27
| | | | | | | | | | Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables. Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: Add functions for next and previous phaseSimon Glass2021-01-271-1/+1
| | | | | | | | | | | | | | | It is useful to be able to figure out which phase we are loading next and which phase we came from. Add some functions to handle this as well as returning the name of a phase. This allows messages like "Booting to x" where x is the next phase. At present, TPL says 'Jumping to U-Boot' at the end, when in fact it is jumping to SPL. This is confusing, so use the new functions to correct this. Tests for this will come with an upcoming minor SPL test refactor. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: fit-sig: Fix error message in fit_config_verify_sig()Alexandru Gagniuc2021-01-271-1/+1
| | | | | | | | | | | | | | In fit_config_verify_sig(), when no 'signature*' subnode exists in the configuration node, the fdt_for_each_subnode() loop is a no-op. Therefore, no error flags are set, and 'err_,sg' is not populated with an error string. This is incorrect behavior. Populate err_msg to indicate that no 'signature' is found, before entering the loop. The first call to fit_image_verify_sig() will override clear err_msg, or set it to a more specific message. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* bootcount: allow to use this feature on TPLPhilippe Reynes2021-01-272-2/+11
| | | | | | | | This commit add an option TPL_BOOTCOUNT_LIMIT to use bootcount on TPL. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* sunxi: support loading with SPL > 32KBAndre Przywara2021-01-251-1/+2
| | | | | | | | | | | | | | | | H616 supports and needs bigger SPL than 32 KiB, mostly due to big DRAM driver and need for PMIC configuration, which pulls several drivers which are not needed otherwise. spl_mmc_get_uboot_raw_sector() will now compare pre-configured size with that, reported in SPL header. If size in header is bigger, it will use that value instead. In the process of function rework, also add missing function argument. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Reviewed-by: Samuel Holland <samuel@sholland.org>
* sunxi: Introduce common symbol for H6 like SoCsJernej Skrabec2021-01-251-2/+2
| | | | | | | | | | | | | It turns out that there are at least 2 other SoCs which have basically the same memory map, similar clocks and other features as H6. It's very likely that we'll see more such SoCs in the future. In order to ease porting to new SoCs and lower ifdef clutter, introduce common symbol for them. Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Reviewed-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
* image-fit: Fix FIT_CIPHER linkingJoel Stanley2021-01-222-14/+15
| | | | | | | | | | | | | When CONFIG_FIT_CIPHER=y and CONFIG_FIT_SIGNATURE=n is there is no implementation of image_get_host_blob for mkimage/dumpimage: /usr/bin/ld: tools/common/image-cipher.o: in function `fit_image_decrypt_data': image-cipher.c:(.text+0x9a): undefined reference to `image_get_host_blob' Move the implementation to a common file so it can be shaed between image-cipher.c and image-fit-sig.c. Signed-off-by: Joel Stanley <joel@jms.id.au>
* common: Makefile: drop duplicated linePeng Fan2021-01-161-1/+0
| | | | | | | | obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o is there, no need obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* console: cosmetics: remove #if 0Patrick Delaunay2021-01-161-10/+0
| | | | | | | Remove the #if 0 present since the first version of console.c Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>