• Michael Ellerman's avatar
    powerpc/perf: Fix kernel address leak via sampling registers · e1ebd0e5
    Michael Ellerman authored
    Current code in power_pmu_disable() does not clear the sampling
    registers like Sampling Instruction Address Register (SIAR) and
    Sampling Data Address Register (SDAR) after disabling the PMU. Since
    these are userspace readable and could contain kernel addresses, add
    code to explicitly clear the content of these registers.
    
    Also add a "context synchronizing instruction" to enforce no further
    updates to these registers as suggested by Power ISA v3.0B. From
    section 9.4, on page 1108:
    
      "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 Context Alterations"
      on page 1133)."
    Signed-off-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
    [mpe: Massage change log and add ISA reference]
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    e1ebd0e5
core-book3s.c 56.6 KB