1. 01 11月, 2019 6 次提交
  2. 31 10月, 2019 4 次提交
    • B
      arm64: cpufeature: Enable Qualcomm Falkor errata 1009 for Kryo · 36c602dc
      Bjorn Andersson 提交于
      The Kryo cores share errata 1009 with Falkor, so add their model
      definitions and enable it for them as well.
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      [will: Update entry in silicon-errata.rst]
      Signed-off-by: NWill Deacon <will@kernel.org>
      36c602dc
    • P
      KVM: vmx, svm: always run with EFER.NXE=1 when shadow paging is active · 9167ab79
      Paolo Bonzini 提交于
      VMX already does so if the host has SMEP, in order to support the combination of
      CR0.WP=1 and CR4.SMEP=1.  However, it is perfectly safe to always do so, and in
      fact VMX already ends up running with EFER.NXE=1 on old processors that lack the
      "load EFER" controls, because it may help avoiding a slow MSR write.  Removing
      all the conditionals simplifies the code.
      
      SVM does not have similar code, but it should since recent AMD processors do
      support SMEP.  So this patch also makes the code for the two vendors more similar
      while fixing NPT=0, CR0.WP=1 and CR4.SMEP=1 on AMD processors.
      
      Cc: stable@vger.kernel.org
      Cc: Joerg Roedel <jroedel@suse.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9167ab79
    • K
      x86, efi: Never relocate kernel below lowest acceptable address · 220dd769
      Kairui Song 提交于
      Currently, kernel fails to boot on some HyperV VMs when using EFI.
      And it's a potential issue on all x86 platforms.
      
      It's caused by broken kernel relocation on EFI systems, when below three
      conditions are met:
      
      1. Kernel image is not loaded to the default address (LOAD_PHYSICAL_ADDR)
         by the loader.
      2. There isn't enough room to contain the kernel, starting from the
         default load address (eg. something else occupied part the region).
      3. In the memmap provided by EFI firmware, there is a memory region
         starts below LOAD_PHYSICAL_ADDR, and suitable for containing the
         kernel.
      
      EFI stub will perform a kernel relocation when condition 1 is met. But
      due to condition 2, EFI stub can't relocate kernel to the preferred
      address, so it fallback to ask EFI firmware to alloc lowest usable memory
      region, got the low region mentioned in condition 3, and relocated
      kernel there.
      
      It's incorrect to relocate the kernel below LOAD_PHYSICAL_ADDR. This
      is the lowest acceptable kernel relocation address.
      
      The first thing goes wrong is in arch/x86/boot/compressed/head_64.S.
      Kernel decompression will force use LOAD_PHYSICAL_ADDR as the output
      address if kernel is located below it. Then the relocation before
      decompression, which move kernel to the end of the decompression buffer,
      will overwrite other memory region, as there is no enough memory there.
      
      To fix it, just don't let EFI stub relocate the kernel to any address
      lower than lowest acceptable address.
      
      [ ardb: introduce efi_low_alloc_above() to reduce the scope of the change ]
      Signed-off-by: NKairui Song <kasong@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20191029173755.27149-6-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      220dd769
    • S
      parisc: fix frame pointer in ftrace_regs_caller() · 3d252454
      Sven Schnelle 提交于
      The current code in ftrace_regs_caller() doesn't assign
      %r3 to contain the address of the current frame. This
      is hidden if the kernel is compiled with FRAME_POINTER,
      but without it just crashes because it tries to dereference
      an arbitrary address. Fix this by always setting %r3 to the
      current stack frame.
      Signed-off-by: NSven Schnelle <svens@stackframe.org>
      Signed-off-by: NHelge Deller <deller@gmx.de>
      3d252454
  3. 30 10月, 2019 3 次提交
    • B
      arm64: cpufeature: Enable Qualcomm Falkor/Kryo errata 1003 · d4af3c4b
      Bjorn Andersson 提交于
      With the introduction of 'cce360b5 ("arm64: capabilities: Filter the
      entries based on a given mask")' the Qualcomm Falkor/Kryo errata 1003 is
      no long applied.
      
      The result of not applying errata 1003 is that MSM8996 runs into various
      RCU stalls and fails to boot most of the times.
      
      Give 1003 a "type" to ensure they are not filtered out in
      update_cpu_capabilities().
      
      Fixes: cce360b5 ("arm64: capabilities: Filter the entries based on a given mask")
      Cc: stable@vger.kernel.org
      Reported-by: NMark Brown <broonie@kernel.org>
      Suggested-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: NWill Deacon <will@kernel.org>
      d4af3c4b
    • C
      arm64: Ensure VM_WRITE|VM_SHARED ptes are clean by default · aa57157b
      Catalin Marinas 提交于
      Shared and writable mappings (__S.1.) should be clean (!dirty) initially
      and made dirty on a subsequent write either through the hardware DBM
      (dirty bit management) mechanism or through a write page fault. A clean
      pte for the arm64 kernel is one that has PTE_RDONLY set and PTE_DIRTY
      clear.
      
      The PAGE_SHARED{,_EXEC} attributes have PTE_WRITE set (PTE_DBM) and
      PTE_DIRTY clear. Prior to commit 73e86cb0 ("arm64: Move PTE_RDONLY
      bit handling out of set_pte_at()"), it was the responsibility of
      set_pte_at() to set the PTE_RDONLY bit and mark the pte clean if the
      software PTE_DIRTY bit was not set. However, the above commit removed
      the pte_sw_dirty() check and the subsequent setting of PTE_RDONLY in
      set_pte_at() while leaving the PAGE_SHARED{,_EXEC} definitions
      unchanged. The result is that shared+writable mappings are now dirty by
      default
      
      Fix the above by explicitly setting PTE_RDONLY in PAGE_SHARED{,_EXEC}.
      In addition, remove the superfluous PTE_DIRTY bit from the kernel PROT_*
      attributes.
      
      Fixes: 73e86cb0 ("arm64: Move PTE_RDONLY bit handling out of set_pte_at()")
      Cc: <stable@vger.kernel.org> # 4.14.x-
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      aa57157b
    • A
      um-ubd: Entrust re-queue to the upper layers · d848074b
      Anton Ivanov 提交于
      Fixes crashes due to ubd requeue logic conflicting with the block-mq
      logic. Crash is reproducible in 5.0 - 5.3.
      
      Fixes: 53766def ("um: Clean-up command processing in UML UBD driver")
      Cc: stable@vger.kernel.org # v5.0+
      Signed-off-by: NAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      d848074b
  4. 29 10月, 2019 3 次提交
  5. 28 10月, 2019 17 次提交
    • K
      perf/x86/uncore: Fix event group support · 75be6f70
      Kan Liang 提交于
      The events in the same group don't start or stop simultaneously.
      Here is the ftrace when enabling event group for uncore_iio_0:
      
        # perf stat -e "{uncore_iio_0/event=0x1/,uncore_iio_0/event=0xe/}"
      
                  <idle>-0     [000] d.h.  8959.064832: read_msr: a41, value
        b2b0b030		//Read counter reg of IIO unit0 counter0
                  <idle>-0     [000] d.h.  8959.064835: write_msr: a48, value
        400001			//Write Ctrl reg of IIO unit0 counter0 to enable
        counter0. <------ Although counter0 is enabled, Unit Ctrl is still
        freezed. Nothing will count. We are still good here.
                  <idle>-0     [000] d.h.  8959.064836: read_msr: a40, value
        30100                   //Read Unit Ctrl reg of IIO unit0
                  <idle>-0     [000] d.h.  8959.064838: write_msr: a40, value
        30000			//Write Unit Ctrl reg of IIO unit0 to enable all
        counters in the unit by clear Freeze bit  <------Unit0 is un-freezed.
        Counter0 has been enabled. Now it starts counting. But counter1 has not
        been enabled yet. The issue starts here.
                  <idle>-0     [000] d.h.  8959.064846: read_msr: a42, value 0
      			//Read counter reg of IIO unit0 counter1
                  <idle>-0     [000] d.h.  8959.064847: write_msr: a49, value
        40000e			//Write Ctrl reg of IIO unit0 counter1 to enable
        counter1.   <------ Now, counter1 just starts to count. Counter0 has
        been running for a while.
      
      Current code un-freezes the Unit Ctrl right after the first counter is
      enabled. The subsequent group events always loses some counter values.
      
      Implement pmu_enable and pmu_disable support for uncore, which can help
      to batch hardware accesses.
      
      No one uses uncore_enable_box and uncore_disable_box. Remove them.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: linux-drivers-review@eclists.intel.com
      Cc: linux-perf@eclists.intel.com
      Fixes: 087bfbb0 ("perf/x86: Add generic Intel uncore PMU support")
      Link: https://lkml.kernel.org/r/1572014593-31591-1-git-send-email-kan.liang@linux.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      75be6f70
    • K
      perf/x86/amd/ibs: Handle erratum #420 only on the affected CPU family (10h) · e431e79b
      Kim Phillips 提交于
      This saves us writing the IBS control MSR twice when disabling the
      event.
      
      I searched revision guides for all families since 10h, and did not
      find occurrence of erratum #420, nor anything remotely similar:
      so we isolate the secondary MSR write to family 10h only.
      
      Also unconditionally update the count mask for IBS Op implementations
      that have read & writeable current count (CurCnt) fields in addition
      to the MaxCnt field.  These bits were reserved on prior
      implementations, and therefore shouldn't have negative impact.
      Signed-off-by: NKim Phillips <kim.phillips@amd.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Fixes: c9574fe0 ("perf/x86-ibs: Implement workaround for IBS erratum #420")
      Link: https://lkml.kernel.org/r/20191023150955.30292-2-kim.phillips@amd.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e431e79b
    • K
      perf/x86/amd/ibs: Fix reading of the IBS OpData register and thus precise RIP validity · 317b96bb
      Kim Phillips 提交于
      The loop that reads all the IBS MSRs into *buf stopped one MSR short of
      reading the IbsOpData register, which contains the RipInvalid status bit.
      
      Fix the offset_max assignment so the MSR gets read, so the RIP invalid
      evaluation is based on what the IBS h/w output, instead of what was
      left in memory.
      Signed-off-by: NKim Phillips <kim.phillips@amd.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Fixes: d47e8238 ("perf/x86-ibs: Take instruction pointer from ibs sample")
      Link: https://lkml.kernel.org/r/20191023150955.30292-1-kim.phillips@amd.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      317b96bb
    • M
      x86/tsx: Add config options to set tsx=on|off|auto · db616173
      Michal Hocko 提交于
      There is a general consensus that TSX usage is not largely spread while
      the history shows there is a non trivial space for side channel attacks
      possible. Therefore the tsx is disabled by default even on platforms
      that might have a safe implementation of TSX according to the current
      knowledge. This is a fair trade off to make.
      
      There are, however, workloads that really do benefit from using TSX and
      updating to a newer kernel with TSX disabled might introduce a
      noticeable regressions. This would be especially a problem for Linux
      distributions which will provide TAA mitigations.
      
      Introduce config options X86_INTEL_TSX_MODE_OFF, X86_INTEL_TSX_MODE_ON
      and X86_INTEL_TSX_MODE_AUTO to control the TSX feature. The config
      setting can be overridden by the tsx cmdline options.
      
       [ bp: Text cleanups from Josh. ]
      Suggested-by: NBorislav Petkov <bpetkov@suse.de>
      Signed-off-by: NMichal Hocko <mhocko@suse.com>
      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>
      db616173
    • P
      riscv: for C functions called only from assembly, mark with __visible · f3073079
      Paul Walmsley 提交于
      Rather than adding prototypes for C functions called only by assembly
      code, mark them as __visible.  This avoids adding prototypes that will
      never be used by the callers.  Resolves the following sparse warnings:
      
      arch/riscv/kernel/irq.c:27:29: warning: symbol 'do_IRQ' was not declared. Should it be static?
      arch/riscv/kernel/ptrace.c:151:6: warning: symbol 'do_syscall_trace_enter' was not declared. Should it be static?
      arch/riscv/kernel/ptrace.c:165:6: warning: symbol 'do_syscall_trace_exit' was not declared. Should it be static?
      arch/riscv/kernel/signal.c:295:17: warning: symbol 'do_notify_resume' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:92:1: warning: symbol 'do_trap_unknown' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:94:1: warning: symbol 'do_trap_insn_misaligned' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:96:1: warning: symbol 'do_trap_insn_fault' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:98:1: warning: symbol 'do_trap_insn_illegal' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:100:1: warning: symbol 'do_trap_load_misaligned' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:102:1: warning: symbol 'do_trap_load_fault' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:104:1: warning: symbol 'do_trap_store_misaligned' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:106:1: warning: symbol 'do_trap_store_fault' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:108:1: warning: symbol 'do_trap_ecall_u' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:110:1: warning: symbol 'do_trap_ecall_s' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:112:1: warning: symbol 'do_trap_ecall_m' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:124:17: warning: symbol 'do_trap_break' was not declared. Should it be static?
      arch/riscv/kernel/smpboot.c:136:24: warning: symbol 'smp_callin' was not declared. Should it be static?
      
      Based on a suggestion from Luc Van Oostenryck.
      
      This version includes changes based on feedback from Christoph Hellwig
      <hch@lst.de>.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Reviewed-by: Christoph Hellwig <hch@lst.de> # for do_syscall_trace_*
      f3073079
    • P
      riscv: fp: add missing __user pointer annotations · a48dac44
      Paul Walmsley 提交于
      The __user annotations were removed from the {save,restore}_fp_state()
      function signatures by commit 007f5c35 ("Refactor FPU code in
      signal setup/return procedures"), but should be present, and sparse
      warns when they are not applied.  Add them back in.
      
      This change should have no functional impact.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Fixes: 007f5c35 ("Refactor FPU code in signal setup/return procedures")
      Cc: Alan Kao <alankao@andestech.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      a48dac44
    • P
      riscv: add missing header file includes · 5ed881bc
      Paul Walmsley 提交于
      sparse identifies several missing prototypes caused by missing
      preprocessor include directives:
      
      arch/riscv/kernel/cpufeature.c:16:6: warning: symbol 'has_fpu' was not declared. Should it be static?
      arch/riscv/kernel/process.c:26:6: warning: symbol 'arch_cpu_idle' was not declared. Should it be static?
      arch/riscv/kernel/reset.c:15:6: warning: symbol 'pm_power_off' was not declared. Should it be static?
      arch/riscv/kernel/syscall_table.c:15:6: warning: symbol 'sys_call_table' was not declared. Should it be static?
      arch/riscv/kernel/traps.c:149:13: warning: symbol 'trap_init' was not declared. Should it be static?
      arch/riscv/kernel/vdso.c:54:5: warning: symbol 'arch_setup_additional_pages' was not declared. Should it be static?
      arch/riscv/kernel/smp.c:64:6: warning: symbol 'arch_match_cpu_phys_id' was not declared. Should it be static?
      arch/riscv/kernel/module-sections.c:89:5: warning: symbol 'module_frob_arch_sections' was not declared. Should it be static?
      arch/riscv/mm/context.c:42:6: warning: symbol 'switch_mm' was not declared. Should it be static?
      
      Fix by including the appropriate header files in the appropriate
      source files.
      
      This patch should have no functional impact.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      5ed881bc
    • P
      riscv: mark some code and data as file-static · bf6df5dd
      Paul Walmsley 提交于
      Several functions and arrays which are only used in the files in which
      they are declared are missing "static" qualifiers.  Warnings for these
      symbols are reported by sparse:
      
      arch/riscv/kernel/vdso.c:28:18: warning: symbol 'vdso_data' was not declared. Should it be static?
      arch/riscv/mm/sifive_l2_cache.c:145:12: warning: symbol 'sifive_l2_init' was not declared. Should it be static?
      
      Resolve these warnings by marking them as static.
      
      This version incorporates feedback from Greentime Hu
      <greentime.hu@sifive.com>.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Greentime Hu <greentime.hu@sifive.com>
      bf6df5dd
    • P
      riscv: init: merge split string literals in preprocessor directive · 6a527b67
      Paul Walmsley 提交于
      sparse complains loudly when string literals associated with
      preprocessor directives are split into multiple, separately quoted
      strings across different lines:
      
      arch/riscv/mm/init.c:341:9: error: Expected ; at the end of type declaration
      arch/riscv/mm/init.c:341:9: error: got "not use absolute addressing."
      arch/riscv/mm/init.c:358:9: error: Trying to use reserved word 'do' as identifier
      arch/riscv/mm/init.c:358:9: error: Expected ; at end of declaration
      [ ... ]
      
      It turns out this doesn't compile.  The existing Linux practice for
      this situation is simply to use a single long line.  So, fix by
      concatenating the strings.
      
      This patch should have no functional impact.
      
      This version incorporates changes based on feedback from Luc Van
      Oostenryck <luc.vanoostenryck@gmail.com>.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Reviewed-by: NLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/linux-riscv/CAAhSdy2nX2LwEEAZuMtW_ByGTkHO6KaUEvVxRnba_ENEjmFayQ@mail.gmail.com/T/#mc1a58bc864f71278123d19a7abc083a9c8e37033
      Fixes: 387181dc ("RISC-V: Always compile mm/init.c with cmodel=medany and notrace")
      Cc: Anup Patel <anup.patel@wdc.com>
      6a527b67
    • P
      riscv: add prototypes for assembly language functions from head.S · ffaee272
      Paul Walmsley 提交于
      Add prototypes for assembly language functions defined in head.S,
      and include these prototypes into C source files that call those
      functions.
      
      This patch resolves the following warnings from sparse:
      
      arch/riscv/kernel/setup.c:39:10: warning: symbol 'hart_lottery' was not declared. Should it be static?
      arch/riscv/kernel/setup.c:42:13: warning: symbol 'parse_dtb' was not declared. Should it be static?
      arch/riscv/kernel/smpboot.c:33:6: warning: symbol '__cpu_up_stack_pointer' was not declared. Should it be static?
      arch/riscv/kernel/smpboot.c:34:6: warning: symbol '__cpu_up_task_pointer' was not declared. Should it be static?
      arch/riscv/mm/fault.c:25:17: warning: symbol 'do_page_fault' was not declared. Should it be static?
      
      This change should have no functional impact.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      ffaee272
    • P
      x86/tsx: Add "auto" option to the tsx= cmdline parameter · 7531a359
      Pawan Gupta 提交于
      Platforms which are not affected by X86_BUG_TAA may want the TSX feature
      enabled. Add "auto" option to the TSX cmdline parameter. When tsx=auto
      disable TSX when X86_BUG_TAA is present, otherwise enable TSX.
      
      More details on X86_BUG_TAA can be found here:
      https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html
      
       [ bp: Extend the arg buffer to accommodate "auto\0". ]
      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: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      7531a359
    • P
      kvm/x86: Export MDS_NO=0 to guests when TSX is enabled · e1d38b63
      Pawan Gupta 提交于
      Export the IA32_ARCH_CAPABILITIES MSR bit MDS_NO=0 to guests on TSX
      Async Abort(TAA) affected hosts that have TSX enabled and updated
      microcode. This is required so that the guests don't complain,
      
        "Vulnerable: Clear CPU buffers attempted, no microcode"
      
      when the host has the updated microcode to clear CPU buffers.
      
      Microcode update also adds support for MSR_IA32_TSX_CTRL which is
      enumerated by the ARCH_CAP_TSX_CTRL bit in IA32_ARCH_CAPABILITIES MSR.
      Guests can't do this check themselves when the ARCH_CAP_TSX_CTRL bit is
      not exported to the guests.
      
      In this case export MDS_NO=0 to the guests. When guests have
      CPUID.MD_CLEAR=1, they deploy MDS mitigation which also mitigates TAA.
      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>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      e1d38b63
    • P
      x86/speculation/taa: Add sysfs reporting for TSX Async Abort · 6608b45a
      Pawan Gupta 提交于
      Add the sysfs reporting file for TSX Async Abort. It exposes the
      vulnerability and the mitigation state similar to the existing files for
      the other hardware vulnerabilities.
      
      Sysfs file path is:
      /sys/devices/system/cpu/vulnerabilities/tsx_async_abort
      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>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      Reviewed-by: NMark Gross <mgross@linux.intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      6608b45a
    • 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
    • P
      x86/cpu: Add a "tsx=" cmdline option with TSX disabled by default · 95c5824f
      Pawan Gupta 提交于
      Add a kernel cmdline parameter "tsx" to control the Transactional
      Synchronization Extensions (TSX) feature. On CPUs that support TSX
      control, use "tsx=on|off" to enable or disable TSX. Not specifying this
      option is equivalent to "tsx=off". This is because on certain processors
      TSX may be used as a part of a speculative side channel attack.
      
      Carve out the TSX controlling functionality into a separate compilation
      unit because TSX is a CPU feature while the TSX async abort control
      machinery will go to cpu/bugs.c.
      
       [ bp: - Massage, shorten and clear the arg buffer.
             - Clarifications of the tsx= possible options - Josh.
             - Expand on TSX_CTRL availability - Pawan. ]
      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>
      95c5824f
    • P
      x86/cpu: Add a helper function x86_read_arch_cap_msr() · 286836a7
      Pawan Gupta 提交于
      Add a helper function to read the IA32_ARCH_CAPABILITIES MSR.
      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>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      Reviewed-by: NMark Gross <mgross@linux.intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      286836a7
    • P
      x86/msr: Add the IA32_TSX_CTRL MSR · c2955f27
      Pawan Gupta 提交于
      Transactional Synchronization Extensions (TSX) may be used on certain
      processors as part of a speculative side channel attack.  A microcode
      update for existing processors that are vulnerable to this attack will
      add a new MSR - IA32_TSX_CTRL to allow the system administrator the
      option to disable TSX as one of the possible mitigations.
      
      The CPUs which get this new MSR after a microcode upgrade are the ones
      which do not set MSR_IA32_ARCH_CAPABILITIES.MDS_NO (bit 5) because those
      CPUs have CPUID.MD_CLEAR, i.e., the VERW implementation which clears all
      CPU buffers takes care of the TAA case as well.
      
        [ Note that future processors that are not vulnerable will also
          support the IA32_TSX_CTRL MSR. ]
      
      Add defines for the new IA32_TSX_CTRL MSR and its bits.
      
      TSX has two sub-features:
      
      1. Restricted Transactional Memory (RTM) is an explicitly-used feature
         where new instructions begin and end TSX transactions.
      2. Hardware Lock Elision (HLE) is implicitly used when certain kinds of
         "old" style locks are used by software.
      
      Bit 7 of the IA32_ARCH_CAPABILITIES indicates the presence of the
      IA32_TSX_CTRL MSR.
      
      There are two control bits in IA32_TSX_CTRL MSR:
      
        Bit 0: When set, it disables the Restricted Transactional Memory (RTM)
               sub-feature of TSX (will force all transactions to abort on the
      	 XBEGIN instruction).
      
        Bit 1: When set, it disables the enumeration of the RTM and HLE feature
               (i.e. it will make CPUID(EAX=7).EBX{bit4} and
      	  CPUID(EAX=7).EBX{bit11} read as 0).
      
      The other TSX sub-feature, Hardware Lock Elision (HLE), is
      unconditionally disabled by the new microcode but still enumerated
      as present by CPUID(EAX=7).EBX{bit4}, unless disabled by
      IA32_TSX_CTRL_MSR[1] - TSX_CTRL_CPUID_CLEAR.
      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>
      Tested-by: NNeelima Krishnan <neelima.krishnan@intel.com>
      Reviewed-by: NMark Gross <mgross@linux.intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      c2955f27
  6. 26 10月, 2019 1 次提交
  7. 25 10月, 2019 3 次提交
  8. 24 10月, 2019 3 次提交
    • P
      MIPS: tlbex: Fix build_restore_pagemask KScratch restore · b42aa3fd
      Paul Burton 提交于
      build_restore_pagemask() will restore the value of register $1/$at when
      its restore_scratch argument is non-zero, and aims to do so by filling a
      branch delay slot. Commit 0b24cae4 ("MIPS: Add missing EHB in mtc0
      -> mfc0 sequence.") added an EHB instruction (Execution Hazard Barrier)
      prior to restoring $1 from a KScratch register, in order to resolve a
      hazard that can result in stale values of the KScratch register being
      observed. In particular, P-class CPUs from MIPS with out of order
      execution pipelines such as the P5600 & P6600 are affected.
      
      Unfortunately this EHB instruction was inserted in the branch delay slot
      causing the MFC0 instruction which performs the restoration to no longer
      execute along with the branch. The result is that the $1 register isn't
      actually restored, ie. the TLB refill exception handler clobbers it -
      which is exactly the problem the EHB is meant to avoid for the P-class
      CPUs.
      
      Similarly build_get_pgd_vmalloc() will restore the value of $1/$at when
      its mode argument equals refill_scratch, and suffers from the same
      problem.
      
      Fix this by in both cases moving the EHB earlier in the emitted code.
      There's no reason it needs to immediately precede the MFC0 - it simply
      needs to be between the MTC0 & MFC0.
      
      This bug only affects Cavium Octeon systems which use
      build_fast_tlb_refill_handler().
      Signed-off-by: NPaul Burton <paulburton@kernel.org>
      Fixes: 0b24cae4 ("MIPS: Add missing EHB in mtc0 -> mfc0 sequence.")
      Cc: Dmitry Korotin <dkorotin@wavecomp.com>
      Cc: stable@vger.kernel.org # v3.15+
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      b42aa3fd
    • J
      MIPS: bmips: mark exception vectors as char arrays · e4f5cb1a
      Jonas Gorski 提交于
      The vectors span more than one byte, so mark them as arrays.
      
      Fixes the following build error when building when using GCC 8.3:
      
      In file included from ./include/linux/string.h:19,
                       from ./include/linux/bitmap.h:9,
                       from ./include/linux/cpumask.h:12,
                       from ./arch/mips/include/asm/processor.h:15,
                       from ./arch/mips/include/asm/thread_info.h:16,
                       from ./include/linux/thread_info.h:38,
                       from ./include/asm-generic/preempt.h:5,
                       from ./arch/mips/include/generated/asm/preempt.h:1,
                       from ./include/linux/preempt.h:81,
                       from ./include/linux/spinlock.h:51,
                       from ./include/linux/mmzone.h:8,
                       from ./include/linux/bootmem.h:8,
                       from arch/mips/bcm63xx/prom.c:10:
      arch/mips/bcm63xx/prom.c: In function 'prom_init':
      ./arch/mips/include/asm/string.h:162:11: error: '__builtin_memcpy' forming offset [2, 32] is out of the bounds [0, 1] of object 'bmips_smp_movevec' with type 'char' [-Werror=array-bounds]
         __ret = __builtin_memcpy((dst), (src), __len); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      arch/mips/bcm63xx/prom.c:97:3: note: in expansion of macro 'memcpy'
         memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20);
         ^~~~~~
      In file included from arch/mips/bcm63xx/prom.c:14:
      ./arch/mips/include/asm/bmips.h:80:13: note: 'bmips_smp_movevec' declared here
       extern char bmips_smp_movevec;
      
      Fixes: 18a1eef9 ("MIPS: BMIPS: Introduce bmips.h")
      Signed-off-by: NJonas Gorski <jonas.gorski@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NPaul Burton <paulburton@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      e4f5cb1a
    • C
      riscv: cleanup <asm/bug.h> · a6d9e267
      Christoph Hellwig 提交于
      Remove various not required ifdefs and externs.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NAnup Patel <anup@brainfault.org>
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      a6d9e267