From: Michael Ellerman <mpe@ellerman.id.au>
Current code in power_pmu_disable() does not clear the sampling
registers like Sampling Instruction Address Register (SAIR) and
Sampling Data Address Register (SDAR) after disabling the PMU.
Since these are userspace readable and could contain kernel
address, add code to explicitly clear the content of these registers.
Patch also adds a "context synchronizing instruction" to enforce
no further updates to these registers as mandated by PowerISA.
"If an mtspr instruction is executed that changes the
value of a Performance Monitor register other than
SIAR, SDAR, and SIER, the change is not guaranteed
to have taken effect until after a subsequent context
synchronizing instruction has been executed (see
Chapter 11. "Synchronization Requirements for Con-
text Alterations" on page 1133)."
Signed-off-by: Madhavan Srinivasan <redacted>
---
Changelog v1:
- Added config flags to avoid 32bit build breaks.
arch/powerpc/perf/core-book3s.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
The current Branch History Rolling Buffer (BHRB) code does
not check for any privilege levels before updating the data
from BHRB. This leaks kernel addresses to userspace even when
profiling only with userspace privileges. Add proper checks
to prevent it.
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Madhavan Srinivasan <redacted>
---
Changelog -v1:
- Added comment.
arch/powerpc/perf/core-book3s.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Sampled Data Address Register (SDAR) is a 64-bit
register that contains the effective address of
the storage operand of an instruction that was
being executed, possibly out-of-order, at or around
the time that the Performance Monitor alert occurred.
In certain scenario SDAR happen to contain the kernel
address even for userspace only sampling. Add checks
to prevent it.
Signed-off-by: Madhavan Srinivasan <redacted>
---
Changelog v1:
- Removed the event exclusive_ check. Will take it up in a separate patch
arch/powerpc/perf/core-book3s.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
From: Michael Ellerman <hidden> Date: 2018-03-28 14:13:27
On Wed, 2018-03-21 at 11:40:24 UTC, Madhavan Srinivasan wrote:
From: Michael Ellerman <mpe@ellerman.id.au>
Current code in power_pmu_disable() does not clear the sampling
registers like Sampling Instruction Address Register (SAIR) and
Sampling Data Address Register (SDAR) after disabling the PMU.
Since these are userspace readable and could contain kernel
address, add code to explicitly clear the content of these registers.
Patch also adds a "context synchronizing instruction" to enforce
no further updates to these registers as mandated by PowerISA.
"If an mtspr instruction is executed that changes the
value of a Performance Monitor register other than
SIAR, SDAR, and SIER, the change is not guaranteed
to have taken effect until after a subsequent context
synchronizing instruction has been executed (see
Chapter 11. "Synchronization Requirements for Con-
text Alterations" on page 1133)."
Signed-off-by: Madhavan Srinivasan <redacted>
From: Michael Ellerman <hidden> Date: 2018-03-28 14:13:29
On Wed, 2018-03-21 at 11:40:25 UTC, Madhavan Srinivasan wrote:
The current Branch History Rolling Buffer (BHRB) code does
not check for any privilege levels before updating the data
from BHRB. This leaks kernel addresses to userspace even when
profiling only with userspace privileges. Add proper checks
to prevent it.
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Madhavan Srinivasan <redacted>
From: Michael Ellerman <hidden> Date: 2018-03-28 14:13:29
On Wed, 2018-03-21 at 11:40:26 UTC, Madhavan Srinivasan wrote:
Sampled Data Address Register (SDAR) is a 64-bit
register that contains the effective address of
the storage operand of an instruction that was
being executed, possibly out-of-order, at or around
the time that the Performance Monitor alert occurred.
In certain scenario SDAR happen to contain the kernel
address even for userspace only sampling. Add checks
to prevent it.
Signed-off-by: Madhavan Srinivasan <redacted>