Skip to content
  • Peter Maydell's avatar
    01765386
    target/arm: Don't mishandle count when enabling or disabling PMU counters · 01765386
    Peter Maydell authored
    
    
    The PMU cycle and event counter infrastructure design requires that
    operations on the PMU register fields are wrapped in pmu_op_start()
    and pmu_op_finish() calls (or their more specific pmmcntr and
    pmevcntr equivalents).  This includes any changes to registers which
    affect whether the counter should be enabled or disabled, but we
    forgot to do this.
    
    The effect of this bug is that in sequences like:
     * disable the cycle counter (PMCCNTR) using the PMCNTEN register
     * write a value such as 0xfffff000 to the PMCCNTR
     * restart the counter by writing to PMCNTEN
    the value written to the cycle counter is corrupted, and it starts
    counting from the wrong place. (Essentially, we fail to record that
    the QEMU_CLOCK_VIRTUAL timestamp when the counter should be considered
    to have started counting is the point when PMCNTEN is written to enable
    the counter.)
    
    Add the necessary bracketing calls, so that updates to the various
    registers which affect whether the PMU is counting are handled
    correctly.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Message-Id: <20220822132358.3524971-4-peter.maydell@linaro.org>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    01765386
    target/arm: Don't mishandle count when enabling or disabling PMU counters
    Peter Maydell authored
    
    
    The PMU cycle and event counter infrastructure design requires that
    operations on the PMU register fields are wrapped in pmu_op_start()
    and pmu_op_finish() calls (or their more specific pmmcntr and
    pmevcntr equivalents).  This includes any changes to registers which
    affect whether the counter should be enabled or disabled, but we
    forgot to do this.
    
    The effect of this bug is that in sequences like:
     * disable the cycle counter (PMCCNTR) using the PMCNTEN register
     * write a value such as 0xfffff000 to the PMCCNTR
     * restart the counter by writing to PMCNTEN
    the value written to the cycle counter is corrupted, and it starts
    counting from the wrong place. (Essentially, we fail to record that
    the QEMU_CLOCK_VIRTUAL timestamp when the counter should be considered
    to have started counting is the point when PMCNTEN is written to enable
    the counter.)
    
    Add the necessary bracketing calls, so that updates to the various
    registers which affect whether the PMU is counting are handled
    correctly.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Message-Id: <20220822132358.3524971-4-peter.maydell@linaro.org>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Loading