[flash_ctrl] update flash info partition access rights - provision_en split into wr_en / rd_en versions - add iso_flash_wr_en to lc_ctrl since its timing is slightly different from provision_en Signed-off-by: Timothy Chen <timothytim@google.com> [flash_ctrl] update access rights Signed-off-by: Timothy Chen <timothytim@google.com>
diff --git a/hw/ip/flash_ctrl/data/flash_ctrl.hjson.tpl b/hw/ip/flash_ctrl/data/flash_ctrl.hjson.tpl index 836f6fc..9ac8c6f 100644 --- a/hw/ip/flash_ctrl/data/flash_ctrl.hjson.tpl +++ b/hw/ip/flash_ctrl/data/flash_ctrl.hjson.tpl
@@ -31,7 +31,21 @@ { struct: "lc_tx", type: "uni", - name: "lc_provision_en", + name: "lc_provision_wr_en", + act: "rcv", + package: "lc_ctrl_pkg" + }, + + { struct: "lc_tx", + type: "uni", + name: "lc_provision_rd_en", + act: "rcv", + package: "lc_ctrl_pkg" + }, + + { struct: "lc_tx", + type: "uni", + name: "lc_iso_flash_wr_en", act: "rcv", package: "lc_ctrl_pkg" },
diff --git a/hw/ip/flash_ctrl/data/flash_ctrl.sv.tpl b/hw/ip/flash_ctrl/data/flash_ctrl.sv.tpl index d907817..749c163 100644 --- a/hw/ip/flash_ctrl/data/flash_ctrl.sv.tpl +++ b/hw/ip/flash_ctrl/data/flash_ctrl.sv.tpl
@@ -13,7 +13,9 @@ input rst_ni, // life cycle interface - lc_ctrl_pkg::lc_tx_t lc_provision_en_i, + lc_ctrl_pkg::lc_tx_t lc_provision_wr_en_i, + lc_ctrl_pkg::lc_tx_t lc_provision_rd_en_i, + lc_ctrl_pkg::lc_tx_t lc_iso_flash_wr_en_i, // Bus Interface input tlul_pkg::tl_h2d_t tl_i, @@ -165,18 +167,38 @@ logic lfsr_en; // life cycle connections - lc_ctrl_pkg::lc_tx_t [FlashLcLast-1:0] lc_provision_en; + lc_ctrl_pkg::lc_tx_t [FlashWrLcLast-1:0] lc_provision_wr_en; + lc_ctrl_pkg::lc_tx_t [FlashRdLcLast-1:0] lc_provision_rd_en; + lc_ctrl_pkg::lc_tx_t lc_iso_flash_wr_en; // synchronize provision enable into local domain prim_lc_sync #( - .NumCopies(int'(FlashLcLast)) - ) u_lc_provision_en_sync ( + .NumCopies(int'(FlashWrLcLast)) + ) u_lc_provision_wr_en_sync ( .clk_i, .rst_ni, - .lc_en_i(lc_provision_en_i), - .lc_en_o(lc_provision_en) + .lc_en_i(lc_provision_wr_en_i), + .lc_en_o(lc_provision_wr_en) ); + prim_lc_sync #( + .NumCopies(int'(FlashRdLcLast)) + ) u_lc_provision_rd_en_sync ( + .clk_i, + .rst_ni, + .lc_en_i(lc_provision_rd_en_i), + .lc_en_o(lc_provision_rd_en) + ); + prim_lc_sync #( + .NumCopies(1) + ) u_lc_iso_flash_en_sync ( + .clk_i, + .rst_ni, + .lc_en_i(lc_iso_flash_wr_en_i), + .lc_en_o(lc_iso_flash_wr_en) + ); + + prim_lfsr #( .DefaultSeed(), .EntropyDw(4), @@ -279,12 +301,21 @@ // hardware interface // software only has privilege to change creator seed when provision enable is set and - // before the the seed is set as valid in otp - assign creator_seed_priv = lc_provision_en[FlashLcCreatorSeedPriv] == lc_ctrl_pkg::On & + // before the the seed is set as valid in otp. + // lc provision write enable is used here as creator assets can only be changed when + // creator secrets are not yet locked. + assign creator_seed_priv = (lc_provision_wr_en[FlashWrLcCreatorSeedPriv] == lc_ctrl_pkg::On) & ~otp_i.seed_valid; // owner seed is under software control and can be modided whenever provision enable is set - assign owner_seed_priv = lc_provision_en[FlashLcOwnerSeedPriv] == lc_ctrl_pkg::On; + // read enable is used here as this is mostly under the control of creator software and just + // needs to be locked out from specific life cycle states. + assign owner_seed_priv = lc_provision_rd_en[FlashRdLcOwnerSeedPriv] == lc_ctrl_pkg::On; + + // the seed is only readable after it has been written and locked. + logic seed_rd_en; + assign seed_rd_en = lc_provision_wr_en[FlashWrLcMgrIf] == lc_ctrl_pkg::Off & + lc_provision_rd_en[FlashRdLcMgrIf] == lc_ctrl_pkg::On; flash_ctrl_lcmgr u_flash_hw_if ( .clk_i, @@ -292,7 +323,7 @@ .init_i(pwrmgr_i.flash_init), .init_done_o(pwrmgr_o.flash_done), - .provision_en_i(lc_provision_en[FlashLcMgrIf] == lc_ctrl_pkg::On), + .provision_en_i(seed_rd_en), // interface to ctrl arb control ports .ctrl_o(hw_ctrl), @@ -553,6 +584,10 @@ % endfor // qualify reg2hw settings with creator / owner privileges + logic iso_flash_wr_en; + assign iso_flash_wr_en = lc_provision_wr_en[FlashWrLcInfoCfg] == lc_ctrl_pkg::On | + lc_iso_flash_wr_en == lc_ctrl_pkg::On; + for(genvar i = 0; i < NumBanks; i++) begin : gen_info_priv_bank for (genvar j = 0; j < InfoTypes; j++) begin : gen_info_priv_type flash_ctrl_info_cfg # ( @@ -562,7 +597,8 @@ .cfgs_i(reg2hw_info_page_cfgs[i][j]), .creator_seed_priv_i(creator_seed_priv), .owner_seed_priv_i(owner_seed_priv), - .provision_en_i(lc_provision_en[FlashLcInfoCfg] == lc_ctrl_pkg::On), + .iso_flash_wr_en_i(iso_flash_wr_en), + .iso_flash_rd_en_i(lc_provision_rd_en[FlashRdLcInfoCfg] == lc_ctrl_pkg::On), .cfgs_o(info_page_cfgs[i][j]) ); end
diff --git a/hw/ip/flash_ctrl/data/flash_ctrl_pkg.sv.tpl b/hw/ip/flash_ctrl/data/flash_ctrl_pkg.sv.tpl index b3bef9a..d5a1b7b 100644 --- a/hw/ip/flash_ctrl/data/flash_ctrl_pkg.sv.tpl +++ b/hw/ip/flash_ctrl/data/flash_ctrl_pkg.sv.tpl
@@ -78,14 +78,21 @@ // parameters for connected components parameter int SeedWidth = 256; - // life cycle provision enable usage - typedef enum logic [2:0] { - FlashLcCreatorSeedPriv, - FlashLcOwnerSeedPriv, - FlashLcMgrIf, - FlashLcInfoCfg, - FlashLcLast - } flash_lc_provision_en_e; + // life cycle provision write enable usage + typedef enum logic [1:0] { + FlashWrLcCreatorSeedPriv, + FlashWrLcMgrIf, + FlashWrLcInfoCfg, + FlashWrLcLast + } flash_lc_provision_wr_en_e; + + // life cycle provision read enable usage + typedef enum logic [1:0] { + FlashRdLcOwnerSeedPriv, + FlashRdLcMgrIf, + FlashRdLcInfoCfg, + FlashRdLcLast + } flash_lc_provision_rd_en_e; // lcmgr phase enum typedef enum logic [1:0] {
diff --git a/hw/ip/flash_ctrl/rtl/flash_ctrl_info_cfg.sv b/hw/ip/flash_ctrl/rtl/flash_ctrl_info_cfg.sv index 1643b07..51d10a3 100644 --- a/hw/ip/flash_ctrl/rtl/flash_ctrl_info_cfg.sv +++ b/hw/ip/flash_ctrl/rtl/flash_ctrl_info_cfg.sv
@@ -14,7 +14,8 @@ input info_page_cfg_t [InfosPerBank-1:0] cfgs_i, input creator_seed_priv_i, input owner_seed_priv_i, - input provision_en_i, + input iso_flash_wr_en_i, + input iso_flash_rd_en_i, output info_page_cfg_t [InfosPerBank-1:0] cfgs_o ); @@ -22,9 +23,9 @@ info_page_cfg_t isolate_pg_cfg; assign isolate_pg_cfg = '{ en: 1'b1, - rd_en: provision_en_i, - prog_en: 1'b1, - erase_en: 1'b1, + rd_en: iso_flash_rd_en_i, + prog_en: iso_flash_wr_en_i, + erase_en: iso_flash_wr_en_i, scramble_en: 1'b1, ecc_en: 1'b1, he_en : 1'b1
diff --git a/hw/ip/lc_ctrl/data/lc_ctrl.hjson b/hw/ip/lc_ctrl/data/lc_ctrl.hjson index 14c38ae..a491a3c 100644 --- a/hw/ip/lc_ctrl/data/lc_ctrl.hjson +++ b/hw/ip/lc_ctrl/data/lc_ctrl.hjson
@@ -191,6 +191,13 @@ } { struct: "lc_tx" type: "uni" + name: "lc_iso_flash_wr_en_o" + act: "req" + default: "lc_ctrl_pkg::Off" + package: "lc_ctrl_pkg" + } + { struct: "lc_tx" + type: "uni" name: "lc_keymgr_en" act: "req" default: "lc_ctrl_pkg::Off"
diff --git a/hw/ip/lc_ctrl/rtl/lc_ctrl.sv b/hw/ip/lc_ctrl/rtl/lc_ctrl.sv index f5416b5..41a2a88 100644 --- a/hw/ip/lc_ctrl/rtl/lc_ctrl.sv +++ b/hw/ip/lc_ctrl/rtl/lc_ctrl.sv
@@ -63,6 +63,7 @@ output lc_tx_t lc_cpu_en_o, output lc_tx_t lc_provision_wr_en_o, output lc_tx_t lc_provision_rd_en_o, + output lc_tx_t lc_iso_flash_wr_en_o, output lc_tx_t lc_keymgr_en_o, output lc_tx_t lc_escalate_en_o, // Request and feedback to/from clock manager and AST. @@ -501,6 +502,7 @@ .lc_cpu_en_o, .lc_provision_wr_en_o, .lc_provision_rd_en_o, + .lc_iso_flash_wr_en_o, .lc_keymgr_en_o, .lc_escalate_en_o, .lc_clk_byp_req_o, @@ -525,6 +527,7 @@ `ASSERT_KNOWN(LcCpuEnKnown_A, lc_cpu_en_o ) `ASSERT_KNOWN(LcProvisionWrEnKnown_A, lc_provision_wr_en_o ) `ASSERT_KNOWN(LcProvisionRdEnKnown_A, lc_provision_rd_en_o ) + `ASSERT_KNOWN(LcIsoFlashWrEnKnown_A, lc_iso_flash_wr_en_o ) `ASSERT_KNOWN(LcKeymgrEnKnown_A, lc_keymgr_en_o ) `ASSERT_KNOWN(LcEscalateEnKnown_A, lc_escalate_en_o ) `ASSERT_KNOWN(LcClkBypReqKnown_A, lc_clk_byp_req_o )
diff --git a/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv b/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv index b66c9a8..0a1f2b3 100644 --- a/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv +++ b/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv
@@ -65,6 +65,7 @@ output lc_tx_t lc_cpu_en_o, output lc_tx_t lc_provision_wr_en_o, output lc_tx_t lc_provision_rd_en_o, + output lc_tx_t lc_iso_flash_wr_en_o, output lc_tx_t lc_keymgr_en_o, output lc_tx_t lc_escalate_en_o, // Request and feedback to/from clock manager and AST. @@ -441,6 +442,7 @@ .lc_cpu_en_o, .lc_provision_wr_en_o, .lc_provision_rd_en_o, + .lc_iso_flash_wr_en_o, .lc_keymgr_en_o, .lc_escalate_en_o, .lc_keymgr_div_o
diff --git a/hw/ip/lc_ctrl/rtl/lc_ctrl_signal_decode.sv b/hw/ip/lc_ctrl/rtl/lc_ctrl_signal_decode.sv index 2f9cf9e..6256640 100644 --- a/hw/ip/lc_ctrl/rtl/lc_ctrl_signal_decode.sv +++ b/hw/ip/lc_ctrl/rtl/lc_ctrl_signal_decode.sv
@@ -35,6 +35,7 @@ output lc_tx_t lc_cpu_en_o, output lc_tx_t lc_provision_wr_en_o, output lc_tx_t lc_provision_rd_en_o, + output lc_tx_t lc_iso_flash_wr_en_o, output lc_tx_t lc_keymgr_en_o, output lc_tx_t lc_escalate_en_o, // State group diversification value for keymgr @@ -51,6 +52,7 @@ lc_tx_t lc_cpu_en_d, lc_cpu_en_q; lc_tx_t lc_provision_wr_en_d, lc_provision_wr_en_q; lc_tx_t lc_provision_rd_en_d, lc_provision_rd_en_q; + lc_tx_t lc_iso_flash_wr_en_d, lc_iso_flash_wr_en_q; lc_tx_t lc_keymgr_en_d, lc_keymgr_en_q; lc_tx_t lc_escalate_en_d, lc_escalate_en_q; lc_keymgr_div_t lc_keymgr_div_d, lc_keymgr_div_q; @@ -63,6 +65,7 @@ lc_cpu_en_d = Off; lc_provision_wr_en_d = Off; lc_provision_rd_en_d = Off; + lc_iso_flash_wr_en_d = Off; lc_keymgr_en_d = Off; lc_escalate_en_d = Off; // Set to invalid diversification value by default. @@ -96,6 +99,7 @@ lc_hw_debug_en_d = On; lc_cpu_en_d = On; lc_keymgr_div_d = RndCnstLcKeymgrDivTest; + lc_iso_flash_wr_en_d = On; end /////////////////////////////////////////////////////////////////// // Enable production functions @@ -155,6 +159,7 @@ assign lc_cpu_en_o = lc_cpu_en_q; assign lc_provision_wr_en_o = lc_provision_wr_en_q; assign lc_provision_rd_en_o = lc_provision_rd_en_q; + assign lc_iso_flash_wr_en_o = lc_iso_flash_wr_en_q; assign lc_keymgr_en_o = lc_keymgr_en_q; assign lc_escalate_en_o = lc_escalate_en_q; assign lc_keymgr_div_o = lc_keymgr_div_q; @@ -167,6 +172,7 @@ lc_cpu_en_q <= Off; lc_provision_wr_en_q <= Off; lc_provision_rd_en_q <= Off; + lc_iso_flash_wr_en_q <= Off; lc_keymgr_en_q <= Off; lc_escalate_en_q <= Off; lc_keymgr_div_q <= RndCnstLcKeymgrDivInv; @@ -177,6 +183,7 @@ lc_cpu_en_q <= lc_cpu_en_d; lc_provision_wr_en_q <= lc_provision_wr_en_d; lc_provision_rd_en_q <= lc_provision_rd_en_d; + lc_iso_flash_wr_en_q <= lc_iso_flash_wr_en_d; lc_keymgr_en_q <= lc_keymgr_en_d; lc_escalate_en_q <= lc_escalate_en_d; lc_keymgr_div_q <= lc_keymgr_div_d;