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