Patch "perf/x86/intel/lbr: Zero the xstate buffer on allocation" has been added to the 5.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf/x86/intel/lbr: Zero the xstate buffer on allocation

to the 5.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-x86-intel-lbr-zero-the-xstate-buffer-on-allocat.patch
and it can be found in the queue-5.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a93e366bb5cfbd583df26297563d6256d7f6c32d
Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Date:   Fri Jun 11 15:03:16 2021 +0200

    perf/x86/intel/lbr: Zero the xstate buffer on allocation
    
    [ Upstream commit 7f049fbdd57f6ea71dc741d903c19c73b2f70950 ]
    
    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: ce711ea3cab9 ("perf/x86/intel/lbr: Support XSAVES/XRSTORS for LBR context switch")
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/87wnr0wo2z.ffs@xxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
index 22d0e40a1920..991715886246 100644
--- a/arch/x86/events/intel/lbr.c
+++ b/arch/x86/events/intel/lbr.c
@@ -730,7 +730,8 @@ void reserve_lbr_buffers(void)
 		if (!kmem_cache || cpuc->lbr_xsave)
 			continue;
 
-		cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache, GFP_KERNEL,
+		cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache,
+							GFP_KERNEL | __GFP_ZERO,
 							cpu_to_node(cpu));
 	}
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux