OSDN Git Service

target/arm: Correctly initialize MDCR_EL2.HPMN
authorDaniel Müller <muellerd@fb.com>
Wed, 10 Feb 2021 17:41:22 +0000 (09:41 -0800)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 11 Feb 2021 19:48:09 +0000 (19:48 +0000)
commitd3c1183ffeb71ca3a783eae3d7e1c51e71e8a621
tree691981f17d285a37bc7b580db06d93a520e6b623
parent4565d826163d2e3a4ca3a5ebf3904e6b3b04a487
target/arm: Correctly initialize MDCR_EL2.HPMN

When working with performance monitoring counters, we look at
MDCR_EL2.HPMN as part of the check whether a counter is enabled. This
check fails, because MDCR_EL2.HPMN is reset to 0, meaning that no
counters are "enabled" for < EL2.
That's in violation of the Arm specification, which states that

> On a Warm reset, this field [MDCR_EL2.HPMN] resets to the value in
> PMCR_EL0.N

That's also what a comment in the code acknowledges, but the necessary
adjustment seems to have been forgotten when support for more counters
was added.
This change fixes the issue by setting the reset value to PMCR.N, which
is four.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/helper.c