![]() ![]() | |||
![]() ![]() | ![]() ![]() | ||
| |||
| Home > Program Trace Macrocell Programmer’s Model > Address comparators > General behavior of address comparators | |||
To define an address comparator:
you program an Address Comparator Value Register with the address to be matched, see Address Comparator Value Registers, ETMACVR1 to ETMACVR16
you program the corresponding Address Comparator Access Type Register with additional information about the required comparison, see Address Comparator Access Type Registers, ETMACTR1 to ETMACTR16. If you want your address comparison to match only if the Context ID also matches you must:
program the Address Comparator Access Type register to define which Context ID comparator to use
program the appropriate Context ID Comparator Value Register, and check the programming of the Context ID Comparator Mask Register, see About the Context ID comparator registers.
In addition, to define an ARC:
program the lower-numbered address comparator with the low address of the required range
program the higher-numbered address comparator with the high address of the required range
program both Address Comparator Access Type Registers with the same values.
The PTM keeps a record of the destination address of the last waypoint, and treats this waypoint destination address as the start address of a block of instructions. Between two waypoints the program flow is continuous. The next waypoint marks the end of the block of instructions, and at that point the PTM can check whether any address comparators matched any address in that block of instructions.
As an example of how this works, consider the following sequence of code execution:
The
instruction at 0x1000 is a direct branch to 0x2000.
The program executes from 0x2000 to 0x2100.
The instruction at 0x2100 is
a direct branch to 0x3000.
If an address comparator matches on address 0x2050,
then when the program flow reaches the waypoint at 0x2100,
the comparators have to determine whether the instruction at address 0x2050 executed.
Since the PTM can determine that the program executed from 0x2000 to 0x2100,
it also determines that the comparator matched.
Because the program executed from 0x2000 to 0x2100,
there was no change in security state or instruction set state in
this block of instructions, and any change in state does not take
effect until after execution of the block is complete.
When processing a new waypoint, the PTM defines the block of instructions executed up to the waypoint from:
The target address of the previous waypoint. This is the start address of the block of instructions.
The address of either:
the current waypoint, if no exception has occurred
the last instruction before the exception.
This is the address of the last instruction successfully executed, and is the end address of the block of instructions.
An instruction block end address might not be the exact address of the waypoint instruction that defines the end of the block, but:
it must not be less than the address of the last successfully executed instruction
it must be less than the address of the instruction that follows the last successfully executed instruction.
This means that a PTM implementation has some flexibility in the addresses used for comparison. See Table 3.2 for more information.
Table 3.2. Permitted instruction block end addresses
| Instruction type [1] | Address | Permitted? | |
|---|---|---|---|
| instruction [2] | Block end | ||
| ARM | 0x1000 | < 0x1000 | No, this is less than the address of the last
instruction, 0x1000. |
0x1000 | 0x1000 | Yes | |
0x1000 | 0x1001 | Yes | |
0x1000 | 0x1002 | Yes | |
0x1000 | 0x1003 | Yes | |
0x1000 | ≥ 0x1004 | No, this is not less than the address of the
next instruction, 0x1004. | |
| 32-bit Thumb | 0x1000 | < 0x1000 | No, this is less than the address of the last
instruction, 0x1000. |
0x1000 | 0x1000 | Yes | |
0x1000 | 0x1001 | Yes | |
0x1000 | 0x1002 | Yes | |
0x1000 | 0x1003 | Yes | |
0x1000 | ≥ 0x1004 | No, this is not less than the address of the
next instruction, 0x1004. | |
| 16-bit Thumb | 0x1000 | < 0x1000 | No, this is less than the address of the last
instruction, 0x1000. |
0x1000 | 0x1000 | Yes | |
0x1000 | 0x1001 | Yes | |
0x1000 | ≥ 0x1002 | No, this is not less than the address of the
next instruction, 0x1002. | |
[1] Instruction set, and instruction length for Thumb instructions. [2] Address of the last instruction executed, see text. | |||
If instruction execution wraps round the top of the memory space then processor operation is unpredictable. If the current waypoint address is less than the previous waypoint address, and no branch or exception has occurred, then instruction execution has wrapped in this way. In this situation, the behavior of address range comparators is implementation specific.
If the processor does not execute any instructions between two waypoints then the comparators are not affected by the second waypoint. Examples of where no instructions are executed between two waypoints are:
if an exception follows immediately after another exception
if a processor reset occurs.
The PTM tests all the address comparators whenever it processes a waypoint. The following terms are used when describing the behavior of SACs and ARCs:
The waypoint currently being executed, for which the PTM is testing the comparators.
The last waypoint executed by the processor, before the current waypoint.
The block of instructions executed between the previous waypoint and the current waypoint. This block is defined by two addresses, START and END, defined as:
The destination address of the previous waypoint.
The address of the current waypoint.
When testing a SAC, the address programmed in the Address Comparator Value Register.
When testing an ARC, the address programmed in the lower-numbered Address Comparator Value Register, that defines the low address of the address range. For example, if you are using Address Comparator Value Registers 1 and 2 to define an ARC, CompAddrLow is the address held in Address Comparator Value Register 1.
When testing an ARC, the address programmed in the higher-numbered Address Comparator Value Register, that defines the high address of the address range. For example, if you are using Address Comparator Value Registers 1 and 2 to define an ARC, CompAddrHigh is the address held in Address Comparator Value Register 2.