1. 11 Jun, 2021 1 commit
  2. 09 Jun, 2021 23 commits
  3. 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
  4. 07 Jun, 2021 2 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