Skip to content

Commit bcd2496

Browse files
committed
[cov] Apply asm auto-instrumentation
Reruns the assembly auto-instrumentation tool to generate the coverage markers for newly enabled asm targets. ``` bash util/coverage/asm/run_instrument.sh --apply ``` Change-Id: I69d8e43713fc62a9f3274e95e0302aa881e12e1b Signed-off-by: Yi-Hsuan Deng <[email protected]>
1 parent 85c6257 commit bcd2496

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

sw/device/silicon_creator/lib/flash_exc_handler.S

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,26 @@ flash_exception_handler:
9595
// PRAGMA_COVERAGE: autogen start
9696

9797
// Get the mcause, mask the reason and check that it is LoadAccessFault.
98+
COVERAGE_ASM_AUTOGEN_MARK(t6,1)
9899
csrr a1, mcause
99100
andi a1, a1, 31
100101
li a2, LOAD_ACCESS_FAULT
101102
bne a1, a2, .L_not_a_flash_error
102103

103104
// Check if there is a flash error.
105+
COVERAGE_ASM_AUTOGEN_MARK(t6,2)
104106
li a3, TOP_EARLGREY_FLASH_CTRL_CORE_BASE_ADDR
105107
lw a1, FLASH_CTRL_FAULT_STATUS_REG_OFFSET(a3)
106108
andi a1, a1, PHY_ERRORS
107109
beqz a1, .L_not_a_flash_error
108110

109111
// Clear the flash error.
112+
COVERAGE_ASM_AUTOGEN_MARK(t6,3)
110113
sw x0, FLASH_CTRL_FAULT_STATUS_REG_OFFSET(a3)
111114
// Hardening: check that the error is cleared.
112115
lw a1, FLASH_CTRL_FAULT_STATUS_REG_OFFSET(a3)
113116
beqz a1, .L_flash_fault_handled
117+
COVERAGE_ASM_AUTOGEN_MARK(t6,4)
114118
j .L_not_a_flash_error
115119
unimp
116120
unimp
@@ -140,6 +144,7 @@ flash_exception_handler:
140144
// Where rd' and rs1' are (register_num - 8, ie: rd' of 0 means reg x8).
141145
//
142146

147+
COVERAGE_ASM_AUTOGEN_MARK(t6,5)
143148
csrr a0, mepc
144149
lh a2, 0(a0)
145150
addi a0, a0, OT_HALF_WORD_SIZE
@@ -149,10 +154,12 @@ flash_exception_handler:
149154
bne a3, a1, .L_compressed_trap_instr
150155
// Check if its an uncompressed load instruction by checking that the next
151156
// five bits are zero.
157+
COVERAGE_ASM_AUTOGEN_MARK(t6,6)
152158
srli a3, a2, 2
153159
andi a3, a3, 0x1f
154160
bnez a3, .L_not_a_flash_error
155161
// Get the register number into a3 by masking off the rd field.
162+
COVERAGE_ASM_AUTOGEN_MARK(t6,7)
156163
srli a3, a2, 7
157164
andi a3, a3, 0x1f
158165
// We already added one half word, so for a 32-bit instruction, add another.
@@ -161,15 +168,18 @@ flash_exception_handler:
161168

162169
.L_compressed_trap_instr:
163170
// Check if its a compressed load instruction.
171+
COVERAGE_ASM_AUTOGEN_MARK(t6,8)
164172
bnez a3, .L_not_a_flash_error
165173
// Get the register number into a3 by masking off the rd' field and adding 8.
174+
COVERAGE_ASM_AUTOGEN_MARK(t6,9)
166175
srli a3, a2, 2
167176
andi a3, a3, 7
168177
addi a3, a3, 8
169178

170179
.L_hardened_mepc_check:
171180
// Hardening: double-check that the retval calculation is 4 bytes or fewer
172181
// from the original value of MEPC.
182+
COVERAGE_ASM_AUTOGEN_MARK(t6,10)
173183
addi a1, a1, 1
174184
csrr a2, mepc
175185
sub a2, a0, a2
@@ -179,9 +189,11 @@ flash_exception_handler:
179189
// that register.
180190
// RISCV register x0, aka zero. This register is always const 0, so there
181191
// is nothing to do.
192+
COVERAGE_ASM_AUTOGEN_MARK(t6,11)
182193
beqz a3, .L_flash_fault_done
183194

