1. 09 Jun, 2021 15 commits
  2. 08 Jun, 2021 14 commits
    • Tom Rini's avatar
      Merge branch '2021-06-08-display-and-logging-updates' into next · da292432
      Tom Rini authored
      To quote Simon, first for the display changes:
      At present we have two ways of showing a hex dump. Once has been in
      U-Boot since the dawn of time and the other was recently added from
      Linux.
      
      They both have their own unique features.
      
      This series makes a few changes to bring them closer together. It also
      adds support for logging a buffer, which is useful since it can put it
      through the same log drivers as other logging output.
      
      Also it adds tests, so we can check the behaviour.
      
      And then the logging changes:
      At present when logging is not enabled, all log() calls become nops.
      This does not seem right, since if the log level is high enough then
      there should be some sort of message. So in that case, this series
      updates it to print the message if the log level is above LOGL_INFO.
      
      This mimics the behaviour for the log_...() macros like log_debug() and
      log_info(), so we can drop the special case for these.
      
      Also the current implementation does not support multiple log calls on
      the same line nicely. The tags are repeated so the line is very hard to
      read.  This series adds that as a new feature.
      da292432
    • Simon Glass's avatar
      log: Convert log values to printf() if not enabled · e1cbd916
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      At present if logging not enabled, log_info() becomes a nop. But we want
      log output at the 'info' level to be akin to printf(). Update the macro to
      pass the output straight to printf() in this case.
      
      This mimics the behaviour for the log_...() macros like log_debug() and
      log_info(), so we can drop the special case for these.
      
      Add new tests to cover this case.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      e1cbd916
    • Simon Glass's avatar
      sandbox: log: Avoid build error with !CONFIG_LOG · 8d9bb98f
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      The pr_cont_test.c test requires CONFIG_LOG since it directly accesses
      fields in global_data that require it. Move the test into the CONFIG_LOG
      condition to avoid build errors.
      
      Enable CONFIG_LOG on sandbox (not sandbox_spl, etc.) so that we still run
      this test. This requires resyncing of the configs.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      8d9bb98f
    • Simon Glass's avatar
      log: Add support for logging a buffer · 58b4b713
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      The print_buffer() function is very useful for debugging. Add a version
      of this in the log system also.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      58b4b713
    • Simon Glass's avatar
      display_options: Split print_buffer() into two functions · 0cceb99a
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      At present print_buffer() outputs a hex dump but it is not possible to
      place this dump in a string. Refactor it into a top-level function which
      does the printing and a utility function that dumps a line into a string.
      This makes the code more generally useful.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      0cceb99a
    • Simon Glass's avatar
      hexdump: Allow ctrl-c to interrupt output · 735dd6ef
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      If a long hexdump is initated the user may wish to interrupt it. Add
      support for this.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      735dd6ef
    • Simon Glass's avatar
      hexdump: Support any rowsize · 5d6d2b88
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      At present print_hex_dump() only supports either 16- or 32-byte lines.
      With U-Boot we want to support any line length up to a maximum of 64.
      Update the function to support this, with 0 defaulting to 16, as with
      print_buffer().
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      5d6d2b88
    • Simon Glass's avatar
      hexdump: Add support for sandbox · 19edf139
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      The current implementation outputs an address as a pointer. Update the
      code to use an address instead, respecting the 32/64 nature of the CPU.
      
      Add some initial tests copied from print_test_display_buffer(), just the
      ones that can pass with the current implementation.
      
      Note that for this case print_hex_dump() and print_bufffer() produce the
      same result. For now the tests are duplicated sine we have separate
      functions.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      19edf139
    • Simon Glass's avatar
      hexdump: Move API to header file · 2f410fe5
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      Move the comments to the header file so people can find the function info
      without digging in the implementation. Fix up the code style and add an
      enum for the first arg.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      2f410fe5
    • Simon Glass's avatar
      display_options: Drop two spaces before the ASCII column · c7b16d83
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      At present with print_buffer() U-Boot shows four spaces between the hex
      and ASCII data. Two seems enough and matches print_hex_dump(). Change it.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      c7b16d83
    • Simon Glass's avatar
      test: Add a test for print_buffer() · c614ddf2
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      Add a test for this function, to cover the various features. Expand the
      expect_str length to take acount of the ~300-bytes lines generated in one
      case.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      c614ddf2
    • Simon Glass's avatar
      test: Convert print tests to use ut framework · fbb99dce
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      This test predates the test framework in U-Boot. It uses #define DEBUG and
      assert() to check the result. Update it to use the framework so it can
      report failure constitent with other tests.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      fbb99dce
    • Simon Glass's avatar
      test: Detect when expect_str is too small · 090d664e
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      If a line of more than 256 bytes is generated, the test will fail but the
      reason is not clear. Add a check for this condition and print a helpful
      message.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      090d664e
    • Simon Glass's avatar
      console: Report an error when output buffer is exhausted · c1a2bb4f
      Simon Glass authored and Tom Rini's avatar Tom Rini committed
      
      
      If the console output buffer is exhausted, characters are silently dropped
      from the end. Detect this condition and report an error when reading back
      the characters.
      Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      c1a2bb4f
  3. 07 Jun, 2021 11 commits
    • Tom Rini's avatar
      Merge branch '2021-06-07-arm-cache-cp15-improvements' into next · 24e1e884
      Tom Rini authored
      To quote the series author, Patrick Delaunay:
      
      On STM32MP15x platform we can use OP-TEE, loaded in DDR in a region
      protected by a firewall. This region is reserved in the device with
      the "no-map" property as defined in the binding file
      doc/device-tree-bindings/reserved-memory/reserved-memory.txt.
      
      Sometime the platform boot failed in U-Boot on a Cortex A7 access to
      this region (depending of the binary and the issue can change with compiler
      version or with code alignment), then the firewall raise an error,
      for example:
      
      E/TC:0   tzc_it_handler:19 TZC permission failure
      E/TC:0   dump_fail_filter:420 Permission violation on filter 0
      E/TC:0   dump_fail_filter:425 Violation @0xde5c6bf0, non-secure privileged read,
               AXI ID 5c0
      E/TC:0   Panic
      
      After investigation, the forbidden access is a speculative request performed
      by the Cortex A7 because all the DDR is mapped as MEMORY with CACHEABLE
      property.
      
      The issue is solved only when the region reserved by OP-TEE is no more
      mapped in U-Boot as it is already done in Linux kernel.
      
      Tested on DK2 board with OP-TEE 3.12 / TF-A 2.4:
      
      With hard-coded address for OP-TEE reserved memory,
      the error doesn't occur.
      
       void dram_bank_mmu_setup(int bank)
       {
       ....
      
          	for (i = start >> MMU_SECTION_SHIFT;
       	     i < (start >> MMU_SECTION_SHIFT) + (size >> MMU_SECTION_SHIFT);
       	     i++) {
       		option = DCACHE_DEFAULT_OPTION;
       		if (i >= 0xde0)
       			option = INVALID_ENTRY;
       		set_section_dcache(i, option);
       	}
       }
      
      Just by modifying the test on 0xde0 to 0xdf0, the OP-TEE memory protected
      by firewall is mapped cacheable and the error occurs.
      
      I think that it can be a general issue for ARM architecture: the "no-map" tag
      of reserved memory in device should be respected by U-Boot if firewall
      is configured before U-Boot execution.
      
      But I don't propose a generic solution in
      arm/lib/cache-cp15.c:dram_bank_mmu_setup()
      because the device tree parsing done in lmb_init_and_reserve() takes a
      long time when it is executed without data cache.
      24e1e884
    • Patrick Delaunay's avatar
      stm32mp: don't map the reserved region with no-map property · ade4e042
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      No more map the reserved region with "no-map" property by marking
      the corresponding TLB entries with invalid entry (=0) to avoid
      speculative access.
      
      The device tree parsing done in lmb_init_and_reserve() takes a
      long time when it is executed without data cache, so it is called in
      enable_caches() before to disable it.
      
      This patch fixes an issue where predictive read access on secure DDR
      OP-TEE reserved area are caught by firewall.
      
        Series-cc: marex
        Series-cc: pch
        Series-cc: marek.bykowski@gmail.com
        Series-cc: Ard Biesheuvel <ardb@kernel.org>
        Series-cc: Etienne Carriere <etienne.carriere@linaro.org>
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      ade4e042
    • Patrick Delaunay's avatar
      stm32mp: Increase the reserved memory in board_get_usable_ram_top · 7dc6068f
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Add 8M for the U-Boot reserved memory (display, fdt, gd, ...)
      mapped cacheable before relocation.
      
      Without this patch the device tree, located before the MALLOC area
      is not tagged cacheable just after relocation, before mmu reconfiguration.
      
      This patch reduces the duration for device tree parsing in
      lmb_init_and_reserve.
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      7dc6068f
    • Patrick Delaunay's avatar
      image-fdt: save no-map parameter of reserve-memory · f46959ce
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Save the 'no-map' information present in 'reserved-memory' node to allow
      correct handling when the MMU is configured in board to avoid
      speculative access.
      
      This binding is defined in
      doc/device-tree-bindings/reserved-memory/reserved-memory.txt
      
      Additional properties:
      ...
      no-map (optional) - empty property
          - Indicates the operating system must not create a virtual mapping
            of the region as part of its standard mapping of system memory,
            nor permit speculative access to it under any circumstances other
            than under the control of the device driver using the region.
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      f46959ce
    • Patrick Delaunay's avatar
      test: lmb: add test for lmb_reserve_flags · 7d08a3dd
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Add a test to check the management of reserved region with flags.
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      7d08a3dd
    • Patrick Delaunay's avatar
      lmb: add lmb_dump_region() function · 358c7789
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Add lmb_dump_region() function, to simplify lmb_dump_all_force().
      This patch is based on Linux memblock dump function.
      
      An example of bdinfo output is:
      
      .....
      fdt_size    = 0x000146a0
      FB base     = 0xfdd00000
      lmb_dump_all:
       memory.cnt  = 0x1
       memory[0]	[0xc0000000-0xffffffff], 0x40000000 bytes flags: 0
       reserved.cnt  = 0x6
       reserved[0]	[0x10000000-0x10045fff], 0x00046000 bytes flags: 4
       reserved[1]	[0x30000000-0x3003ffff], 0x00040000 bytes flags: 4
       reserved[2]	[0x38000000-0x3800ffff], 0x00010000 bytes flags: 4
       reserved[3]	[0xe8000000-0xefffffff], 0x08000000 bytes flags: 4
       reserved[4]	[0xfbaea344-0xfdffffff], 0x02515cbc bytes flags: 0
       reserved[5]	[0xfe000000-0xffffffff], 0x02000000 bytes flags: 4
      arch_number = 0x00000000
      TLB addr    = 0xfdff0000
      ....
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      358c7789
    • Patrick Delaunay's avatar
      lmb: add lmb_is_reserved_flags · e359a4a5
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Add a new function lmb_is_reserved_flags to check if
      an address is reserved with a specific flags.
      
      This function can be used to check if an address was
      reserved with no-map flags with:
      
      lmb_is_reserved_flags(lmb, addr, LMB_NOMAP);
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      e359a4a5
    • Patrick Delaunay's avatar
      lmb: Add support of flags for no-map properties · 59c0ea5d
      Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
      
      
      Add "flags" in lmb_property to save the "no-map" property of
      reserved region and a new function lmb_reserve_flags() to check
      this flag.
      
      The default allocation use flags = LMB_NONE.
      
      The adjacent reserved memory region are merged only when they have
      the same flags value.
      
      This patch is partially based on flags support done in Linux kernel
      mm/memblock .c (previously lmb.c); it is why LMB_NOMAP = 0x4, it is
      aligned with MEMBLOCK_NOMAP value.
      Signed-off-by: Patrick Delaunay's avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
      Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      59c0ea5d
    • Tom Rini's avatar
      Prepare v2021.07-rc4 · e3b64bed
      Tom Rini authored
      
      Signed-off-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
      e3b64bed
    • Tom Rini's avatar
      configs: Resync with savedefconfig · 80da2453
      Tom Rini authored
      
      
      Rsync all defconfig files using moveconfig.py
      Signed-off-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
      80da2453
    • Tom Rini's avatar