|
| 1 | +.. _memory-firewalls: |
| 2 | + |
| 3 | +################ |
| 4 | +Memory Firewalls |
| 5 | +################ |
| 6 | + |
| 7 | +******** |
| 8 | +Overview |
| 9 | +******** |
| 10 | + |
| 11 | +TI System-on-Chips (SoCs) use hardware-backed firewalls to enforce |
| 12 | +access control. Texas Instruments Foundational Security (TIFS) |
| 13 | +configures these firewalls to restrict the components that can access |
| 14 | +specific regions of device-mapped memory. Other components such as |
| 15 | +Open Portable Trusted Execution Environment (OP-TEE), Arm Trusted |
| 16 | +Firmware (ATF), Linux, U-Boot, and user-space programs can request TIFS |
| 17 | +to configure firewalls on their behalf. |
| 18 | + |
| 19 | +Firewalls can restrict access based on: |
| 20 | + |
| 21 | +* **Core**: A53, R5, M4 |
| 22 | +* **Privilege level**: privileged or non-privileged |
| 23 | +* **Security state**: secure or insecure |
| 24 | + |
| 25 | +For example, TIFS might configure a firewall to prevent Linux (running |
| 26 | +on A53) from accessing a memory region reserved for the secure world. |
| 27 | + |
| 28 | +For more information about firewalls, see the Technical Reference |
| 29 | +Manual (TRM) for the specific SoC, the |
| 30 | +`TISCI Firewall API <https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/security/firewall_api.html>`__, |
| 31 | +and the |
| 32 | +`TIFS Firewall FAQ <https://software-dl.ti.com/tisci/esd/latest/6_topic_user_guides/firewall_faq.html>`__. |
| 33 | + |
| 34 | +**************************************** |
| 35 | +What Happens During a Firewall Violation |
| 36 | +**************************************** |
| 37 | + |
| 38 | +When software attempts an unauthorized access to a memory region that |
| 39 | +a firewall protects, the firewall blocks the access and triggers an |
| 40 | +exception. The outcome depends on the type of access: |
| 41 | + |
| 42 | +* **Read access**: The firewall blocks the read. The system continues |
| 43 | + running. |
| 44 | +* **Write access**: The firewall blocks the write and crashes the |
| 45 | + Linux kernel. The system halts. |
| 46 | + |
| 47 | +The kernel crash on write violations stops the offending software |
| 48 | +immediately, preventing further unauthorized access attempts. |
| 49 | + |
| 50 | +TIFS logs information about every firewall exception. The rest of this |
| 51 | +document explains how to trigger exceptions, enable TIFS logs, access |
| 52 | +them, and interpret them. |
| 53 | + |
| 54 | +******************************* |
| 55 | +Triggering a Firewall Exception |
| 56 | +******************************* |
| 57 | + |
| 58 | +To test firewall behavior, use ``k3conf`` to read from or write to a |
| 59 | +protected memory region. |
| 60 | + |
| 61 | +Triggering a read exception: |
| 62 | + |
| 63 | +.. code-block:: console |
| 64 | +
|
| 65 | + k3conf read <addr> [<size>] |
| 66 | +
|
| 67 | +Triggering a write exception (this will crash the kernel): |
| 68 | + |
| 69 | +.. code-block:: console |
| 70 | +
|
| 71 | + k3conf write <addr> <value> |
| 72 | +
|
| 73 | +Replace ``<addr>`` with the address of a firewall-protected region, |
| 74 | +``<size>`` with the number of bytes to read, and ``<value>`` with the |
| 75 | +value to write. |
| 76 | + |
| 77 | +****************** |
| 78 | +Enabling TIFS Logs |
| 79 | +****************** |
| 80 | + |
| 81 | +TIFS does not output logs by default. Enabling TIFS logging requires |
| 82 | +modifying U-Boot source code, recompiling it, and transferring the new |
| 83 | +binaries to the boot partition. |
| 84 | + |
| 85 | +Modify U-Boot Configuration |
| 86 | +=========================== |
| 87 | + |
| 88 | +Open :file:`board/ti/<soc_name>/board-cfg.yaml` in the U-Boot source |
| 89 | +tree. Locate ``trace_dst_enables`` and ``trace_src_enables``, which |
| 90 | +U-Boot sets to ``0x0`` by default. Change these values as follows: |
| 91 | + |
| 92 | +* ``trace_dst_enables``: change from ``0x0`` to ``0xD`` |
| 93 | +* ``trace_src_enables``: change from ``0x0`` to ``0x3F`` |
| 94 | + |
| 95 | +Build and Deploy U-Boot |
| 96 | +======================= |
| 97 | + |
| 98 | +After making these changes, compile U-Boot and transfer the resulting |
| 99 | +binaries to the board's boot partition. See |
| 100 | +:ref:`u-boot-build-guide-build-k3` for build instructions. |
| 101 | + |
| 102 | +******************* |
| 103 | +Accessing TIFS Logs |
| 104 | +******************* |
| 105 | + |
| 106 | +TIFS outputs logs to a separate serial port from the Linux console. |
| 107 | +If the Linux command line is accessible through :file:`/dev/ttyUSB0`, TIFS logs |
| 108 | +are typically accessible through :file:`/dev/ttyUSB1`. However, the exact device |
| 109 | +assignment depends on the hardware setup and the order in which the |
| 110 | +host enumerates USB devices. |
| 111 | + |
| 112 | +Open the TIFS serial port with a terminal emulator to view the logs. |
| 113 | + |
| 114 | +********************** |
| 115 | +Interpreting TIFS Logs |
| 116 | +********************** |
| 117 | + |
| 118 | +For information about interpreting firewall exception logs, see the |
| 119 | +`TIFS Firewall FAQ <https://software-dl.ti.com/tisci/esd/latest/6_topic_user_guides/firewall_faq.html#how-do-i-debug-firewall-issues>`__. |
0 commit comments