1. 31 7月, 2020 1 次提交
  2. 29 7月, 2020 1 次提交
  3. 26 7月, 2020 2 次提交
  4. 25 7月, 2020 3 次提交
  5. 24 7月, 2020 2 次提交
    • I
      compiler.h: Move instrumentation_begin()/end() to new <linux/instrumentation.h> header · d19e789f
      Ingo Molnar 提交于
      Linus pointed out that compiler.h - which is a key header that gets included in every
      single one of the 28,000+ kernel files during a kernel build - was bloated in:
      
        65538966: ("vmlinux.lds.h: Create section for protection against instrumentation")
      
      Linus noted:
      
       > I have pulled this, but do we really want to add this to a header file
       > that is _so_ core that it gets included for basically every single
       > file built?
       >
       > I don't even see those instrumentation_begin/end() things used
       > anywhere right now.
       >
       > It seems excessive. That 53 lines is maybe not a lot, but it pushed
       > that header file to over 12kB, and while it's mostly comments, it's
       > extra IO and parsing basically for _every_ single file compiled in the
       > kernel.
       >
       > For what appears to be absolutely zero upside right now, and I really
       > don't see why this should be in such a core header file!
      
      Move these primitives into a new header: <linux/instrumentation.h>, and include that
      header in the headers that make use of it.
      
      Unfortunately one of these headers is asm-generic/bug.h, which does get included
      in a lot of places, similarly to compiler.h. So the de-bloating effect isn't as
      good as we'd like it to be - but at least the interfaces are defined separately.
      
      No change to functionality intended.
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200604071921.GA1361070@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      d19e789f
    • A
      x86/mm: Drop unused MAX_PHYSADDR_BITS · 0a787b28
      Arvind Sankar 提交于
      The macro is not used anywhere, and has an incorrect value (going by the
      comment) on x86_64 since commit c898faf9 ("x86: 46 bit physical address
      support on 64 bits")
      
      To avoid confusion, just remove the definition.
      Signed-off-by: NArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20200723231544.17274-2-nivedita@alum.mit.edu
      0a787b28
  6. 23 7月, 2020 12 次提交
  7. 18 7月, 2020 2 次提交
  8. 16 7月, 2020 3 次提交
  9. 10 7月, 2020 1 次提交
  10. 08 7月, 2020 8 次提交
    • K
      perf/x86/intel/lbr: Support XSAVES/XRSTORS for LBR context switch · ce711ea3
      Kan Liang 提交于
      In the LBR call stack mode, LBR information is used to reconstruct a
      call stack. To get the complete call stack, perf has to save/restore
      all LBR registers during a context switch. Due to a large number of the
      LBR registers, this process causes a high CPU overhead. To reduce the
      CPU overhead during a context switch, use the XSAVES/XRSTORS
      instructions.
      
      Every XSAVE area must follow a canonical format: the legacy region, an
      XSAVE header and the extended region. Although the LBR information is
      only kept in the extended region, a space for the legacy region and
      XSAVE header is still required. Add a new dedicated structure for LBR
      XSAVES support.
      
      Before enabling XSAVES support, the size of the LBR state has to be
      sanity checked, because:
      - the size of the software structure is calculated from the max number
      of the LBR depth, which is enumerated by the CPUID leaf for Arch LBR.
      The size of the LBR state is enumerated by the CPUID leaf for XSAVE
      support of Arch LBR. If the values from the two CPUID leaves are not
      consistent, it may trigger a buffer overflow. For example, a hypervisor
      may unconsciously set inconsistent values for the two emulated CPUID.
      - unlike other state components, the size of an LBR state depends on the
      max number of LBRs, which may vary from generation to generation.
      
      Expose the function xfeature_size() for the sanity check.
      The LBR XSAVES support will be disabled if the size of the LBR state
      enumerated by CPUID doesn't match with the size of the software
      structure.
      
      The XSAVE instruction requires 64-byte alignment for state buffers. A
      new macro is added to reflect the alignment requirement. A 64-byte
      aligned kmem_cache is created for architecture LBR.
      
      Currently, the structure for each state component is maintained in
      fpu/types.h. The structure for the new LBR state component should be
      maintained in the same place. Move structure lbr_entry to fpu/types.h as
      well for broader sharing.
      
      Add dedicated lbr_save/lbr_restore functions for LBR XSAVES support,
      which invokes the corresponding xstate helpers to XSAVES/XRSTORS LBR
      information at the context switch when the call stack mode is enabled.
      Since the XSAVES/XRSTORS instructions will be eventually invoked, the
      dedicated functions is named with '_xsaves'/'_xrstors' postfix.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/1593780569-62993-23-git-send-email-kan.liang@linux.intel.com
      ce711ea3
    • K
      x86/fpu/xstate: Add helpers for LBR dynamic supervisor feature · 50f408d9
      Kan Liang 提交于
      The perf subsystem will only need to save/restore the LBR state.
      However, the existing helpers save all supported supervisor states to a
      kernel buffer, which will be unnecessary. Two helpers are introduced to
      only save/restore requested dynamic supervisor states. The supervisor
      features in XFEATURE_MASK_SUPERVISOR_SUPPORTED and
      XFEATURE_MASK_SUPERVISOR_UNSUPPORTED mask cannot be saved/restored using
      these helpers.
      
      The helpers will be used in the following patch.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/1593780569-62993-22-git-send-email-kan.liang@linux.intel.com
      50f408d9
    • K
      x86/fpu/xstate: Support dynamic supervisor feature for LBR · f0dccc9d
      Kan Liang 提交于
      Last Branch Records (LBR) registers are used to log taken branches and
      other control flows. In perf with call stack mode, LBR information is
      used to reconstruct a call stack. To get the complete call stack, perf
      has to save/restore all LBR registers during a context switch. Due to
      the large number of the LBR registers, e.g., the current platform has
      96 LBR registers, this process causes a high CPU overhead. To reduce
      the CPU overhead during a context switch, an LBR state component that
      contains all the LBR related registers is introduced in hardware. All
      LBR registers can be saved/restored together using one XSAVES/XRSTORS
      instruction.
      
      However, the kernel should not save/restore the LBR state component at
      each context switch, like other state components, because of the
      following unique features of LBR:
      - The LBR state component only contains valuable information when LBR
        is enabled in the perf subsystem, but for most of the time, LBR is
        disabled.
      - The size of the LBR state component is huge. For the current
        platform, it's 808 bytes.
      If the kernel saves/restores the LBR state at each context switch, for
      most of the time, it is just a waste of space and cycles.
      
      To efficiently support the LBR state component, it is desired to have:
      - only context-switch the LBR when the LBR feature is enabled in perf.
      - only allocate an LBR-specific XSAVE buffer on demand.
        (Besides the LBR state, a legacy region and an XSAVE header have to be
         included in the buffer as well. There is a total of (808+576) byte
         overhead for the LBR-specific XSAVE buffer. The overhead only happens
         when the perf is actively using LBRs. There is still a space-saving,
         on average, when it replaces the constant 808 bytes of overhead for
         every task, all the time on the systems that support architectural
         LBR.)
      - be able to use XSAVES/XRSTORS for accessing LBR at run time.
        However, the IA32_XSS should not be adjusted at run time.
        (The XCR0 | IA32_XSS are used to determine the requested-feature
        bitmap (RFBM) of XSAVES.)
      
      A solution, called dynamic supervisor feature, is introduced to address
      this issue, which
      - does not allocate a buffer in each task->fpu;
      - does not save/restore a state component at each context switch;
      - sets the bit corresponding to the dynamic supervisor feature in
        IA32_XSS at boot time, and avoids setting it at run time.
      - dynamically allocates a specific buffer for a state component
        on demand, e.g. only allocates LBR-specific XSAVE buffer when LBR is
        enabled in perf. (Note: The buffer has to include the LBR state
        component, a legacy region and a XSAVE header space.)
        (Implemented in a later patch)
      - saves/restores a state component on demand, e.g. manually invokes
        the XSAVES/XRSTORS instruction to save/restore the LBR state
        to/from the buffer when perf is active and a call stack is required.
        (Implemented in a later patch)
      
      A new mask XFEATURE_MASK_DYNAMIC and a helper xfeatures_mask_dynamic()
      are introduced to indicate the dynamic supervisor feature. For the
      systems which support the Architecture LBR, LBR is the only dynamic
      supervisor feature for now. For the previous systems, there is no
      dynamic supervisor feature available.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/1593780569-62993-21-git-send-email-kan.liang@linux.intel.com
      f0dccc9d
    • K
      x86/fpu: Use proper mask to replace full instruction mask · a063bf24
      Kan Liang 提交于
      When saving xstate to a kernel/user XSAVE area with the XSAVE family of
      instructions, the current code applies the 'full' instruction mask (-1),
      which tries to XSAVE all possible features. This method relies on
      hardware to trim 'all possible' down to what is enabled in the
      hardware. The code works well for now. However, there will be a
      problem, if some features are enabled in hardware, but are not suitable
      to be saved into all kernel XSAVE buffers, like task->fpu, due to
      performance consideration.
      
      One such example is the Last Branch Records (LBR) state. The LBR state
      only contains valuable information when LBR is explicitly enabled by
      the perf subsystem, and the size of an LBR state is large (808 bytes
      for now). To avoid both CPU overhead and space overhead at each context
      switch, the LBR state should not be saved into task->fpu like other
      state components. It should be saved/restored on demand when LBR is
      enabled in the perf subsystem. Current copy_xregs_to_* will trigger a
      buffer overflow for such cases.
      
      Three sites use the '-1' instruction mask which must be updated.
      
      Two are saving/restoring the xstate to/from a kernel-allocated XSAVE
      buffer and can use 'xfeatures_mask_all', which will save/restore all of
      the features present in a normal task FPU buffer.
      
      The last one saves the register state directly to a user buffer. It
      could
      also use 'xfeatures_mask_all'. Just as it was with the '-1' argument,
      any supervisor states in the mask will be filtered out by the hardware
      and not saved to the buffer.  But, to be more explicit about what is
      expected to be saved, use xfeatures_mask_user() for the instruction
      mask.
      
      KVM includes the header file fpu/internal.h. To avoid 'undefined
      xfeatures_mask_all' compiling issue, move copy_fpregs_to_fpstate() to
      fpu/core.c and export it, because:
      - The xfeatures_mask_all is indirectly used via copy_fpregs_to_fpstate()
        by KVM. The function which is directly used by other modules should be
        exported.
      - The copy_fpregs_to_fpstate() is a function, while xfeatures_mask_all
        is a variable for the "internal" FPU state. It's safer to export a
        function than a variable, which may be implicitly changed by others.
      - The copy_fpregs_to_fpstate() is a big function with many checks. The
        removal of the inline keyword should not impact the performance.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/1593780569-62993-20-git-send-email-kan.liang@linux.intel.com
      a063bf24
    • K
      perf/x86/intel/lbr: Unify the stored format of LBR information · 5624986d
      Kan Liang 提交于
      Current LBR information in the structure x86_perf_task_context is stored
      in a different format from the PEBS LBR record and Architecture LBR,
      which prevents the sharing of the common codes.
      
      Use the format of the PEBS LBR record as a unified format. Use a generic
      name lbr_entry to replace pebs_lbr_entry.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1593780569-62993-11-git-send-email-kan.liang@linux.intel.com
      5624986d
    • K
      perf/x86: Expose CPUID enumeration bits for arch LBR · af6cf129
      Kan Liang 提交于
      The LBR capabilities of Architecture LBR are retrieved from the CPUID
      enumeration once at boot time. The capabilities have to be saved for
      future usage.
      
      Several new fields are added into structure x86_pmu to indicate the
      capabilities. The fields will be used in the following patches.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1593780569-62993-9-git-send-email-kan.liang@linux.intel.com
      af6cf129
    • K
      x86/msr-index: Add bunch of MSRs for Arch LBR · d6a162a4
      Kan Liang 提交于
      Add Arch LBR related MSRs and the new LBR INFO bits in MSR-index.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1593780569-62993-8-git-send-email-kan.liang@linux.intel.com
      d6a162a4
    • K
      x86/cpufeatures: Add Architectural LBRs feature bit · bd657aa3
      Kan Liang 提交于
      CPUID.(EAX=07H, ECX=0):EDX[19] indicates whether an Intel CPU supports
      Architectural LBRs.
      
      The "X86_FEATURE_..., word 18" is already mirrored from CPUID
      "0x00000007:0 (EDX)". Add X86_FEATURE_ARCH_LBR under the "word 18"
      section.
      
      The feature will appear as "arch_lbr" in /proc/cpuinfo.
      
      The Architectural Last Branch Records (LBR) feature enables recording
      of software path history by logging taken branches and other control
      flows. The feature will be supported in the perf_events subsystem.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/1593780569-62993-2-git-send-email-kan.liang@linux.intel.com
      bd657aa3
  11. 07 7月, 2020 1 次提交
  12. 06 7月, 2020 1 次提交
    • I
      x86/entry/32: Fix XEN_PV build dependency · a4c0e91d
      Ingo Molnar 提交于
      xenpv_exc_nmi() and xenpv_exc_debug() are only defined on 64-bit kernels,
      but they snuck into the 32-bit build via <asm/identry.h>, causing the link
      to fail:
      
        ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_nmi':
        (.entry.text+0x817): undefined reference to `xenpv_exc_nmi'
      
        ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_debug':
        (.entry.text+0x827): undefined reference to `xenpv_exc_debug'
      
      Only use them on 64-bit kernels.
      
      Fixes: f41f0824: ("x86/entry/xen: Route #DB correctly on Xen PV")
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      a4c0e91d
  13. 05 7月, 2020 2 次提交
  14. 02 7月, 2020 1 次提交