184195
// All other registers load the value 0xFFFFFFFF as the faulting value.
196+
COVERAGE_ASM_AUTOGEN_MARK(t6,12)
185197
li a2, -1
186198
slli a3, a3, 2
187199
add a3, a3, sp
@@ -190,6 +202,7 @@ flash_exception_handler:
190202
.L_flash_fault_done:
191203
// Exception handler exit and return to C:
192204
// Load the correct MEPC for the next instruction in the current task.
205+
COVERAGE_ASM_AUTOGEN_MARK(t6,13)
193206
csrw mepc, a0
194207

195208
// Restore all registers from the stack and restore SP to its former value.
@@ -239,6 +252,7 @@ flash_exception_handler:
239252
// Note: we _also_ do not restore SP - we'll restart the stack at
240253
// `ram_end - 128`. This allows us to report exceptions after jumping
241254
// to the next stage if the next stage has trashed its SP register.
255+
COVERAGE_ASM_AUTOGEN_MARK(t6,15)
242256
j INTERRUPT_HANDLER
243257
unimp
244258
.size flash_exception_handler, .-flash_exception_handler

sw/device/silicon_creator/rom/rom_epmp_init.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ rom_epmp_init:
6161
// Setup PMP address registers.
6262

6363
// ROM TEXT
64+
COVERAGE_ASM_AUTOGEN_MARK(t6,0)
6465
la t0, _epmp_text_tor_lo
6566
csrw pmpaddr0, t0
6667
la t0, _epmp_text_tor_hi

sw/device/silicon_creator/rom/rom_start.S

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,21 @@ _rom_start_boot:
160160

161161
LABEL_FOR_TEST(kRomStartBootMaybeHalt)
162162
// Check if we should halt here.
163+
COVERAGE_ASM_AUTOGEN_MARK(t6,0)
163164
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
164165
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
165166
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_ROM_EXEC_EN_OFFSET(a0)
166167
bnez t0, .L_exec_en
167168
LABEL_FOR_TEST(kRomStartBootHalted)
168169
.L_halt_loop:
170+
COVERAGE_ASM_AUTOGEN_MARK(t6,1)
169171
wfi
170172
j .L_halt_loop
171173

172174
LABEL_FOR_TEST(kRomStartBootExecEn)
173175
.L_exec_en:
174176
// Enable NMIs from the watchdog timer.
177+
COVERAGE_ASM_AUTOGEN_MARK(t6,2)
175178
li t0, TOP_EARLGREY_RV_CORE_IBEX_CFG_BASE_ADDR
176179
li t1, (1 << RV_CORE_IBEX_NMI_ENABLE_WDOG_EN_BIT)
177180
sw t1, RV_CORE_IBEX_NMI_ENABLE_REG_OFFSET(t0)
@@ -194,6 +197,7 @@ LABEL_FOR_TEST(kRomStartBootExecEn)
194197
beq t0, t1, .L_skip_watchdog_init
195198

196199
// Configure the watchdog's bark and bite thresholds.
200+
COVERAGE_ASM_AUTOGEN_MARK(t6,3)
197201
li t0, TOP_EARLGREY_AON_TIMER_AON_BASE_ADDR
198202
li t1, WDOG_BARK_THOLD
199203
sw t1, AON_TIMER_WDOG_BARK_THOLD_REG_OFFSET(t0)
@@ -207,6 +211,7 @@ LABEL_FOR_TEST(kRomStartStoreT1ToBiteThold)
207211
.L_skip_watchdog_init:
208212

209213
// Configure rstmgr alert and cpu info collection.
214+
COVERAGE_ASM_AUTOGEN_MARK(t6,4)
210215
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
211216
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
212217
lw t0, OTP_CTRL_PARAM_OWNER_SW_CFG_ROM_RSTMGR_INFO_EN_OFFSET(a0)
@@ -215,20 +220,24 @@ LABEL_FOR_TEST(kRomStartStoreT1ToBiteThold)
215220
// Enable alert info collection if enabled in OTP.
216221
andi t2, t0, 0xff
217222
bne t2, t1, .L_skip_rstmgr_alert_info_en
223+
COVERAGE_ASM_AUTOGEN_MARK(t6,5)
218224
li t2, (1 << RSTMGR_ALERT_INFO_CTRL_EN_BIT)
219225
sw t2, RSTMGR_ALERT_INFO_CTRL_REG_OFFSET(a0)
220226
.L_skip_rstmgr_alert_info_en:
221227
// Enable cpu info collection if enabled in OTP.
228+
COVERAGE_ASM_AUTOGEN_MARK(t6,6)
222229
srli t0, t0, 8
223230
andi t2, t0, 0xff
224231
bne t2, t1, .L_skip_rstmgr_cpu_info_en
232+
COVERAGE_ASM_AUTOGEN_MARK(t6,7)
225233
li t2, (1 << RSTMGR_CPU_INFO_CTRL_EN_BIT)
226234
sw t2, RSTMGR_ALERT_INFO_CTRL_REG_OFFSET(a0)
227235
.L_skip_rstmgr_cpu_info_en:
228236

229237
LABEL_FOR_TEST(kRomStartWatchdogEnabled)
230238
// Clear all the machine-defined interrupts, `MEIE`, `MTIE`, and `MSIE` fields
231239
// of `mie`.
240+
COVERAGE_ASM_AUTOGEN_MARK(t6,8)
232241
li t0, 0x00000888
233242
csrc mie, t0
234243

@@ -240,6 +249,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
240249
bne t0, t1, .L_ast_init_end
241250

242251
// Copy the AST configuration from OTP.
252+
COVERAGE_ASM_AUTOGEN_MARK(t6,9)
243253
li a0, (TOP_EARLGREY_AST_BASE_ADDR)
244254
li a1, (TOP_EARLGREY_AST_BASE_ADDR + AST_REGAL_REG_OFFSET + 4)
245255
li a2, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
@@ -250,11 +260,13 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
250260
// Enable jittery clock if not strictly disabled in OTP.
251261
// Use hardcoded MULTIBIT_ASM_BOOL4_TRUE as the enable word to reduce all
252262
// other possible OTP values to true.
263+
COVERAGE_ASM_AUTOGEN_MARK(t6,10)
253264
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
254265
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
255266
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_JITTER_EN_OFFSET(a0)
256267
li t1, MULTIBIT_ASM_BOOL4_FALSE
257268
beq t0, t1, .L_ast_init_end
269+
COVERAGE_ASM_AUTOGEN_MARK(t6,11)
258270
li a0, TOP_EARLGREY_CLKMGR_AON_BASE_ADDR
259271
li t1, MULTIBIT_ASM_BOOL4_TRUE
260272
sw t1, CLKMGR_JITTER_ENABLE_REG_OFFSET(a0)
@@ -264,16 +276,19 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
264276
// CREATOR_SW_CFG_RMA_SPIN_CYCLES to let the transition start and continue
265277
// looping while lc_ctrl is not ready. Reset if the CPU is still executing at
266278
// the end.
279+
COVERAGE_ASM_AUTOGEN_MARK(t6,12)
267280
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
268281
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
269282
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_RMA_SPIN_EN_OFFSET(a0)
270283
li t6, HARDENED_BOOL_TRUE
271284
bne t0, t6, .L_rma_spin_skip
272285

286+
COVERAGE_ASM_AUTOGEN_MARK(t6,13)
273287
li a1, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
274288
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
275289
lw t1, OTP_CTRL_PARAM_CREATOR_SW_CFG_RMA_SPIN_EN_OFFSET(a1)
276290
beq t1, t6, .L_rma_spin_check_straps
291+
COVERAGE_ASM_AUTOGEN_MARK(t6,14)
277292
unimp
278293
unimp
279294
unimp
@@ -289,6 +304,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
289304
// |------------------+----------------+----------------+------------------|
290305
// | Configuration: | Input | Input | Input |
291306
// | | Pull-down | Pull-down | Pull-up |
307+
COVERAGE_ASM_AUTOGEN_MARK(t6,15)
292308
li a0, (TOP_EARLGREY_PINMUX_AON_BASE_ADDR + \
293309
PINMUX_MIO_PAD_ATTR_0_REG_OFFSET)
294310
li t0, (1 << PINMUX_MIO_PAD_ATTR_0_PULL_EN_0_BIT) | \
@@ -312,10 +328,12 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
312328
csrw mcycle, zero
313329
li t0, PINMUX_PAD_ATTR_PROP_CYCLES
314330
.L_rma_strap_pu_spin_cycles_loop:
331+
COVERAGE_ASM_AUTOGEN_MARK(t6,16)
315332
csrr t1, mcycle
316333
bltu t1, t0, .L_rma_strap_pu_spin_cycles_loop
317334

