hi @avinaw01-arm
could you please help review this timer-related issue?
Background
While reviewing and running the ACS timer test test_pool/timer/t005.c, I noticed two potential issues that may affect correctness on some platforms, especially under virtualization / E2H configurations.
1.val/src/acs_timer.c : missing E2H branch for programming compare value (CNTP_CVAL_EL02)
In val/src/acs_timer.c (around the implementation of val_timer_set_phy_el1, currently near the referenced line), the code programs the physical timer compare value using CNTP_CVAL_EL0 style accesses.
|
case CntpCval: |
|
write_cntp_cval_el0(*data_buf); |
|
break; |
However, when E2H is enabled, the correct register to program may be CNTP_CVAL_EL02. Without an E2H-specific branch,
ArmArchTimerReadReg(CntpCval) will call read_cntp_cval_el02 but this reg has wrong value. I believe the read and write helpers should be implemented as a pair.
|
case CntpCval: |
|
return effective_e2h ? read_cntp_cval_el02() : read_cntp_cval_el0(); |
i believe
Suggestion
Add an E2H handling path in val_timer_set_phy_el1() to write CNTP_CVAL_EL02 (e.g., via a write_cntp_cval_el02() helper) when E2H is active.
2.t005.c: systimer and physical EL1 timer are not started at the same time
In t005.c, the system timer is programmed with:
|
val_timer_set_system_timer((addr_t)cnt_base_n, sys_timer_ticks); |
and the physical EL1 timer is programmed separately via:
|
val_timer_set_phy_el1(pe_timer_ticks); |
These two operations are not placed together, so the two timers may not be armed “simultaneously”. Depending on implementation and execution latency, this can introduce a start-time skew (delay) between the two timers, which may cause intermittent failures or unexpected deltas when the test assumes they start at roughly the same time.
Suggestion
Move val_timer_set_system_timer((addr_t)cnt_base_n, sys_timer_ticks); to be adjacent to val_timer_set_phy_el1(pe_timer_ticks); (i.e., program both timers back-to-back), so they are armed as close in time as possible.
I’d appreciate any feedback on whether the timer arming order and the E2H (CNTP_CVAL_EL02) handling are correct for ACS expectations.
If you agree that the changes are appropriate, please let me know and I can put together a PR/commit for review.
Thanks!
hi @avinaw01-arm
could you please help review this timer-related issue?
Background
While reviewing and running the ACS timer test test_pool/timer/t005.c, I noticed two potential issues that may affect correctness on some platforms, especially under virtualization / E2H configurations.
1.val/src/acs_timer.c : missing E2H branch for programming compare value (CNTP_CVAL_EL02)
In val/src/acs_timer.c (around the implementation of val_timer_set_phy_el1, currently near the referenced line), the code programs the physical timer compare value using CNTP_CVAL_EL0 style accesses.
sysarch-acs/val/src/acs_timer.c
Lines 239 to 241 in 7a82e7e
However, when E2H is enabled, the correct register to program may be CNTP_CVAL_EL02. Without an E2H-specific branch,
ArmArchTimerReadReg(CntpCval) will call read_cntp_cval_el02 but this reg has wrong value. I believe the read and write helpers should be implemented as a pair.
sysarch-acs/val/src/acs_timer.c
Lines 142 to 143 in 7a82e7e
i believe
Suggestion
Add an E2H handling path in val_timer_set_phy_el1() to write CNTP_CVAL_EL02 (e.g., via a write_cntp_cval_el02() helper) when E2H is active.
2.t005.c: systimer and physical EL1 timer are not started at the same time
In t005.c, the system timer is programmed with:
sysarch-acs/test_pool/timer/t005.c
Line 104 in 7a82e7e
and the physical EL1 timer is programmed separately via:
sysarch-acs/test_pool/timer/t005.c
Line 115 in 7a82e7e
These two operations are not placed together, so the two timers may not be armed “simultaneously”. Depending on implementation and execution latency, this can introduce a start-time skew (delay) between the two timers, which may cause intermittent failures or unexpected deltas when the test assumes they start at roughly the same time.
Suggestion
Move val_timer_set_system_timer((addr_t)cnt_base_n, sys_timer_ticks); to be adjacent to val_timer_set_phy_el1(pe_timer_ticks); (i.e., program both timers back-to-back), so they are armed as close in time as possible.
I’d appreciate any feedback on whether the timer arming order and the E2H (CNTP_CVAL_EL02) handling are correct for ACS expectations.
If you agree that the changes are appropriate, please let me know and I can put together a PR/commit for review.
Thanks!