1. 21 4月, 2020 3 次提交
    • V
      KVM: x86: make Hyper-V PV TLB flush use tlb_flush_guest() · 0baedd79
      Vitaly Kuznetsov 提交于
      Hyper-V PV TLB flush mechanism does TLB flush on behalf of the guest
      so doing tlb_flush_all() is an overkill, switch to using tlb_flush_guest()
      (just like KVM PV TLB flush mechanism) instead. Introduce
      KVM_REQ_HV_TLB_FLUSH to support the change.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0baedd79
    • S
      KVM: x86: Move "flush guest's TLB" logic to separate kvm_x86_ops hook · e64419d9
      Sean Christopherson 提交于
      Add a dedicated hook to handle flushing TLB entries on behalf of the
      guest, i.e. for a paravirtualized TLB flush, and use it directly instead
      of bouncing through kvm_vcpu_flush_tlb().
      
      For VMX, change the effective implementation implementation to never do
      INVEPT and flush only the current context, i.e. to always flush via
      INVVPID(SINGLE_CONTEXT).  The INVEPT performed by __vmx_flush_tlb() when
      @invalidate_gpa=false and enable_vpid=0 is unnecessary, as it will only
      flush guest-physical mappings; linear and combined mappings are flushed
      by VM-Enter when VPID is disabled, and changes in the guest pages tables
      do not affect guest-physical mappings.
      
      When EPT and VPID are enabled, doing INVVPID is not required (by Intel's
      architecture) to invalidate guest-physical mappings, i.e. TLB entries
      that cache guest-physical mappings can live across INVVPID as the
      mappings are associated with an EPTP, not a VPID.  The intent of
      @invalidate_gpa is to inform vmx_flush_tlb() that it must "invalidate
      gpa mappings", i.e. do INVEPT and not simply INVVPID.  Other than nested
      VPID handling, which now calls vpid_sync_context() directly, the only
      scenario where KVM can safely do INVVPID instead of INVEPT (when EPT is
      enabled) is if KVM is flushing TLB entries from the guest's perspective,
      i.e. is only required to invalidate linear mappings.
      
      For SVM, flushing TLB entries from the guest's perspective can be done
      by flushing the current ASID, as changes to the guest's page tables are
      associated only with the current ASID.
      
      Adding a dedicated ->tlb_flush_guest() paves the way toward removing
      @invalidate_gpa, which is a potentially dangerous control flag as its
      meaning is not exactly crystal clear, even for those who are familiar
      with the subtleties of what mappings Intel CPUs are/aren't allowed to
      keep across various invalidation scenarios.
      Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200320212833.3507-15-sean.j.christopherson@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e64419d9
    • P
      KVM: x86: introduce kvm_mmu_invalidate_gva · 5efac074
      Paolo Bonzini 提交于
      Wrap the combination of mmu->invlpg and kvm_x86_ops->tlb_flush_gva
      into a new function.  This function also lets us specify the host PGD to
      invalidate and also the MMU, both of which will be useful in fixing and
      simplifying kvm_inject_emulated_page_fault.
      
      A nested guest's MMU however has g_context->invlpg == NULL.  Instead of
      setting it to nonpaging_invlpg, make kvm_mmu_invalidate_gva the only
      entry point to mmu->invlpg and make a NULL invlpg pointer equivalent
      to nonpaging_invlpg, saving a retpoline.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5efac074
  2. 16 4月, 2020 1 次提交
  3. 14 4月, 2020 1 次提交
  4. 03 4月, 2020 2 次提交
    • A
      mm/vma: make vma_is_foreign() available for general use · 7969f226
      Anshuman Khandual 提交于
      Idea of a foreign VMA with respect to the present context is very generic.
      But currently there are two identical definitions for this in powerpc and
      x86 platforms.  Lets consolidate those redundant definitions while making
      vma_is_foreign() available for general use later.  This should not cause
      any functional change.
      Signed-off-by: NAnshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Link: http://lkml.kernel.org/r/1582782965-3274-3-git-send-email-anshuman.khandual@arm.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7969f226
    • M
      asm-generic: make more kernel-space headers mandatory · 630f289b
      Masahiro Yamada 提交于
      Change a header to mandatory-y if both of the following are met:
      
      [1] At least one architecture (except um) specifies it as generic-y in
          arch/*/include/asm/Kbuild
      
      [2] Every architecture (except um) either has its own implementation
          (arch/*/include/asm/*.h) or specifies it as generic-y in
          arch/*/include/asm/Kbuild
      
      This commit was generated by the following shell script.
      
      ----------------------------------->8-----------------------------------
      
      arches=$(cd arch; ls -1 | sed -e '/Kconfig/d' -e '/um/d')
      
      tmpfile=$(mktemp)
      
      grep "^mandatory-y +=" include/asm-generic/Kbuild > $tmpfile
      
      find arch -path 'arch/*/include/asm/Kbuild' |
      	xargs sed -n 's/^generic-y += \(.*\)/\1/p' | sort -u |
      while read header
      do
      	mandatory=yes
      
      	for arch in $arches
      	do
      		if ! grep -q "generic-y += $header" arch/$arch/include/asm/Kbuild &&
      			! [ -f arch/$arch/include/asm/$header ]; then
      			mandatory=no
      			break
      		fi
      	done
      
      	if [ "$mandatory" = yes ]; then
      		echo "mandatory-y += $header" >> $tmpfile
      
      		for arch in $arches
      		do
      			sed -i "/generic-y += $header/d" arch/$arch/include/asm/Kbuild
      		done
      	fi
      
      done
      
      sed -i '/^mandatory-y +=/d' include/asm-generic/Kbuild
      
      LANG=C sort $tmpfile >> include/asm-generic/Kbuild
      
      ----------------------------------->8-----------------------------------
      
      One obvious benefit is the diff stat:
      
       25 files changed, 52 insertions(+), 557 deletions(-)
      
      It is tedious to list generic-y for each arch that needs it.
      
      So, mandatory-y works like a fallback default (by just wrapping
      asm-generic one) when arch does not have a specific header
      implementation.
      
      See the following commits:
      
      def3f7ce
      a1b39bae
      
      It is tedious to convert headers one by one, so I processed by a shell
      script.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Link: http://lkml.kernel.org/r/20200210175452.5030-1-masahiroy@kernel.orgSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      630f289b
  5. 02 4月, 2020 3 次提交
    • L
      x86: start using named parameters for low-level uaccess asms · 890f0b0d
      Linus Torvalds 提交于
      This is partly for readability - using named arguments instead of
      numbered ones makes it muchmore obvious just what is going on.  Using
      "%[efault]" instead of "%4" for the special -EFAULT constant just means
      that you don't have to count the arguments to see what's up.
      
      But the motivation for all this cleanup is that when we'll start to
      conditionally use "asm goto" even for the __get_user_asm() case, the
      argument numbers will depend on whether we have an error output, or an
      error label we can just directly jump to.
      
      So this moves us towards named arguments for the same reason that we
      have to use named arguments for the asms that use SET_CC(): numbering
      will eventually become similarly unreliable and depends on whether we
      can use particular compiler features or not.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      890f0b0d
    • L
      x86: get rid of 'rtype' argument to __get_user_asm() macro · 7da63b3d
      Linus Torvalds 提交于
      This is the exact same thing as 36807856 ("x86: get rid of 'rtype'
      argument to __put_user_goto() macro") except it's about __get_user_asm()
      rather than __put_user_goto().
      
      The reasons are the same: having the low-level asm access the argument
      with a different size than the compiler thinks it does is fundamentally
      wrong.
      
      But unlike the __put_user_goto() case, we actually did tell the compiler
      that we used a bigger variable (either long or long long), and then only
      filled in the low bits, and ended up "fixing" this by casting the result
      to the proper pointer type.
      
      That's because we needed to use a non-qualified type (the user pointer
      might be a const pointer!), and that makes this a bit more painful.  Our
      '__inttype()' macro used to be lazy and only differentiate between "fits
      in a register" or "needs two registers".
      
      So this fix had to also make that '__inttype()' macro more precise.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7da63b3d
    • L
      x86: get rid of 'rtype' argument to __put_user_goto() macro · 36807856
      Linus Torvalds 提交于
      The 'rtype' argument goes back to pre-git (and pre-BK) times, and comes
      from the fact that we used to not necessarily have the same type sizes
      for the arguments of the inline asm as we did for the actual accesses we
      did.
      
      So 'rtype' is the 'register type' - the override of the register size in
      the inline asm when it doesn't match the actual size of the variable we
      use as the output argument (for when you used "put_user()" on an "int"
      value that was assigned to a byte-sized user space access etc).
      
      That mismatch doesn't actually exist any more, and should probably never
      have existed in the first place.  It's a horrid bug just waiting to
      happen (using more - or less - of the variable that the compiler
      expected us to use).
      
      I think we had some odd casting going on to hide the effects of that
      oddity after-the-fact, but those are long gone, and these days we should
      always have the right size value in the first place, using things like
      
              __typeof__(*(ptr)) __pu_val = (x);
      
      and gcc should thus have the right register size without any manual
      'rtype' games.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      36807856
  6. 01 4月, 2020 2 次提交
  7. 31 3月, 2020 3 次提交
  8. 28 3月, 2020 4 次提交
  9. 27 3月, 2020 3 次提交
  10. 25 3月, 2020 4 次提交
  11. 24 3月, 2020 1 次提交
    • V
      um: Fix header inclusion · 1c1a18b0
      Vincenzo Frascino 提交于
      User Mode Linux is a flavor of x86 that from the vDSO prospective always
      falls back on system calls. This implies that it does not require any
      of the unified vDSO definitions and their inclusion causes side effects
      like this:
      
        In file included from include/vdso/processor.h:10:0,
                            from include/vdso/datapage.h:17,
                            from arch/x86/include/asm/vgtod.h:7,
                            from arch/x86/um/../kernel/sys_ia32.c:49:
        >> arch/x86/include/asm/vdso/processor.h:11:29: error: redefinition of 'rep_nop'
            static __always_inline void rep_nop(void)
                                        ^~~~~~~
           In file included from include/linux/rcupdate.h:30:0,
                            from include/linux/rculist.h:11,
                            from include/linux/pid.h:5,
                            from include/linux/sched.h:14,
                            from arch/x86/um/../kernel/sys_ia32.c:25:
           arch/x86/um/asm/processor.h:24:20: note: previous definition of 'rep_nop' was here
            static inline void rep_nop(void)
      
      Make sure that the unnecessary headers are not included when um is built
      to address the problem.
      
      Fixes: abc22418 ("x86/vdso: Enable x86 to use common headers")
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NVincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/20200323124109.7104-1-vincenzo.frascino@arm.com
      1c1a18b0
  12. 23 3月, 2020 1 次提交
  13. 22 3月, 2020 1 次提交
  14. 21 3月, 2020 11 次提交