318335
// Read the strap GPIOs and check their value.
336+
COVERAGE_ASM_AUTOGEN_MARK(t6,17)
319337
li a0, TOP_EARLGREY_GPIO_BASE_ADDR
320338
lw t0, GPIO_DATA_IN_REG_OFFSET(a0)
321339
li t5, SW_STRAP_MASK
@@ -325,12 +343,14 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
325343
bne t0, t6, .L_rma_spin_skip
326344

327345
// Double-check the GPIO strap value.
346+
COVERAGE_ASM_AUTOGEN_MARK(t6,18)
328347
li t6, HARDENED_BOOL_TRUE
329348
li a1, TOP_EARLGREY_GPIO_BASE_ADDR
330349
lw t1, GPIO_DATA_IN_REG_OFFSET(a1)
331350
and t1, t1, t5
332351
xor t1, t1, t4
333352
beq t1, t6, .L_rma_spin_init
353+
COVERAGE_ASM_AUTOGEN_MARK(t6,19)
334354
unimp
335355
unimp
336356
unimp
@@ -340,20 +360,24 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
340360
// the lifecycle transition request on JTAG. Since this is a wait
341361
// loop, disable the watchdog.
342362
.L_rma_spin_init:
363+
COVERAGE_ASM_AUTOGEN_MARK(t6,20)
343364
csrw mcycle, zero
344365
li a0, TOP_EARLGREY_AON_TIMER_AON_BASE_ADDR
345366
sw zero, AON_TIMER_WDOG_CTRL_REG_OFFSET(a0)
346367
.L_rma_spin_cycles_loop:
368+
COVERAGE_ASM_AUTOGEN_MARK(t6,21)
347369
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
348370
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
349371
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_RMA_SPIN_CYCLES_OFFSET(a0)
350372
csrr t1, mcycle
351373
bltu t1, t0, .L_rma_spin_cycles_loop
352374
.L_rma_spin_lc_ctrl_loop:
375+
COVERAGE_ASM_AUTOGEN_MARK(t6,22)
353376
li a0, TOP_EARLGREY_LC_CTRL_BASE_ADDR
354377
lw t0, LC_CTRL_STATUS_REG_OFFSET(a0)
355378
andi t0, t0, (1 << LC_CTRL_STATUS_READY_BIT)
356379
beqz t0, .L_rma_spin_lc_ctrl_loop
380+
COVERAGE_ASM_AUTOGEN_MARK(t6,23)
357381
unimp
358382
unimp
359383
unimp
@@ -363,12 +387,14 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
363387
// Skip the `entropy_src` health checks configuration if the
364388
// `RNG_HEALTH_CONFIG_DIGEST` is not programmed. The default digest value is
365389
// 0 given that it is stored in a software OTP partition.
390+
COVERAGE_ASM_AUTOGEN_MARK(t6,24)
366391
li a0, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
367392
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
368393
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_RNG_HEALTH_CONFIG_DIGEST_OFFSET(a0)
369394
beqz t0, .L_entropy_enable
370395

