Skip to content

Commit 7f049fb

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
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: ce711ea ("perf/x86/intel/lbr: Support XSAVES/XRSTORS for LBR context switch") Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 13311e7 commit 7f049fb

File tree

1 file changed

+2
-1
lines changed
  • arch/x86/events/intel

1 file changed

+2
-1
lines changed

arch/x86/events/intel/lbr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ void reserve_lbr_buffers(void)
731731
if (!kmem_cache || cpuc->lbr_xsave)
732732
continue;
733733

734-
cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache, GFP_KERNEL,
734+
cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache,
735+
GFP_KERNEL | __GFP_ZERO,
735736
cpu_to_node(cpu));
736737
}
737738
}

0 commit comments

Comments
 (0)