Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/perf: Ensure all EBB register state is cleared on fork()

In commit 330a1eb "Core EBB support for 64-bit book3s" I messed up
clear_task_ebb(). It clears some but not all of the task's Event Based
Branch (EBB) registers when we duplicate a task struct.

That allows a child task to observe the EBBHR & EBBRR of its parent,
which it should not be able to do.

Fix it by clearing EBBHR & EBBRR.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: stable@vger.kernel.org [v3.11+]
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
3df48c98 caf69ba6

+2
+2
arch/powerpc/include/asm/switch_to.h
··· 86 86 { 87 87 #ifdef CONFIG_PPC_BOOK3S_64 88 88 /* EBB perf events are not inherited, so clear all EBB state. */ 89 + t->thread.ebbrr = 0; 90 + t->thread.ebbhr = 0; 89 91 t->thread.bescr = 0; 90 92 t->thread.mmcr2 = 0; 91 93 t->thread.mmcr0 = 0;