1. 15 6月, 2021 1 次提交
    • P
      x86/msr: Define new bits in TSX_FORCE_ABORT MSR · 1348924b
      Pawan Gupta 提交于
      Intel client processors that support the IA32_TSX_FORCE_ABORT MSR
      related to perf counter interaction [1] received a microcode update that
      deprecates the Transactional Synchronization Extension (TSX) feature.
      The bit FORCE_ABORT_RTM now defaults to 1, writes to this bit are
      ignored. A new bit TSX_CPUID_CLEAR clears the TSX related CPUID bits.
      
      The summary of changes to the IA32_TSX_FORCE_ABORT MSR are:
      
        Bit 0: FORCE_ABORT_RTM (legacy bit, new default=1) Status bit that
        indicates if RTM transactions are always aborted. This bit is
        essentially !SDV_ENABLE_RTM(Bit 2). Writes to this bit are ignored.
      
        Bit 1: TSX_CPUID_CLEAR (new bit, default=0) When set, CPUID.HLE = 0
        and CPUID.RTM = 0.
      
        Bit 2: SDV_ENABLE_RTM (new bit, default=0) When clear, XBEGIN will
        always abort with EAX code 0. When set, XBEGIN will not be forced to
        abort (but will always abort in SGX enclaves). This bit is intended to
        be used on developer systems. If this bit is set, transactional
        atomicity correctness is not certain. SDV = Software Development
        Vehicle (SDV), i.e. developer systems.
      
      Performance monitoring counter 3 is usable in all cases, regardless of
      the value of above bits.
      
      Add support for a new CPUID bit - CPUID.RTM_ALWAYS_ABORT (CPUID 7.EDX[11])
       - to indicate the status of always abort behavior.
      
      [1] [ bp: Look for document ID 604224, "Performance Monitoring Impact
            of Intel Transactional Synchronization Extension Memory". Since
            there's no way for us to have stable links to documents... ]
      
       [ bp: Massage and extend commit message. ]
      Signed-off-by: NPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      Link: https://lkml.kernel.org/r/9add61915b4a4eedad74fbd869107863a28b428e.1623704845.git-series.pawan.kumar.gupta@linux.intel.com
      1348924b
  2. 02 6月, 2021 1 次提交
  3. 20 4月, 2021 1 次提交
  4. 29 3月, 2021 1 次提交
  5. 26 3月, 2021 1 次提交
  6. 15 3月, 2021 2 次提交
    • P
      x86: Remove dynamic NOP selection · a89dfde3
      Peter Zijlstra 提交于
      This ensures that a NOP is a NOP and not a random other instruction that
      is also a NOP. It allows simplification of dynamic code patching that
      wants to verify existing code before writing new instructions (ftrace,
      jump_label, static_call, etc..).
      
      Differentiating on NOPs is not a feature.
      
      This pessimises 32bit (DONTCARE) and 32bit on 64bit CPUs (CARELESS).
      32bit is not a performance target.
      
      Everything x86_64 since AMD K10 (2007) and Intel IvyBridge (2012) is
      fine with using NOPL (as opposed to prefix NOP). And per FEATURE_NOPL
      being required for x86_64, all x86_64 CPUs can use NOPL. So stop
      caring about NOPs, simplify things and get on with life.
      
      [ The problem seems to be that some uarchs can only decode NOPL on a
      single front-end port while others have severe decode penalties for
      excessive prefixes. All modern uarchs can handle both, except Atom,
      which has prefix penalties. ]
      
      [ Also, much doubt you can actually measure any of this on normal
      workloads. ]
      
      After this, FEATURE_NOPL is unused except for required-features for
      x86_64. FEATURE_K8 is only used for PTI.
      
       [ bp: Kernel build measurements showed ~0.3s slowdown on Sandybridge
         which is hardly a slowdown. Get rid of X86_FEATURE_K7, while at it. ]
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: Alexei Starovoitov <alexei.starovoitov@gmail.com> # bpf
      Acked-by: NLinus Torvalds <torvalds@linuxfoundation.org>
      Link: https://lkml.kernel.org/r/20210312115749.065275711@infradead.org
      a89dfde3
    • B
      x86/cpufeatures: Add the Virtual SPEC_CTRL feature · f333374e
      Babu Moger 提交于
      Newer AMD processors have a feature to virtualize the use of the
      SPEC_CTRL MSR. Presence of this feature is indicated via CPUID
      function 0x8000000A_EDX[20]: GuestSpecCtrl. When present, the
      SPEC_CTRL MSR is automatically virtualized.
      Signed-off-by: NBabu Moger <babu.moger@amd.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Message-Id: <161188100272.28787.4097272856384825024.stgit@bmoger-ubuntu>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f333374e
  7. 12 3月, 2021 1 次提交
  8. 04 2月, 2021 2 次提交
  9. 29 1月, 2021 1 次提交
  10. 15 12月, 2020 1 次提交
    • T
      x86/cpu: Add VM page flush MSR availablility as a CPUID feature · 69372cf0
      Tom Lendacky 提交于
      On systems that do not have hardware enforced cache coherency between
      encrypted and unencrypted mappings of the same physical page, the
      hypervisor can use the VM page flush MSR (0xc001011e) to flush the cache
      contents of an SEV guest page. When a small number of pages are being
      flushed, this can be used in place of issuing a WBINVD across all CPUs.
      
      CPUID 0x8000001f_eax[2] is used to determine if the VM page flush MSR is
      available. Add a CPUID feature to indicate it is supported and define the
      MSR.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <f1966379e31f9b208db5257509c4a089a87d33d0.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      69372cf0
  11. 12 12月, 2020 1 次提交
    • K
      x86: Enumerate AVX512 FP16 CPUID feature flag · e1b35da5
      Kyung Min Park 提交于
      Enumerate AVX512 Half-precision floating point (FP16) CPUID feature
      flag. Compared with using FP32, using FP16 cut the number of bits
      required for storage in half, reducing the exponent from 8 bits to 5,
      and the mantissa from 23 bits to 10. Using FP16 also enables developers
      to train and run inference on deep learning models fast when all
      precision or magnitude (FP32) is not needed.
      
      A processor supports AVX512 FP16 if CPUID.(EAX=7,ECX=0):EDX[bit 23]
      is present. The AVX512 FP16 requires AVX512BW feature be implemented
      since the instructions for manipulating 32bit masks are associated with
      AVX512BW.
      
      The only in-kernel usage of this is kvm passthrough. The CPU feature
      flag is shown as "avx512_fp16" in /proc/cpuinfo.
      Signed-off-by: NKyung Min Park <kyung.min.park@intel.com>
      Acked-by: NDave Hansen <dave.hansen@intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Message-Id: <20201208033441.28207-2-kyung.min.park@intel.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e1b35da5
  12. 17 11月, 2020 2 次提交
  13. 18 9月, 2020 2 次提交
  14. 08 9月, 2020 1 次提交
  15. 30 8月, 2020 1 次提交
  16. 26 8月, 2020 1 次提交
  17. 27 7月, 2020 1 次提交
  18. 08 7月, 2020 1 次提交
  19. 16 6月, 2020 1 次提交
  20. 20 4月, 2020 1 次提交
    • M
      x86/speculation: Add Special Register Buffer Data Sampling (SRBDS) mitigation · 7e5b3c26
      Mark Gross 提交于
      SRBDS is an MDS-like speculative side channel that can leak bits from the
      random number generator (RNG) across cores and threads. New microcode
      serializes the processor access during the execution of RDRAND and
      RDSEED. This ensures that the shared buffer is overwritten before it is
      released for reuse.
      
      While it is present on all affected CPU models, the microcode mitigation
      is not needed on models that enumerate ARCH_CAPABILITIES[MDS_NO] in the
      cases where TSX is not supported or has been disabled with TSX_CTRL.
      
      The mitigation is activated by default on affected processors and it
      increases latency for RDRAND and RDSEED instructions. Among other
      effects this will reduce throughput from /dev/urandom.
      
      * Enable administrator to configure the mitigation off when desired using
        either mitigations=off or srbds=off.
      
      * Export vulnerability status via sysfs
      
      * Rename file-scoped macros to apply for non-whitelist table initializations.
      
       [ bp: Massage,
         - s/VULNBL_INTEL_STEPPING/VULNBL_INTEL_STEPPINGS/g,
         - do not read arch cap MSR a second time in tsx_fused_off() - just pass it in,
         - flip check in cpu_set_bug_bits() to save an indentation level,
         - reflow comments.
         jpoimboe: s/Mitigated/Mitigation/ in user-visible strings
         tglx: Dropped the fused off magic for now
       ]
      Signed-off-by: NMark Gross <mgross@linux.intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      7e5b3c26
  21. 22 3月, 2020 1 次提交
  22. 12 3月, 2020 1 次提交
  23. 21 2月, 2020 1 次提交
    • P
      x86/split_lock: Enable split lock detection by kernel · 6650cdd9
      Peter Zijlstra (Intel) 提交于
      A split-lock occurs when an atomic instruction operates on data that spans
      two cache lines. In order to maintain atomicity the core takes a global bus
      lock.
      
      This is typically >1000 cycles slower than an atomic operation within a
      cache line. It also disrupts performance on other cores (which must wait
      for the bus lock to be released before their memory operations can
      complete). For real-time systems this may mean missing deadlines. For other
      systems it may just be very annoying.
      
      Some CPUs have the capability to raise an #AC trap when a split lock is
      attempted.
      
      Provide a command line option to give the user choices on how to handle
      this:
      
      split_lock_detect=
      	off	- not enabled (no traps for split locks)
      	warn	- warn once when an application does a
      		  split lock, but allow it to continue
      		  running.
      	fatal	- Send SIGBUS to applications that cause split lock
      
      On systems that support split lock detection the default is "warn". Note
      that if the kernel hits a split lock in any mode other than "off" it will
      OOPs.
      
      One implementation wrinkle is that the MSR to control the split lock
      detection is per-core, not per thread. This might result in some short
      lived races on HT systems in "warn" mode if Linux tries to enable on one
      thread while disabling on the other. Race analysis by Sean Christopherson:
      
        - Toggling of split-lock is only done in "warn" mode.  Worst case
          scenario of a race is that a misbehaving task will generate multiple
          #AC exceptions on the same instruction.  And this race will only occur
          if both siblings are running tasks that generate split-lock #ACs, e.g.
          a race where sibling threads are writing different values will only
          occur if CPUx is disabling split-lock after an #AC and CPUy is
          re-enabling split-lock after *its* previous task generated an #AC.
        - Transitioning between off/warn/fatal modes at runtime isn't supported
          and disabling is tracked per task, so hardware will always reach a steady
          state that matches the configured mode.  I.e. split-lock is guaranteed to
          be enabled in hardware once all _TIF_SLD threads have been scheduled out.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Co-developed-by: NFenghua Yu <fenghua.yu@intel.com>
      Signed-off-by: NFenghua Yu <fenghua.yu@intel.com>
      Co-developed-by: NTony Luck <tony.luck@intel.com>
      Signed-off-by: NTony Luck <tony.luck@intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Link: https://lore.kernel.org/r/20200126200535.GB30377@agluck-desk2.amr.corp.intel.com
      6650cdd9
  24. 14 1月, 2020 1 次提交
    • S
      x86/cpufeatures: Add flag to track whether MSR IA32_FEAT_CTL is configured · 85c17291
      Sean Christopherson 提交于
      Add a new feature flag, X86_FEATURE_MSR_IA32_FEAT_CTL, to track whether
      IA32_FEAT_CTL has been initialized.  This will allow KVM, and any future
      subsystems that depend on IA32_FEAT_CTL, to rely purely on cpufeatures
      to query platform support, e.g. allows a future patch to remove KVM's
      manual IA32_FEAT_CTL MSR checks.
      
      Various features (on platforms that support IA32_FEAT_CTL) are dependent
      on IA32_FEAT_CTL being configured and locked, e.g. VMX and LMCE.  The
      MSR is always configured during boot, but only if the CPU vendor is
      recognized by the kernel.  Because CPUID doesn't incorporate the current
      IA32_FEAT_CTL value in its reporting of relevant features, it's possible
      for a feature to be reported as supported in cpufeatures but not truly
      enabled, e.g. if the CPU supports VMX but the kernel doesn't recognize
      the CPU.
      
      As a result, without the flag, KVM would see VMX as supported even if
      IA32_FEAT_CTL hasn't been initialized, and so would need to manually
      read the MSR and check the various enabling bits to avoid taking an
      unexpected #GP on VMXON.
      Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/20191221044513.21680-14-sean.j.christopherson@intel.com
      85c17291
  25. 08 1月, 2020 1 次提交
    • T
      x86/cpufeatures: Add support for fast short REP; MOVSB · f444a5ff
      Tony Luck 提交于
      >From the Intel Optimization Reference Manual:
      
      3.7.6.1 Fast Short REP MOVSB
      Beginning with processors based on Ice Lake Client microarchitecture,
      REP MOVSB performance of short operations is enhanced. The enhancement
      applies to string lengths between 1 and 128 bytes long.  Support for
      fast-short REP MOVSB is enumerated by the CPUID feature flag: CPUID
      [EAX=7H, ECX=0H).EDX.FAST_SHORT_REP_MOVSB[bit 4] = 1. There is no change
      in the REP STOS performance.
      
      Add an X86_FEATURE_FSRM flag for this.
      
      memmove() avoids REP MOVSB for short (< 32 byte) copies. Check FSRM and
      use REP MOVSB for short copies on systems that support it.
      
       [ bp: Massage and add comment. ]
      Signed-off-by: NTony Luck <tony.luck@intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/20191216214254.26492-1-tony.luck@intel.com
      f444a5ff
  26. 04 11月, 2019 1 次提交
  27. 28 10月, 2019 1 次提交
    • P
      x86/speculation/taa: Add mitigation for TSX Async Abort · 1b42f017
      Pawan Gupta 提交于
      TSX Async Abort (TAA) is a side channel vulnerability to the internal
      buffers in some Intel processors similar to Microachitectural Data
      Sampling (MDS). In this case, certain loads may speculatively pass
      invalid data to dependent operations when an asynchronous abort
      condition is pending in a TSX transaction.
      
      This includes loads with no fault or assist condition. Such loads may
      speculatively expose stale data from the uarch data structures as in
      MDS. Scope of exposure is within the same-thread and cross-thread. This
      issue affects all current processors that support TSX, but do not have
      ARCH_CAP_TAA_NO (bit 8) set in MSR_IA32_ARCH_CAPABILITIES.
      
      On CPUs which have their IA32_ARCH_CAPABILITIES MSR bit MDS_NO=0,
      CPUID.MD_CLEAR=1 and the MDS mitigation is clearing the CPU buffers
      using VERW or L1D_FLUSH, there is no additional mitigation needed for
      TAA. On affected CPUs with MDS_NO=1 this issue can be mitigated by
      disabling the Transactional Synchronization Extensions (TSX) feature.
      
      A new MSR IA32_TSX_CTRL in future and current processors after a
      microcode update can be used to control the TSX feature. There are two
      bits in that MSR:
      
      * TSX_CTRL_RTM_DISABLE disables the TSX sub-feature Restricted
      Transactional Memory (RTM).
      
      * TSX_CTRL_CPUID_CLEAR clears the RTM enumeration in CPUID. The other
      TSX sub-feature, Hardware Lock Elision (HLE), is unconditionally
      disabled with updated microcode but still enumerated as present by
      CPUID(EAX=7).EBX{bit4}.
      
      The second mitigation approach is similar to MDS which is clearing the
      affected CPU buffers on return to user space and when entering a guest.
      Relevant microcode update is required for the mitigation to work.  More
      details on this approach can be found here:
      
        https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html
      
      The TSX feature can be controlled by the "tsx" command line parameter.
      If it is force-enabled then "Clear CPU buffers" (MDS mitigation) is
      deployed. The effective mitigation state can be read from sysfs.
      
       [ bp:
         - massage + comments cleanup
         - s/TAA_MITIGATION_TSX_DISABLE/TAA_MITIGATION_TSX_DISABLED/g - Josh.
         - remove partial TAA mitigation in update_mds_branch_idle() - Josh.
         - s/tsx_async_abort_cmdline/tsx_async_abort_parse_cmdline/g
       ]
      Signed-off-by: NPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      1b42f017
  28. 08 10月, 2019 1 次提交
    • B
      x86/cpufeatures: Add feature bit RDPRU on AMD · 9d40b85b
      Babu Moger 提交于
      AMD Zen 2 introduces a new RDPRU instruction which is used to give
      access to some processor registers that are typically only accessible
      when the privilege level is zero.
      
      ECX is used as the implicit register to specify which register to read.
      RDPRU places the specified register’s value into EDX:EAX.
      
      For example, the RDPRU instruction can be used to read MPERF and APERF
      at CPL > 0.
      
      Add the feature bit so it is visible in /proc/cpuinfo.
      
      Details are available in the AMD64 Architecture Programmer’s Manual:
      https://www.amd.com/system/files/TechDocs/24594.pdfSigned-off-by: NBabu Moger <babu.moger@amd.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Aaron Lewis <aaronlewis@google.com>
      Cc: ak@linux.intel.com
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: robert.hu@linux.intel.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20191007204839.5727.10803.stgit@localhost.localdomain
      9d40b85b
  29. 28 8月, 2019 1 次提交
    • T
      x86/vmware: Add a header file for hypercall definitions · b4dd4f6e
      Thomas Hellstrom 提交于
      The new header is intended to be used by drivers using the backdoor.
      Follow the KVM example using alternatives self-patching to choose
      between vmcall, vmmcall and io instructions.
      
      Also define two new CPU feature flags to indicate hypervisor support
      for vmcall- and vmmcall instructions. The new XF86_FEATURE_VMW_VMMCALL
      flag is needed because using XF86_FEATURE_VMMCALL might break QEMU/KVM
      setups using the vmmouse driver. They rely on XF86_FEATURE_VMMCALL
      on AMD to get the kvm_hypercall() right. But they do not yet implement
      vmmcall for the VMware hypercall used by the vmmouse driver.
      
       [ bp: reflow hypercall %edx usage explanation comment. ]
      Signed-off-by: NThomas Hellstrom <thellstrom@vmware.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NDoug Covelli <dcovelli@vmware.com>
      Cc: Aaron Lewis <aaronlewis@google.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: linux-graphics-maintainer@vmware.com
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Cc: Robert Hoo <robert.hu@linux.intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: virtualization@lists.linux-foundation.org
      Cc: <pv-drivers@vmware.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190828080353.12658-3-thomas_os@shipmail.org
      b4dd4f6e
  30. 29 7月, 2019 1 次提交
  31. 22 7月, 2019 2 次提交
    • J
      x86: Remove X86_FEATURE_MFENCE_RDTSC · be261ffc
      Josh Poimboeuf 提交于
      AMD and Intel both have serializing lfence (X86_FEATURE_LFENCE_RDTSC).
      They've both had it for a long time, and AMD has had it enabled in Linux
      since Spectre v1 was announced.
      
      Back then, there was a proposal to remove the serializing mfence feature
      bit (X86_FEATURE_MFENCE_RDTSC), since both AMD and Intel have
      serializing lfence.  At the time, it was (ahem) speculated that some
      hypervisors might not yet support its removal, so it remained for the
      time being.
      
      Now a year-and-a-half later, it should be safe to remove.
      
      I asked Andrew Cooper about whether it's still needed:
      
        So if you're virtualised, you've got no choice in the matter.  lfence
        is either dispatch-serialising or not on AMD, and you won't be able to
        change it.
      
        Furthermore, you can't accurately tell what state the bit is in, because
        the MSR might not be virtualised at all, or may not reflect the true
        state in hardware.  Worse still, attempting to set the bit may not be
        successful even if there isn't a fault for doing so.
      
        Xen sets the DE_CFG bit unconditionally, as does Linux by the looks of
        things (see MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT).  ISTR other hypervisor
        vendors saying the same, but I don't have any information to hand.
      
        If you are running under a hypervisor which has been updated, then
        lfence will almost certainly be dispatch-serialising in practice, and
        you'll almost certainly see the bit already set in DE_CFG.  If you're
        running under a hypervisor which hasn't been patched since Spectre,
        you've already lost in many more ways.
      
        I'd argue that X86_FEATURE_MFENCE_RDTSC is not worth keeping.
      
      So remove it.  This will reduce some code rot, and also make it easier
      to hook barrier_nospec() up to a cmdline disable for performance
      raisins, without having to need an alternative_3() macro.
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/d990aa51e40063acb9888e8c1b688e41355a9588.1562255067.git.jpoimboe@redhat.com
      be261ffc
    • G
      x86/cpufeatures: Enable a new AVX512 CPU feature · 018ebca8
      Gayatri Kammela 提交于
      Add a new AVX512 instruction group/feature for enumeration in
      /proc/cpuinfo: AVX512_VP2INTERSECT.
      
      CPUID.(EAX=7,ECX=0):EDX[bit 8]  AVX512_VP2INTERSECT
      
      Detailed information of CPUID bits for this feature can be found in
      the Intel Architecture Intsruction Set Extensions Programming Reference
      document (refer to Table 1-2). A copy of this document is available at
      https://bugzilla.kernel.org/show_bug.cgi?id=204215.
      Signed-off-by: NGayatri Kammela <gayatri.kammela@intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190717234632.32673-3-gayatri.kammela@intel.com
      018ebca8
  32. 09 7月, 2019 1 次提交
    • J
      x86/speculation: Prepare entry code for Spectre v1 swapgs mitigations · 18ec54fd
      Josh Poimboeuf 提交于
      
      Spectre v1 isn't only about array bounds checks.  It can affect any
      conditional checks.  The kernel entry code interrupt, exception, and NMI
      handlers all have conditional swapgs checks.  Those may be problematic in
      the context of Spectre v1, as kernel code can speculatively run with a user
      GS.
      
      For example:
      
      	if (coming from user space)
      		swapgs
      	mov %gs:<percpu_offset>, %reg
      	mov (%reg), %reg1
      
      When coming from user space, the CPU can speculatively skip the swapgs, and
      then do a speculative percpu load using the user GS value.  So the user can
      speculatively force a read of any kernel value.  If a gadget exists which
      uses the percpu value as an address in another load/store, then the
      contents of the kernel value may become visible via an L1 side channel
      attack.
      
      A similar attack exists when coming from kernel space.  The CPU can
      speculatively do the swapgs, causing the user GS to get used for the rest
      of the speculative window.
      
      The mitigation is similar to a traditional Spectre v1 mitigation, except:
      
        a) index masking isn't possible; because the index (percpu offset)
           isn't user-controlled; and
      
        b) an lfence is needed in both the "from user" swapgs path and the
           "from kernel" non-swapgs path (because of the two attacks described
           above).
      
      The user entry swapgs paths already have SWITCH_TO_KERNEL_CR3, which has a
      CR3 write when PTI is enabled.  Since CR3 writes are serializing, the
      lfences can be skipped in those cases.
      
      On the other hand, the kernel entry swapgs paths don't depend on PTI.
      
      To avoid unnecessary lfences for the user entry case, create two separate
      features for alternative patching:
      
        X86_FEATURE_FENCE_SWAPGS_USER
        X86_FEATURE_FENCE_SWAPGS_KERNEL
      
      Use these features in entry code to patch in lfences where needed.
      
      The features aren't enabled yet, so there's no functional change.
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NDave Hansen <dave.hansen@intel.com>
      18ec54fd
  33. 24 6月, 2019 1 次提交
    • F
      x86/cpufeatures: Enumerate user wait instructions · 6dbbf5ec
      Fenghua Yu 提交于
      umonitor, umwait, and tpause are a set of user wait instructions.
      
      umonitor arms address monitoring hardware using an address. The
      address range is determined by using CPUID.0x5. A store to
      an address within the specified address range triggers the
      monitoring hardware to wake up the processor waiting in umwait.
      
      umwait instructs the processor to enter an implementation-dependent
      optimized state while monitoring a range of addresses. The optimized
      state may be either a light-weight power/performance optimized state
      (C0.1 state) or an improved power/performance optimized state
      (C0.2 state).
      
      tpause instructs the processor to enter an implementation-dependent
      optimized state C0.1 or C0.2 state and wake up when time-stamp counter
      reaches specified timeout.
      
      The three instructions may be executed at any privilege level.
      
      The instructions provide power saving method while waiting in
      user space. Additionally, they can allow a sibling hyperthread to
      make faster progress while this thread is waiting. One example of an
      application usage of umwait is when waiting for input data from another
      application, such as a user level multi-threaded packet processing
      engine.
      
      Availability of the user wait instructions is indicated by the presence
      of the CPUID feature flag WAITPKG CPUID.0x07.0x0:ECX[5].
      
      Detailed information on the instructions and CPUID feature WAITPKG flag
      can be found in the latest Intel Architecture Instruction Set Extensions
      and Future Features Programming Reference and Intel 64 and IA-32
      Architectures Software Developer's Manual.
      Signed-off-by: NFenghua Yu <fenghua.yu@intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NAshok Raj <ashok.raj@intel.com>
      Reviewed-by: NAndy Lutomirski <luto@kernel.org>
      Cc: "Borislav Petkov" <bp@alien8.de>
      Cc: "H Peter Anvin" <hpa@zytor.com>
      Cc: "Peter Zijlstra" <peterz@infradead.org>
      Cc: "Tony Luck" <tony.luck@intel.com>
      Cc: "Ravi V Shankar" <ravi.v.shankar@intel.com>
      Link: https://lkml.kernel.org/r/1560994438-235698-2-git-send-email-fenghua.yu@intel.com
      6dbbf5ec
  34. 20 6月, 2019 2 次提交
    • F
      x86/cpufeatures: Enumerate the new AVX512 BFLOAT16 instructions · b302e4b1
      Fenghua Yu 提交于
      AVX512 BFLOAT16 instructions support 16-bit BFLOAT16 floating-point
      format (BF16) for deep learning optimization.
      
      BF16 is a short version of 32-bit single-precision floating-point
      format (FP32) and has several advantages over 16-bit half-precision
      floating-point format (FP16). BF16 keeps FP32 accumulation after
      multiplication without loss of precision, offers more than enough
      range for deep learning training tasks, and doesn't need to handle
      hardware exception.
      
      AVX512 BFLOAT16 instructions are enumerated in CPUID.7.1:EAX[bit 5]
      AVX512_BF16.
      
      CPUID.7.1:EAX contains only feature bits. Reuse the currently empty
      word 12 as a pure features word to hold the feature bits including
      AVX512_BF16.
      
      Detailed information of the CPUID bit and AVX512 BFLOAT16 instructions
      can be found in the latest Intel Architecture Instruction Set Extensions
      and Future Features Programming Reference.
      
       [ bp: Check CPUID(7) subleaf validity before accessing subleaf 1. ]
      Signed-off-by: NFenghua Yu <fenghua.yu@intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: "Chang S. Bae" <chang.seok.bae@intel.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nadav Amit <namit@vmware.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
      Cc: Peter Feiner <pfeiner@google.com>
      Cc: Radim Krcmar <rkrcmar@redhat.com>
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Cc: "Ravi V Shankar" <ravi.v.shankar@intel.com>
      Cc: Robert Hoo <robert.hu@linux.intel.com>
      Cc: "Sean J Christopherson" <sean.j.christopherson@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
      Cc: x86 <x86@kernel.org>
      Link: https://lkml.kernel.org/r/1560794416-217638-3-git-send-email-fenghua.yu@intel.com
      b302e4b1
    • F
      x86/cpufeatures: Combine word 11 and 12 into a new scattered features word · acec0ce0
      Fenghua Yu 提交于
      It's a waste for the four X86_FEATURE_CQM_* feature bits to occupy two
      whole feature bits words. To better utilize feature words, re-define
      word 11 to host scattered features and move the four X86_FEATURE_CQM_*
      features into Linux defined word 11. More scattered features can be
      added in word 11 in the future.
      
      Rename leaf 11 in cpuid_leafs to CPUID_LNX_4 to reflect it's a
      Linux-defined leaf.
      
      Rename leaf 12 as CPUID_DUMMY which will be replaced by a meaningful
      name in the next patch when CPUID.7.1:EAX occupies world 12.
      
      Maximum number of RMID and cache occupancy scale are retrieved from
      CPUID.0xf.1 after scattered CQM features are enumerated. Carve out the
      code into a separate function.
      
      KVM doesn't support resctrl now. So it's safe to move the
      X86_FEATURE_CQM_* features to scattered features word 11 for KVM.
      Signed-off-by: NFenghua Yu <fenghua.yu@intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Aaron Lewis <aaronlewis@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Babu Moger <babu.moger@amd.com>
      Cc: "Chang S. Bae" <chang.seok.bae@intel.com>
      Cc: "Sean J Christopherson" <sean.j.christopherson@intel.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: kvm ML <kvm@vger.kernel.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nadav Amit <namit@vmware.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
      Cc: Peter Feiner <pfeiner@google.com>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Cc: Ravi V Shankar <ravi.v.shankar@intel.com>
      Cc: Sherry Hurwitz <sherry.hurwitz@amd.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
      Cc: x86 <x86@kernel.org>
      Link: https://lkml.kernel.org/r/1560794416-217638-2-git-send-email-fenghua.yu@intel.com
      acec0ce0