]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86/intel/lbr: Zero the xstate buffer on allocation
authorThomas Gleixner <tglx@linutronix.de>
Fri, 11 Jun 2021 13:03:16 +0000 (15:03 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 24 Jun 2021 06:49:03 +0000 (08:49 +0200)
commit4b21cc6b81e50a97250a420776a4e857aea677a0
tree5b11e726fd368def34a736cfa73511ac95ded45e
parentc6de18cbc82363742b3e5ae9084ce57f72e214f0
perf/x86/intel/lbr: Zero the xstate buffer on allocation

XRSTORS requires a valid xstate buffer to work correctly. XSAVES does not
guarantee to write a fully valid buffer according to the SDM:

  "XSAVES does not write to any parts of the XSAVE header other than the
   XSTATE_BV and XCOMP_BV fields."

XRSTORS triggers a #GP:

  "If bytes 63:16 of the XSAVE header are not all zero."

It's dubious at best how this can work at all when the buffer is not zeroed
before use.

Allocate the buffers with __GFP_ZERO to prevent XRSTORS failure.

Fixes: c1fa5eaa2211 ("perf/x86/intel/lbr: Support XSAVES/XRSTORS for LBR context switch")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/87wnr0wo2z.ffs@nanos.tec.linutronix.de
arch/x86/events/intel/lbr.c