371396
// Copy the entropy source health checks configuration thresholds from OTP.
397+
COVERAGE_ASM_AUTOGEN_MARK(t6,25)
372398
li a0, (TOP_EARLGREY_ENTROPY_SRC_BASE_ADDR + \
373399
ENTROPY_SRC_REPCNT_THRESHOLDS_REG_OFFSET)
374400
li a1, (TOP_EARLGREY_ENTROPY_SRC_BASE_ADDR + \
@@ -379,6 +405,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
379405
call crt_section_copy
380406

381407
// Configure the entropy source health alert threshold.
408+
COVERAGE_ASM_AUTOGEN_MARK(t6,26)
382409
li a0, TOP_EARLGREY_ENTROPY_SRC_BASE_ADDR
383410
li a1, (TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + \
384411
OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET)
@@ -388,6 +415,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
388415
.L_entropy_enable:
389416
// The following sequence enables the minimum level of entropy required to
390417
// initialize memory scrambling, as well as the entropy distribution network.
418+
COVERAGE_ASM_AUTOGEN_MARK(t6,27)
391419
li a0, TOP_EARLGREY_ENTROPY_SRC_BASE_ADDR
392420

393421
// Note for BOOT_ROM initialization the FIPS_ENABLE bit is set to kMultiBitBool4False
@@ -428,6 +456,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
428456
lw t0, OTP_CTRL_PARAM_CREATOR_SW_CFG_SRAM_KEY_RENEW_EN_OFFSET(a0)
429457
li t1, HARDENED_BOOL_FALSE
430458
beq t0, t1, .L_sram_key_renew_skip
459+
COVERAGE_ASM_AUTOGEN_MARK(t6,28)
431460
COVERAGE_ASM_BACKUP_COUNTERS(s10, s11)
432461
li a0, TOP_EARLGREY_SRAM_CTRL_MAIN_REGS_BASE_ADDR
433462
li a1, (1 << SRAM_CTRL_CTRL_RENEW_SCR_KEY_BIT) | (1 << SRAM_CTRL_CTRL_INIT_BIT)
@@ -486,6 +515,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
486515
*/
487516

488517
// Initialize the `.bss` section.
518+
COVERAGE_ASM_AUTOGEN_MARK(t6,30)
489519
la a0, _bss_start
490520
la a1, _bss_end
491521
call crt_section_clear
@@ -497,6 +527,7 @@ LABEL_FOR_TEST(kRomStartWatchdogEnabled)
497527
//
498528
// If an exception fires, the handler is conventionally only allowed to clobber
499529
// memory at addresses below `sp`.
530+
COVERAGE_ASM_AUTOGEN_MARK(t6,31)
500531
la sp, _stack_end
501532

502533
// PRAGMA_COVERAGE: skip start

sw/device/silicon_creator/rom_ext/imm_section/imm_section_start.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ _imm_section_start_boot:
5454
*/
5555

5656
// Clear `MIE` field of `mstatus` (disable interrupts globally).
57+
COVERAGE_ASM_AUTOGEN_MARK(t6,0)
5758
csrci mstatus, 0x8
5859

5960
/**
@@ -80,13 +81,15 @@ _imm_section_start_boot:
8081
* We do this despite zeroing all of SRAM above, so that we still zero `.bss`
8182
* once we've enabled SRAM scrambling.
8283
*/
84+
COVERAGE_ASM_AUTOGEN_MARK(t6,1)
8385
la a0, _bss_start
8486
la a1, _bss_end
8587
jal ra, crt_section_clear
8688

8789
/**
8890
* Restore registers.
8991
*/
92+
COVERAGE_ASM_AUTOGEN_MARK(t6,2)
9093
lw ra, 4(sp)
9194
addi sp, sp, 8
9295

sw/device/silicon_creator/rom_ext/rom_ext_start.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ _rom_ext_start_boot:
160160
/**
161161
* Initialize the `.data` section in RAM from ROM.
162162
*/
163+
COVERAGE_ASM_AUTOGEN_MARK(t6,2)
163164
la a0, _data_start
164165
la a1, _data_end
165166
la a2, _data_init_start
@@ -171,11 +172,13 @@ _rom_ext_start_boot:
171172
* We do this despite zeroing all of SRAM above, so that we still zero `.bss`
172173
* once we've enabled SRAM scrambling.
173174
*/
175+
COVERAGE_ASM_AUTOGEN_MARK(t6,3)
174176
la a0, _bss_start
175177
la a1, _bss_end
176178
call crt_section_clear
177179

178180
// Re-clobber all of the temporary registers.
181+
COVERAGE_ASM_AUTOGEN_MARK(t6,4)
179182
li t0, 0x0
180183
li t1, 0x0
181184
li t2, 0x0

0 commit comments

Comments
 (0)