P2.14.3 The AxPROT Firewall

HardImplementIcarus · browser samples / server checksReview the topic

Guard a subordinate with AxPROT. Refuse Non-secure requests to the Secure region and unprivileged writes to the protected one, and never let a refused request through.

Hardware context: The attribute path of an interconnect: write buffers, firewalls, decoders and the stages between. Implement a firewall that refuses Non-secure and unprivileged requests by AxPROT without leaking them.

Lesson P2.14 opened with a decoder that compared addresses and nothing else. This is the block that should have been there. It sits in front of one subordinate and reads AxPROT on every request.

Write module axi_firewall. Addresses 0x0000 to 0x0fff are Secure only. A Non-secure request there gets DECERR: that location does not exist in the Non-secure address space. Addresses 0x1000 to 0x1fff accept writes from privileged code only. An unprivileged write there gets SLVERR: the location exists, but this writer may not change it.

A refused request must never reach the subordinate. Your firewall completes it itself: it drains the write beats, or it sends every read beat. Everything else passes through unchanged, and responses with one ID never overtake each other.

The fixture plays scripts against a subordinate that returns each beat's address as its data. It checks every response the manager gets and counts every refused request that leaks through.

Signals in the Timeline

SignalWidthRole
requests4input of each check
Full specification
The module you write (keep these ports)
module axi_firewall (
  input  logic        aclk,
  input  logic        aresetn,    // active low, asynchronous assert
  // from the manager
  input  logic [3:0]  awid,
  input  logic [31:0] awaddr,
  input  logic [7:0]  awlen,
  input  logic [2:0]  awprot,     // [0] privileged, [1] Non-secure, [2] instruction
  input  logic        awvalid,
  output logic        awready,
  input  logic [31:0] wdata,
  input  logic        wlast,
  input  logic        wvalid,
  output logic        wready,
  output logic [3:0]  bid,
  output logic [1:0]  bresp,
  output logic        bvalid,
  input  logic        bready,
  input  logic [3:0]  arid,
  input  logic [31:0] araddr,
  input  logic [7:0]  arlen,
  input  logic [2:0]  arprot,
  input  logic        arvalid,
  output logic        arready,
  output logic [3:0]  rid,
  output logic [31:0] rdata,
  output logic [1:0]  rresp,
  output logic        rlast,
  output logic        rvalid,
  input  logic        rready,
  // to the subordinate (it has no protection inputs: you are its guard)
  output logic [3:0]  s_awid,
  output logic [31:0] s_awaddr,
  output logic [7:0]  s_awlen,
  output logic        s_awvalid,
  input  logic        s_awready,
  output logic [31:0] s_wdata,
  output logic        s_wlast,
  output logic        s_wvalid,
  input  logic        s_wready,
  input  logic [3:0]  s_bid,
  input  logic [1:0]  s_bresp,
  input  logic        s_bvalid,
  output logic        s_bready,
  output logic [3:0]  s_arid,
  output logic [31:0] s_araddr,
  output logic [7:0]  s_arlen,
  output logic        s_arvalid,
  input  logic        s_arready,
  input  logic [3:0]  s_rid,
  input  logic [31:0] s_rdata,
  input  logic [1:0]  s_rresp,
  input  logic        s_rlast,
  input  logic        s_rvalid,
  output logic        s_rready
);
  // your firewall
endmodule
RequestResponse
Below 0x1000 with AxPROT[1] = 1 (Non-secure)DECERR, from the firewall. A read gets ARLEN + 1 beats, each DECERR, RLAST on the last.
Write from 0x1000 to 0x1fff with AWPROT[0] = 0 (unprivileged)SLVERR, from the firewall, after the last write beat.
Read from 0x1000 to 0x1fff, any privilegePassed to the subordinate.
Anything elsePassed to the subordinate unchanged. Its responses come back unchanged.

The result is {writes_ok[7:0], reads_ok[7:0], beats[15:0], bad[7:0], leaks[3:0], hold[3:0]} in bits 47 to 0. bad counts responses that are wrong, early or have no request. leaks counts refused requests that reached the subordinate. hold counts responses withdrawn or changed before their READY.

The manager keeps up to two writes and two reads outstanding. Two reads with one ID must be answered in order. That holds even when the firewall answers one and the subordinate the other.

Examples

Example 1

Non-Secure Requests to the Secure Region
Input
Writes: ID 3 0x100 3 beats unprivileged Non-secure -> DECERR
Reads: ID 4 0xff0 4 beats privileged Non-secure -> DECERR
BREADY 16'hffff, RREADY 16'hffff, subordinate readies 16'hffff
Output
writes_ok = 1, reads_ok = 1, beats = 4, bad = 0, leaks = 0, hold = 0

Both are refused with DECERR. The read gets four DECERR beats, RLAST on the fourth. Neither request reaches the subordinate.

Example 2

The Protected Region
Input
Writes: ID 5 0x1000 1 beat privileged Secure -> OKAY; ID 5 0x1100 2 beats unprivileged Secure -> SLVERR
Reads: ID 6 0x1100 2 beats unprivileged Secure -> OKAY
BREADY 16'hffff, RREADY 16'hffff, subordinate readies 16'hffff
Output
writes_ok = 2, reads_ok = 1, beats = 2, bad = 0, leaks = 0, hold = 0

The privileged write passes. The unprivileged write gets SLVERR from the firewall. The unprivileged read passes: the rule covers writes only.

Example 3

One ID, Two Answerers
Input
Writes: none
Reads: ID 9 0x3000 2 beats unprivileged Non-secure -> OKAY; ID 9 0x400 3 beats unprivileged Non-secure -> DECERR; ID 9 0x3010 2 beats unprivileged Non-secure -> OKAY
BREADY 16'hffff, RREADY 16'hffff, subordinate readies 16'hffff
Output
writes_ok = 0, reads_ok = 3, beats = 7, bad = 0, leaks = 0, hold = 0

Three reads on ID 9: allowed, refused, allowed. Their beats must come back in that order. So the firewall must not start the next read before the refused one is fully answered.

Constraints and Contract

  • Keep the module name and the ports. Every request is INCR with 4-byte beats; AxLEN goes up to 15.
  • The fixture drives its signals after each rising edge and samples yours just before the next one.
  • Do not reach outside your ports.

Hints

Hint 1

Handle one write and one read at a time. Then a response from you and one from the subordinate can never be out of order.

Hint 2

Decide the verdict when the address is taken, and remember it with the ID and the length.

Hint 3

For a refused write, take every beat until WLAST and only then raise BVALID. For a refused read, count the beats down from ARLEN.

What the grader checks: Your firewall runs eleven scripts against a subordinate that answers OKAY, with stalls on every channel. Every response the manager receives is checked against the policy, and every leak is counted. Passing shows the policy holds on these scripts, not for every possible traffic.

11 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 4 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Non-Secure Requests to the Secure Region

Input
Writes: ID 3 0x100 3 beats unprivileged Non-secure -> DECERR
Reads: ID 4 0xff0 4 beats privileged Non-secure -> DECERR
BREADY 16'hffff, RREADY 16'hffff, subordinate readies 16'hffff
Expected output
writes_ok = 1, reads_ok = 1, beats = 4, bad = 0, leaks = 0, hold = 0

Both are refused with DECERR. The read gets four DECERR beats, RLAST on the fourth. Neither request reaches the subordinate.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus · browser samples / server checks