1. 29 10月, 2019 2 次提交
    • P
      CPX: KVM: cpuid: do_cpuid_ent works on a whole CPUID function · 9ea2c5e1
      Paolo Bonzini 提交于
      commit ab8bcf64971180e1344ce2c7e70c49b0f24f6b0d upstream.
      
      Rename it as well as __do_cpuid_ent and __do_cpuid_ent_emulated to have
      "func" in its name, and drop the index parameter which is always 0.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NLin Wang <lin.x.wang@intel.com>
      Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      9ea2c5e1
    • F
      CPX: x86/cpufeatures: Enumerate the new AVX512 BFLOAT16 instructions · 61c73dc7
      Fenghua Yu 提交于
      commit b302e4b176d00e1cbc80148c5d0aee36751f7480 upstream.
      
      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.comSigned-off-by: NLin Wang <lin.x.wang@intel.com>
      Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      61c73dc7
  2. 12 10月, 2019 36 次提交
  3. 09 10月, 2019 2 次提交
    • M
      sched/psi: Correct overly pessimistic size calculation · a4926952
      Miles Chen 提交于
      commit 4adcdcea717cb2d8436bef00dd689aa5bc76f11b upstream.
      
      When passing a equal or more then 32 bytes long string to psi_write(),
      psi_write() copies 31 bytes to its buf and overwrites buf[30]
      with '\0'. Which makes the input string 1 byte shorter than
      it should be.
      
      Fix it by copying sizeof(buf) bytes when nbytes >= sizeof(buf).
      
      This does not cause problems in normal use case like:
      "some 500000 10000000" or "full 500000 10000000" because they
      are less than 32 bytes in length.
      
      	/* assuming nbytes == 35 */
      	char buf[32];
      
      	buf_size = min(nbytes, (sizeof(buf) - 1)); /* buf_size = 31 */
      	if (copy_from_user(buf, user_buf, buf_size))
      		return -EFAULT;
      
      	buf[buf_size - 1] = '\0'; /* buf[30] = '\0' */
      
      Before:
      
       %cd /proc/pressure/
       %echo "123456789|123456789|123456789|1234" > memory
       [   22.473497] nbytes=35,buf_size=31
       [   22.473775] 123456789|123456789|123456789| (print 30 chars)
       %sh: write error: Invalid argument
      
       %echo "123456789|123456789|123456789|1" > memory
       [   64.916162] nbytes=32,buf_size=31
       [   64.916331] 123456789|123456789|123456789| (print 30 chars)
       %sh: write error: Invalid argument
      
      After:
      
       %cd /proc/pressure/
       %echo "123456789|123456789|123456789|1234" > memory
       [  254.837863] nbytes=35,buf_size=32
       [  254.838541] 123456789|123456789|123456789|1 (print 31 chars)
       %sh: write error: Invalid argument
      
       %echo "123456789|123456789|123456789|1" > memory
       [ 9965.714935] nbytes=32,buf_size=32
       [ 9965.715096] 123456789|123456789|123456789|1 (print 31 chars)
       %sh: write error: Invalid argument
      
      Also remove the superfluous parentheses.
      Signed-off-by: NMiles Chen <miles.chen@mediatek.com>
      Cc: <linux-mediatek@lists.infradead.org>
      Cc: <wsd_upstream@mediatek.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190912103452.13281-1-miles.chen@mediatek.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      a4926952
    • S
      sched/psi: Do not require setsched permission from the trigger creator · 31107f61
      Suren Baghdasaryan 提交于
      commit 04e048cf09d7b5fc995817cdc5ae1acd4482429c upstream.
      
      When a process creates a new trigger by writing into /proc/pressure/*
      files, permissions to write such a file should be used to determine whether
      the process is allowed to do so or not. Current implementation would also
      require such a process to have setsched capability. Setting of psi trigger
      thread's scheduling policy is an implementation detail and should not be
      exposed to the user level. Remove the permission check by using _nocheck
      version of the function.
      Suggested-by: NNick Kralevich <nnk@google.com>
      Signed-off-by: NSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: lizefan@huawei.com
      Cc: mingo@redhat.com
      Cc: akpm@linux-foundation.org
      Cc: kernel-team@android.com
      Cc: dennisszhou@gmail.com
      Cc: dennis@kernel.org
      Cc: hannes@cmpxchg.org
      Cc: axboe@kernel.dk
      Link: https://lkml.kernel.org/r/20190730013310.162367-1-surenb@google.comSigned-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      31107f61