Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Aug 11, 2022
    • Greg Kroah-Hartman's avatar
    • Pawan Gupta's avatar
      x86/speculation: Add LFENCE to RSB fill sequence · fd2128cd
      Pawan Gupta authored
      
      commit ba6e31af upstream.
      
      RSB fill sequence does not have any protection for miss-prediction of
      conditional branch at the end of the sequence. CPU can speculatively
      execute code immediately after the sequence, while RSB filling hasn't
      completed yet.
      
        #define __FILL_RETURN_BUFFER(reg, nr, sp)       \
                mov     $(nr/2), reg;                   \
        771:                                            \
                ANNOTATE_INTRA_FUNCTION_CALL;           \
                call    772f;                           \
        773:    /* speculation trap */                  \
                UNWIND_HINT_EMPTY;                      \
                pause;                                  \
                lfence;                                 \
                jmp     773b;                           \
        772:                                            \
                ANNOTATE_INTRA_FUNCTION_CALL;           \
                call    774f;                           \
        775:    /* speculation trap */                  \
                UNWIND_HINT_EMPTY;                      \
                pause;                                  \
                lfence;                                 \
                jmp     775b;                           \
        774:                                            \
                add     $(BITS_PER_LONG/8) * 2, sp;     \
                dec     reg;                            \
                jnz     771b;        <----- CPU can miss-predict here.
      
      Before RSB is filled, RETs that come in program order after this macro
      can be executed speculatively, making them vulnerable to RSB-based
      attacks.
      
      Mitigate it by adding an LFENCE after the conditional branch to prevent
      speculation while RSB is being filled.
      
      Suggested-by: default avatarAndrew Cooper <andrew.cooper3@citrix.com>
      Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarDaniel Sneddon <daniel.sneddon@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd2128cd
    • Daniel Sneddon's avatar
      x86/speculation: Add RSB VM Exit protections · 0abdbbd9
      Daniel Sneddon authored
      
      commit 2b129932 upstream.
      
      tl;dr: The Enhanced IBRS mitigation for Spectre v2 does not work as
      documented for RET instructions after VM exits. Mitigate it with a new
      one-entry RSB stuffing mechanism and a new LFENCE.
      
      == Background ==
      
      Indirect Branch Restricted Speculation (IBRS) was designed to help
      mitigate Branch Target Injection and Speculative Store Bypass, i.e.
      Spectre, attacks. IBRS prevents software run in less privileged modes
      from affecting branch prediction in more privileged modes. IBRS requires
      the MSR to be written on every privilege level change.
      
      To overcome some of the performance issues of IBRS, Enhanced IBRS was
      introduced.  eIBRS is an "always on" IBRS, in other words, just turn
      it on once instead of writing the MSR on every privilege level change.
      When eIBRS is enabled, more privileged modes should be protected from
      less privileged modes, including protecting VMMs from guests.
      
      == Problem ==
      
      Here's a simplification of how guests are run on Linux' KVM:
      
      void run_kvm_guest(void)
      {
      	// Prepare to run guest
      	VMRESUME();
      	// Clean up after guest runs
      }
      
      The execution flow for that would look something like this to the
      processor:
      
      1. Host-side: call run_kvm_guest()
      2. Host-side: VMRESUME
      3. Guest runs, does "CALL guest_function"
      4. VM exit, host runs again
      5. Host might make some "cleanup" function calls
      6. Host-side: RET from run_kvm_guest()
      
      Now, when back on the host, there are a couple of possible scenarios of
      post-guest activity the host needs to do before executing host code:
      
      * on pre-eIBRS hardware (legacy IBRS, or nothing at all), the RSB is not
      touched and Linux has to do a 32-entry stuffing.
      
      * on eIBRS hardware, VM exit with IBRS enabled, or restoring the host
      IBRS=1 shortly after VM exit, has a documented side effect of flushing
      the RSB except in this PBRSB situation where the software needs to stuff
      the last RSB entry "by hand".
      
      IOW, with eIBRS supported, host RET instructions should no longer be
      influenced by guest behavior after the host retires a single CALL
      instruction.
      
      However, if the RET instructions are "unbalanced" with CALLs after a VM
      exit as is the RET in #6, it might speculatively use the address for the
      instruction after the CALL in #3 as an RSB prediction. This is a problem
      since the (untrusted) guest controls this address.
      
      Balanced CALL/RET instruction pairs such as in step #5 are not affected.
      
      == Solution ==
      
      The PBRSB issue affects a wide variety of Intel processors which
      support eIBRS. But not all of them need mitigation. Today,
      X86_FEATURE_RSB_VMEXIT triggers an RSB filling sequence that mitigates
      PBRSB. Systems setting RSB_VMEXIT need no further mitigation - i.e.,
      eIBRS systems which enable legacy IBRS explicitly.
      
      However, such systems (X86_FEATURE_IBRS_ENHANCED) do not set RSB_VMEXIT
      and most of them need a new mitigation.
      
      Therefore, introduce a new feature flag X86_FEATURE_RSB_VMEXIT_LITE
      which triggers a lighter-weight PBRSB mitigation versus RSB_VMEXIT.
      
      The lighter-weight mitigation performs a CALL instruction which is
      immediately followed by a speculative execution barrier (INT3). This
      steers speculative execution to the barrier -- just like a retpoline
      -- which ensures that speculation can never reach an unbalanced RET.
      Then, ensure this CALL is retired before continuing execution with an
      LFENCE.
      
      In other words, the window of exposure is opened at VM exit where RET
      behavior is troublesome. While the window is open, force RSB predictions
      sampling for RET targets to a dead end at the INT3. Close the window
      with the LFENCE.
      
      There is a subset of eIBRS systems which are not vulnerable to PBRSB.
      Add these systems to the cpu_vuln_whitelist[] as NO_EIBRS_PBRSB.
      Future systems that aren't vulnerable will set ARCH_CAP_PBRSB_NO.
      
        [ bp: Massage, incorporate review comments from Andy Cooper. ]
      
      Signed-off-by: default avatarDaniel Sneddon <daniel.sneddon@linux.intel.com>
      Co-developed-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0abdbbd9
    • Ning Qiang's avatar
      macintosh/adb: fix oob read in do_adb_query() function · 9deefaf7
      Ning Qiang authored
      
      commit fd97e4ad upstream.
      
      In do_adb_query() function of drivers/macintosh/adb.c, req->data is copied
      form userland. The parameter "req->data[2]" is missing check, the array
      size of adb_handler[] is 16, so adb_handler[req->data[2]].original_address and
      adb_handler[req->data[2]].handler_id will lead to oob read.
      
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarNing Qiang <sohu0106@126.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220713153734.2248-1-sohu0106@126.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9deefaf7
    • Hilda Wu's avatar
      Bluetooth: btusb: Add Realtek RTL8852C support ID 0x13D3:0x3586 · 86419b1c
      Hilda Wu authored
      
      commit 6ad353df upstream.
      
      Add the support ID(0x13D3, 0x3586) to usb_device_id table for
      Realtek RTL8852C.
      
      The device info from /sys/kernel/debug/usb/devices as below.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
      D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=13d3 ProdID=3586 Rev= 0.00
      S:  Manufacturer=Realtek
      S:  Product=Bluetooth Radio
      S:  SerialNumber=00e04c000001
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Signed-off-by: default avatarHilda Wu <hildawu@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86419b1c
    • Hilda Wu's avatar
      Bluetooth: btusb: Add Realtek RTL8852C support ID 0x13D3:0x3587 · a683911c
      Hilda Wu authored
      
      commit 8f0054dd upstream.
      
      Add the support ID(0x13D3, 0x3587) to usb_device_id table for
      Realtek RTL8852C.
      
      The device info from /sys/kernel/debug/usb/devices as below.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
      D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=13d3 ProdID=3587 Rev= 0.00
      S:  Manufacturer=Realtek
      S:  Product=Bluetooth Radio
      S:  SerialNumber=00e04c000001
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Signed-off-by: default avatarHilda Wu <hildawu@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a683911c
    • Hilda Wu's avatar
      Bluetooth: btusb: Add Realtek RTL8852C support ID 0x0CB8:0xC558 · 07320c2a
      Hilda Wu authored
      
      commit 5b75ee37 upstream.
      
      Add the support ID(0x0CB8, 0xC558) to usb_device_id table for
      Realtek RTL8852C.
      
      The device info from /sys/kernel/debug/usb/devices as below.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
      D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=0cb8 ProdID=c558 Rev= 0.00
      S:  Manufacturer=Realtek
      S:  Product=Bluetooth Radio
      S:  SerialNumber=00e04c000001
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Signed-off-by: default avatarHilda Wu <hildawu@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07320c2a
    • Hilda Wu's avatar
      Bluetooth: btusb: Add Realtek RTL8852C support ID 0x04C5:0x1675 · 7635f111
      Hilda Wu authored
      
      commit 893fa8bc upstream.
      
      Add the support ID(0x04c5, 0x1675) to usb_device_id table for
      Realtek RTL8852C.
      
      The device info from /sys/kernel/debug/usb/devices as below.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
      D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=04c5 ProdID=1675 Rev= 0.00
      S:  Manufacturer=Realtek
      S:  Product=Bluetooth Radio
      S:  SerialNumber=00e04c000001
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Signed-off-by: default avatarHilda Wu <hildawu@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7635f111
    • Hilda Wu's avatar
      Bluetooth: btusb: Add Realtek RTL8852C support ID 0x04CA:0x4007 · 8f2d39a4
      Hilda Wu authored
      
      commit c379c96c upstream.
      
      Add the support ID(0x04CA, 0x4007) to usb_device_id table for
      Realtek RTL8852C.
      
      The device info from /sys/kernel/debug/usb/devices as below.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
      D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=04ca ProdID=4007 Rev= 0.00
      S:  Manufacturer=Realtek
      S:  Product=Bluetooth Radio
      S:  SerialNumber=00e04c000001
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Signed-off-by: default avatarHilda Wu <hildawu@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f2d39a4
    • Aaron Ma's avatar
      Bluetooth: btusb: Add support of IMC Networks PID 0x3568 · 73db8c4b
      Aaron Ma authored
      
      commit c69ecb0e upstream.
      
      It is 13d3:3568 for MediaTek MT7922 USB Bluetooth chip.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
      D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=13d3 ProdID=3568 Rev=01.00
      S:  Manufacturer=MediaTek Inc.
      S:  Product=Wireless_Device
      S:  SerialNumber=...
      C:  #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=125us
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 2 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
      E:  Ad=0a(O) Atr=03(Int.) MxPS=  64 Ivl=125us
      E:  Ad=8a(I) Atr=03(Int.) MxPS=  64 Ivl=125us
      
      Signed-off-by: default avatarAaron Ma <aaron.ma@canonical.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73db8c4b
    • Ahmad Fatoum's avatar
      dt-bindings: bluetooth: broadcom: Add BCM4349B1 DT binding · 86a1b593
      Ahmad Fatoum authored
      
      commit 88b65887 upstream.
      
      The BCM4349B1, aka CYW/BCM89359, is a WiFi+BT chip and its Bluetooth
      portion can be controlled over serial.
      Extend the binding with its DT compatible.
      
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86a1b593
    • Hakan Jansson's avatar
      Bluetooth: hci_bcm: Add DT compatible for CYW55572 · 70bbf6e6
      Hakan Jansson authored
      
      commit f8cad620 upstream.
      
      CYW55572 is a Wi-Fi + Bluetooth combo device from Infineon.
      
      Signed-off-by: default avatarHakan Jansson <hakan.jansson@infineon.com>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70bbf6e6
    • Ahmad Fatoum's avatar
      Bluetooth: hci_bcm: Add BCM4349B1 variant · 1d4e83f9
      Ahmad Fatoum authored
      
      commit 4f17c2b6 upstream.
      
      The BCM4349B1, aka CYW/BCM89359, is a WiFi+BT chip and its Bluetooth
      portion can be controlled over serial.
      
      Two subversions are added for the chip, because ROM firmware reports
      002.002.013 (at least for the chips I have here), while depending on
      patchram firmware revision, either 002.002.013 or 002.002.014 is
      reported.
      
      Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d4e83f9
    • Sai Teja Aluvala's avatar
      Bluetooth: hci_qca: Return wakeup for qca_wakeup · a8277293
      Sai Teja Aluvala authored
      
      commit bde63e9e upstream.
      
      This fixes the return value of qca_wakeup(), since
      .wakeup work inversely with original .prevent_wake.
      
      Fixes: 4539ca67 (Bluetooth: Rename driver .prevent_wake to .wakeup)
      Signed-off-by: default avatarSai Teja Aluvala <quic_saluvala@quicinc.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8277293
    • Naohiro Aota's avatar
      btrfs: zoned: drop optimization of zone finish · a2267bc7
      Naohiro Aota authored
      
      commit b3a3b025 upstream.
      
      We have an optimization in do_zone_finish() to send REQ_OP_ZONE_FINISH only
      when necessary, i.e. we don't send REQ_OP_ZONE_FINISH when we assume we
      wrote fully into the zone.
      
      The assumption is determined by "alloc_offset == capacity". This condition
      won't work if the last ordered extent is canceled due to some errors. In
      that case, we consider the zone is deactivated without sending the finish
      command while it's still active.
      
      This inconstancy results in activating another block group while we cannot
      really activate the underlying zone, which causes the active zone exceeds
      errors like below.
      
          BTRFS error (device nvme3n2): allocation failed flags 1, wanted 520192 tree-log 0, relocation: 0
          nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR
          active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0
          nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR
          active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0
      
      Fix the issue by removing the optimization for now.
      
      Fixes: 8376d9e1 ("btrfs: zoned: finish superblock zone once no space left for new SB")
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2267bc7
    • Naohiro Aota's avatar
      btrfs: zoned: fix critical section of relocation inode writeback · 4199731d
      Naohiro Aota authored
      
      commit 19ab78ca upstream.
      
      We use btrfs_zoned_data_reloc_{lock,unlock} to allow only one process to
      write out to the relocation inode. That critical section must include all
      the IO submission for the inode. However, flush_write_bio() in
      extent_writepages() is out of the critical section, causing an IO
      submission outside of the lock. This leads to an out of the order IO
      submission and fail the relocation process.
      
      Fix it by extending the critical section.
      
      Fixes: 35156d85 ("btrfs: zoned: only allow one process to add pages to a relocation inode")
      CC: stable@vger.kernel.org # 5.16+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4199731d
    • Naohiro Aota's avatar
      btrfs: zoned: prevent allocation from previous data relocation BG · 037763b9
      Naohiro Aota authored
      
      commit 343d8a30 upstream.
      
      After commit 5f0addf7 ("btrfs: zoned: use dedicated lock for data
      relocation"), we observe IO errors on e.g, btrfs/232 like below.
      
        [09.0][T4038707] WARNING: CPU: 3 PID: 4038707 at fs/btrfs/extent-tree.c:2381 btrfs_cross_ref_exist+0xfc/0x120 [btrfs]
        <snip>
        [09.9][T4038707] Call Trace:
        [09.5][T4038707]  <TASK>
        [09.3][T4038707]  run_delalloc_nocow+0x7f1/0x11a0 [btrfs]
        [09.6][T4038707]  ? test_range_bit+0x174/0x320 [btrfs]
        [09.2][T4038707]  ? fallback_to_cow+0x980/0x980 [btrfs]
        [09.3][T4038707]  ? find_lock_delalloc_range+0x33e/0x3e0 [btrfs]
        [09.5][T4038707]  btrfs_run_delalloc_range+0x445/0x1320 [btrfs]
        [09.2][T4038707]  ? test_range_bit+0x320/0x320 [btrfs]
        [09.4][T4038707]  ? lock_downgrade+0x6a0/0x6a0
        [09.2][T4038707]  ? orc_find.part.0+0x1ed/0x300
        [09.5][T4038707]  ? __module_address.part.0+0x25/0x300
        [09.0][T4038707]  writepage_delalloc+0x159/0x310 [btrfs]
        <snip>
        [09.4][    C3] sd 10:0:1:0: [sde] tag#2620 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
        [09.5][    C3] sd 10:0:1:0: [sde] tag#2620 Sense Key : Illegal Request [current]
        [09.9][    C3] sd 10:0:1:0: [sde] tag#2620 Add. Sense: Unaligned write command
        [09.5][    C3] sd 10:0:1:0: [sde] tag#2620 CDB: Write(16) 8a 00 00 00 00 00 02 f3 63 87 00 00 00 2c 00 00
        [09.4][    C3] critical target error, dev sde, sector 396041272 op 0x1:(WRITE) flags 0x800 phys_seg 3 prio class 0
        [09.9][    C3] BTRFS error (device dm-1): bdev /dev/mapper/dml_102_2 errs: wr 1, rd 0, flush 0, corrupt 0, gen 0
      
      The IO errors occur when we allocate a regular extent in previous data
      relocation block group.
      
      On zoned btrfs, we use a dedicated block group to relocate a data
      extent. Thus, we allocate relocating data extents (pre-alloc) only from
      the dedicated block group and vice versa. Once the free space in the
      dedicated block group gets tight, a relocating extent may not fit into
      the block group. In that case, we need to switch the dedicated block
      group to the next one. Then, the previous one is now freed up for
      allocating a regular extent. The BG is already not enough to allocate
      the relocating extent, but there is still room to allocate a smaller
      extent. Now the problem happens. By allocating a regular extent while
      nocow IOs for the relocation is still on-going, we will issue WRITE IOs
      (for relocation) and ZONE APPEND IOs (for the regular writes) at the
      same time. That mixed IOs confuses the write pointer and arises the
      unaligned write errors.
      
      This commit introduces a new bit 'zoned_data_reloc_ongoing' to the
      btrfs_block_group. We set this bit before releasing the dedicated block
      group, and no extent are allocated from a block group having this bit
      set. This bit is similar to setting block_group->ro, but is different from
      it by allowing nocow writes to start.
      
      Once all the nocow IO for relocation is done (hooked from
      btrfs_finish_ordered_io), we reset the bit to release the block group for
      further allocation.
      
      Fixes: c2707a25 ("btrfs: zoned: add a dedicated data relocation block group")
      CC: stable@vger.kernel.org # 5.16+
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      037763b9
    • Peter Collingbourne's avatar
      arm64: set UXN on swapper page tables · a1c8d49f
      Peter Collingbourne authored
      [ This issue was fixed upstream by accident in c3cee924 ("arm64:
        head: cover entire kernel image in initial ID map") as part of a
        large refactoring of the arm64 boot flow. This simple fix is therefore
        preferred for -stable backporting ]
      
      On a system that implements FEAT_EPAN, read/write access to the idmap
      is denied because UXN is not set on the swapper PTEs. As a result,
      idmap_kpti_install_ng_mappings panics the kernel when accessing
      __idmap_kpti_flag. Fix it by setting UXN on these PTEs.
      
      Fixes: 18107f8a ("arm64: Support execute-only permissions with Enhanced PAN")
      Cc: <stable@vger.kernel.org> # 5.15
      Link: https://linux-review.googlesource.com/id/Ic452fa4b4f74753e54f71e61027e7222a0fae1b1
      
      
      Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20220719234909.1398992-1-pcc@google.com
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a1c8d49f
    • Mingwei Zhang's avatar
      KVM: x86/svm: add __GFP_ACCOUNT to __sev_dbg_{en,de}crypt_user() · 731dd6be
      Mingwei Zhang authored
      
      [ Upstream commit ebdec859 ]
      
      Adding the accounting flag when allocating pages within the SEV function,
      since these memory pages should belong to individual VM.
      
      No functional change intended.
      
      Signed-off-by: default avatarMingwei Zhang <mizhang@google.com>
      Message-Id: <20220623171858.2083637-1-mizhang@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      731dd6be
    • Raghavendra Rao Ananta's avatar
      selftests: KVM: Handle compiler optimizations in ucall · 661af1a1
      Raghavendra Rao Ananta authored
      
      [ Upstream commit 9e2f6498 ]
      
      The selftests, when built with newer versions of clang, is found
      to have over optimized guests' ucall() function, and eliminating
      the stores for uc.cmd (perhaps due to no immediate readers). This
      resulted in the userspace side always reading a value of '0', and
      causing multiple test failures.
      
      As a result, prevent the compiler from optimizing the stores in
      ucall() with WRITE_ONCE().
      
      Suggested-by: default avatarRicardo Koller <ricarkol@google.com>
      Suggested-by: default avatarReiji Watanabe <reijiw@google.com>
      Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@google.com>
      Message-Id: <20220615185706.1099208-1-rananta@google.com>
      Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      661af1a1
    • Dmitry Klochkov's avatar
      tools/kvm_stat: fix display of error when multiple processes are found · f2451166
      Dmitry Klochkov authored
      
      [ Upstream commit 933b5f9f ]
      
      Instead of printing an error message, kvm_stat script fails when we
      restrict statistics to a guest by its name and there are multiple guests
      with such name:
      
        # kvm_stat -g my_vm
        Traceback (most recent call last):
          File "/usr/bin/kvm_stat", line 1819, in <module>
            main()
          File "/usr/bin/kvm_stat", line 1779, in main
            options = get_options()
          File "/usr/bin/kvm_stat", line 1718, in get_options
            options = argparser.parse_args()
          File "/usr/lib64/python3.10/argparse.py", line 1825, in parse_args
            args, argv = self.parse_known_args(args, namespace)
          File "/usr/lib64/python3.10/argparse.py", line 1858, in parse_known_args
            namespace, args = self._parse_known_args(args, namespace)
          File "/usr/lib64/python3.10/argparse.py", line 2067, in _parse_known_args
            start_index = consume_optional(start_index)
          File "/usr/lib64/python3.10/argparse.py", line 2007, in consume_optional
            take_action(action, args, option_string)
          File "/usr/lib64/python3.10/argparse.py", line 1935, in take_action
            action(self, namespace, argument_values, option_string)
          File "/usr/bin/kvm_stat", line 1649, in __call__
            ' to specify the desired pid'.format(" ".join(pids)))
        TypeError: sequence item 0: expected str instance, int found
      
      To avoid this, it's needed to convert pids int values to strings before
      pass them to join().
      
      Signed-off-by: default avatarDmitry Klochkov <kdmitry556@gmail.com>
      Message-Id: <20220614121141.160689-1-kdmitry556@gmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f2451166
    • David Matlack's avatar
      KVM: selftests: Restrict test region to 48-bit physical addresses when using nested · 574e7f48
      David Matlack authored
      
      [ Upstream commit e0f3f46e ]
      
      The selftests nested code only supports 4-level paging at the moment.
      This means it cannot map nested guest physical addresses with more than
      48 bits. Allow perf_test_util nested mode to work on hosts with more
      than 48 physical addresses by restricting the guest test region to
      48-bits.
      
      While here, opportunistically fix an off-by-one error when dealing with
      vm_get_max_gfn(). perf_test_util.c was treating this as the maximum
      number of GFNs, rather than the maximum allowed GFN. This didn't result
      in any correctness issues, but it did end up shifting the test region
      down slightly when using huge pages.
      
      Suggested-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
      Message-Id: <20220520233249.3776001-12-dmatlack@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      574e7f48
    • Maxim Levitsky's avatar
      KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking · 55e56fab
      Maxim Levitsky authored
      
      [ Upstream commit 18869f26 ]
      
      On SVM, if preemption happens right after the call to finish_rcuwait
      but before call to kvm_arch_vcpu_unblocking on SVM/AVIC, it itself
      will re-enable AVIC, and then we will try to re-enable it again
      in kvm_arch_vcpu_unblocking which will lead to a warning
      in __avic_vcpu_load.
      
      The same problem can happen if the vCPU is preempted right after the call
      to kvm_arch_vcpu_blocking but before the call to prepare_to_rcuwait
      and in this case, we will end up with AVIC enabled during sleep -
      Ooops.
      
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20220606180829.102503-7-mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      55e56fab
    • Maxim Levitsky's avatar
      KVM: x86: disable preemption while updating apicv inhibition · b8cb2f25
      Maxim Levitsky authored
      
      [ Upstream commit 66c768d3 ]
      
      Currently nothing prevents preemption in kvm_vcpu_update_apicv.
      
      On SVM, If the preemption happens after we update the
      vcpu->arch.apicv_active, the preemption itself will
      'update' the inhibition since the AVIC will be first disabled
      on vCPU unload and then enabled, when the current task
      is loaded again.
      
      Then we will try to update it again, which will lead to a warning
      in __avic_vcpu_load, that the AVIC is already enabled.
      
      Fix this by disabling preemption in this code.
      
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20220606180829.102503-6-mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b8cb2f25
    • Seth Forshee's avatar
      entry/kvm: Exit to user mode when TIF_NOTIFY_SIGNAL is set · 625b61e5
      Seth Forshee authored
      
      [ Upstream commit 3e684903 ]
      
      A livepatch transition may stall indefinitely when a kvm vCPU is heavily
      loaded. To the host, the vCPU task is a user thread which is spending a
      very long time in the ioctl(KVM_RUN) syscall. During livepatch
      transition, set_notify_signal() will be called on such tasks to
      interrupt the syscall so that the task can be transitioned. This
      interrupts guest execution, but when xfer_to_guest_mode_work() sees that
      TIF_NOTIFY_SIGNAL is set but not TIF_SIGPENDING it concludes that an
      exit to user mode is unnecessary, and guest execution is resumed without
      transitioning the task for the livepatch.
      
      This handling of TIF_NOTIFY_SIGNAL is incorrect, as set_notify_signal()
      is expected to break tasks out of interruptible kernel loops and cause
      them to return to userspace. Change xfer_to_guest_mode_work() to handle
      TIF_NOTIFY_SIGNAL the same as TIF_SIGPENDING, signaling to the vCPU run
      loop that an exit to userpsace is needed. Any pending task_work will be
      run when get_signal() is called from exit_to_user_mode_loop(), so there
      is no longer any need to run task work from xfer_to_guest_mode_work().
      
      Suggested-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarSeth Forshee <sforshee@digitalocean.com>
      Message-Id: <20220504180840.2907296-1-sforshee@digitalocean.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      625b61e5
    • Ben Gardon's avatar
      KVM: x86/MMU: Zap non-leaf SPTEs when disabling dirty logging · 51ddfb29
      Ben Gardon authored
      
      [ Upstream commit 5ba7c4c6 ]
      
      Currently disabling dirty logging with the TDP MMU is extremely slow.
      On a 96 vCPU / 96G VM backed with gigabyte pages, it takes ~200 seconds
      to disable dirty logging with the TDP MMU, as opposed to ~4 seconds with
      the shadow MMU.
      
      When disabling dirty logging, zap non-leaf parent entries to allow
      replacement with huge pages instead of recursing and zapping all of the
      child, leaf entries. This reduces the number of TLB flushes required.
      and reduces the disable dirty log time with the TDP MMU to ~3 seconds.
      
      Opportunistically add a WARN() to catch GFNs that are mapped at a
      higher level than their max level.
      
      Signed-off-by: default avatarBen Gardon <bgardon@google.com>
      Message-Id: <20220525230904.1584480-1-bgardon@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51ddfb29
    • Vitaly Kuznetsov's avatar
      KVM: selftests: Make hyperv_clock selftest more stable · 5eaeaa7b
      Vitaly Kuznetsov authored
      
      [ Upstream commit eae260be ]
      
      hyperv_clock doesn't always give a stable test result, especially with
      AMD CPUs. The test compares Hyper-V MSR clocksource (acquired either
      with rdmsr() from within the guest or KVM_GET_MSRS from the host)
      against rdtsc(). To increase the accuracy, increase the measured delay
      (done with nop loop) by two orders of magnitude and take the mean rdtsc()
      value before and after rdmsr()/KVM_GET_MSRS.
      
      Reported-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Tested-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20220601144322.1968742-1-vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5eaeaa7b
    • Paolo Bonzini's avatar
      KVM: x86: do not set st->preempted when going back to user space · 316ebf07
      Paolo Bonzini authored
      
      [ Upstream commit 54aa83c9 ]
      
      Similar to the Xen path, only change the vCPU's reported state if the vCPU
      was actually preempted.  The reason for KVM's behavior is that for example
      optimistic spinning might not be a good idea if the guest is doing repeated
      exits to userspace; however, it is confusing and unlikely to make a difference,
      because well-tuned guests will hardly ever exit KVM_RUN in the first place.
      
      Suggested-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      316ebf07
    • Paolo Bonzini's avatar
      KVM: x86: do not report a vCPU as preempted outside instruction boundaries · 719492d2
      Paolo Bonzini authored
      
      [ Upstream commit 6cd88243 ]
      
      If a vCPU is outside guest mode and is scheduled out, it might be in the
      process of making a memory access.  A problem occurs if another vCPU uses
      the PV TLB flush feature during the period when the vCPU is scheduled
      out, and a virtual address has already been translated but has not yet
      been accessed, because this is equivalent to using a stale TLB entry.
      
      To avoid this, only report a vCPU as preempted if sure that the guest
      is at an instruction boundary.  A rescheduling request will be delivered
      to the host physical CPU as an external interrupt, so for simplicity
      consider any vmexit *not* instruction boundary except for external
      interrupts.
      
      It would in principle be okay to report the vCPU as preempted also
      if it is sleeping in kvm_vcpu_block(): a TLB flush IPI will incur the
      vmentry/vmexit overhead unnecessarily, and optimistic spinning is
      also unlikely to succeed.  However, leave it for later because right
      now kvm_vcpu_check_block() is doing memory accesses.  Even
      though the TLB flush issue only applies to virtual memory address,
      it's very much preferrable to be conservative.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      719492d2
    • GUO Zihua's avatar
      crypto: arm64/poly1305 - fix a read out-of-bound · 8d25a085
      GUO Zihua authored
      
      commit 7ae19d42 upstream.
      
      A kasan error was reported during fuzzing:
      
      BUG: KASAN: slab-out-of-bounds in neon_poly1305_blocks.constprop.0+0x1b4/0x250 [poly1305_neon]
      Read of size 4 at addr ffff0010e293f010 by task syz-executor.5/1646715
      CPU: 4 PID: 1646715 Comm: syz-executor.5 Kdump: loaded Not tainted 5.10.0.aarch64 #1
      Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.59 01/31/2019
      Call trace:
       dump_backtrace+0x0/0x394
       show_stack+0x34/0x4c arch/arm64/kernel/stacktrace.c:196
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x158/0x1e4 lib/dump_stack.c:118
       print_address_description.constprop.0+0x68/0x204 mm/kasan/report.c:387
       __kasan_report+0xe0/0x140 mm/kasan/report.c:547
       kasan_report+0x44/0xe0 mm/kasan/report.c:564
       check_memory_region_inline mm/kasan/generic.c:187 [inline]
       __asan_load4+0x94/0xd0 mm/kasan/generic.c:252
       neon_poly1305_blocks.constprop.0+0x1b4/0x250 [poly1305_neon]
       neon_poly1305_do_update+0x6c/0x15c [poly1305_neon]
       neon_poly1305_update+0x9c/0x1c4 [poly1305_neon]
       crypto_shash_update crypto/shash.c:131 [inline]
       shash_finup_unaligned+0x84/0x15c crypto/shash.c:179
       crypto_shash_finup+0x8c/0x140 crypto/shash.c:193
       shash_digest_unaligned+0xb8/0xe4 crypto/shash.c:201
       crypto_shash_digest+0xa4/0xfc crypto/shash.c:217
       crypto_shash_tfm_digest+0xb4/0x150 crypto/shash.c:229
       essiv_skcipher_setkey+0x164/0x200 [essiv]
       crypto_skcipher_setkey+0xb0/0x160 crypto/skcipher.c:612
       skcipher_setkey+0x3c/0x50 crypto/algif_skcipher.c:305
       alg_setkey+0x114/0x2a0 crypto/af_alg.c:220
       alg_setsockopt+0x19c/0x210 crypto/af_alg.c:253
       __sys_setsockopt+0x190/0x2e0 net/socket.c:2123
       __do_sys_setsockopt net/socket.c:2134 [inline]
       __se_sys_setsockopt net/socket.c:2131 [inline]
       __arm64_sys_setsockopt+0x78/0x94 net/socket.c:2131
       __invoke_syscall arch/arm64/kernel/syscall.c:36 [inline]
       invoke_syscall+0x64/0x100 arch/arm64/kernel/syscall.c:48
       el0_svc_common.constprop.0+0x220/0x230 arch/arm64/kernel/syscall.c:155
       do_el0_svc+0xb4/0xd4 arch/arm64/kernel/syscall.c:217
       el0_svc+0x24/0x3c arch/arm64/kernel/entry-common.c:353
       el0_sync_handler+0x160/0x164 arch/arm64/kernel/entry-common.c:369
       el0_sync+0x160/0x180 arch/arm64/kernel/entry.S:683
      
      This error can be reproduced by the following code compiled as ko on a
      system with kasan enabled:
      
      #include <linux/module.h>
      #include <linux/crypto.h>
      #include <crypto/hash.h>
      #include <crypto/poly1305.h>
      
      char test_data[] = "\x00\x01\x02\x03\x04\x05\x06\x07"
                         "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
                         "\x10\x11\x12\x13\x14\x15\x16\x17"
                         "\x18\x19\x1a\x1b\x1c\x1d\x1e";
      
      int init(void)
      {
              struct crypto_shash *tfm = NULL;
              char *data = NULL, *out = NULL;
      
              tfm = crypto_alloc_shash("poly1305", 0, 0);
              data = kmalloc(POLY1305_KEY_SIZE - 1, GFP_KERNEL);
              out = kmalloc(POLY1305_DIGEST_SIZE, GFP_KERNEL);
              memcpy(data, test_data, POLY1305_KEY_SIZE - 1);
              crypto_shash_tfm_digest(tfm, data, POLY1305_KEY_SIZE - 1, out);
      
              kfree(data);
              kfree(out);
              return 0;
      }
      
      void deinit(void)
      {
      }
      
      module_init(init)
      module_exit(deinit)
      MODULE_LICENSE("GPL");
      
      The root cause of the bug sits in neon_poly1305_blocks. The logic
      neon_poly1305_blocks() performed is that if it was called with both s[]
      and r[] uninitialized, it will first try to initialize them with the
      data from the first "block" that it believed to be 32 bytes in length.
      First 16 bytes are used as the key and the next 16 bytes for s[]. This
      would lead to the aforementioned read out-of-bound. However, after
      calling poly1305_init_arch(), only 16 bytes were deducted from the input
      and s[] is initialized yet again with the following 16 bytes. The second
      initialization of s[] is certainly redundent which indicates that the
      first initialization should be for r[] only.
      
      This patch fixes the issue by calling poly1305_init_arm64() instead of
      poly1305_init_arch(). This is also the implementation for the same
      algorithm on arm platform.
      
      Fixes: f569ca16 ("crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8d25a085
    • Tony Luck's avatar
      ACPI: APEI: Better fix to avoid spamming the console with old error logs · adb4c864
      Tony Luck authored
      
      commit c3481b6b upstream.
      
      The fix in commit 3f8dec11 ("ACPI/APEI: Limit printable size of BERT
      table data") does not work as intended on systems where the BIOS has a
      fixed size block of memory for the BERT table, relying on s/w to quit
      when it finds a record with estatus->block_status == 0. On these systems
      all errors are suppressed because the check:
      
      	if (region_len < ACPI_BERT_PRINT_MAX_LEN)
      
      always fails.
      
      New scheme skips individual CPER records that are too large, and also
      limits the total number of records that will be printed to 5.
      
      Fixes: 3f8dec11 ("ACPI/APEI: Limit printable size of BERT table data")
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adb4c864
    • Werner Sembach's avatar
      ACPI: video: Shortening quirk list by identifying Clevo by board_name only · 36dd48b8
      Werner Sembach authored
      
      commit f0341e67 upstream.
      
      Taking a recent change in the i8042 quirklist to this one: Clevo
      board_names are somewhat unique, and if not: The generic Board_-/Sys_Vendor
      string "Notebook" doesn't help much anyway. So identifying the devices just
      by the board_name helps keeping the list significantly shorter and might
      even hit more devices requiring the fix.
      
      Signed-off-by: default avatarWerner Sembach <wse@tuxedocomputers.com>
      Fixes: c844d22f ("ACPI: video: Force backlight native for Clevo NL5xRU and NL5xNU")
      Cc: All applicable <stable@vger.kernel.org>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36dd48b8
    • Werner Sembach's avatar
      ACPI: video: Force backlight native for some TongFang devices · 03bd08f5
      Werner Sembach authored
      
      commit c752089f upstream.
      
      The TongFang PF5PU1G, PF4NU1F, PF5NU1G, and PF5LUXG/TUXEDO BA15 Gen10,
      Pulse 14/15 Gen1, and Pulse 15 Gen2 have the same problem as the Clevo
      NL5xRU and NL5xNU/TUXEDO Aura 15 Gen1 and Gen2:
      They have a working native and video interface. However the default
      detection mechanism first registers the video interface before
      unregistering it again and switching to the native interface during boot.
      This results in a dangling SBIOS request for backlight change for some
      reason, causing the backlight to switch to ~2% once per boot on the first
      power cord connect or disconnect event. Setting the native interface
      explicitly circumvents this buggy behaviour by avoiding the unregistering
      process.
      
      Signed-off-by: default avatarWerner Sembach <wse@tuxedocomputers.com>
      Cc: All applicable <stable@vger.kernel.org>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03bd08f5
    • Stéphane Graber's avatar
      tools/vm/slabinfo: Handle files in debugfs · 93d4edbf
      Stéphane Graber authored
      
      commit 0c7e0d69 upstream.
      
      Commit 64dd6849 relocated and renamed the alloc_calls and
      free_calls files from /sys/kernel/slab/NAME/*_calls over to
      /sys/kernel/debug/slab/NAME/*_calls but didn't update the slabinfo tool
      with the new location.
      
      This change will now have slabinfo look at the new location (and filenames)
      with a fallback to the prior files.
      
      Fixes: 64dd6849 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarStéphane Graber <stgraber@ubuntu.com>
      Tested-by: default avatarStéphane Graber <stgraber@ubuntu.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93d4edbf
    • Jan Kara's avatar
      block: fix default IO priority handling again · a440836f
      Jan Kara authored
      
      commit e589f464 upstream.
      
      Commit e70344c0 ("block: fix default IO priority handling")
      introduced an inconsistency in get_current_ioprio() that tasks without
      IO context return IOPRIO_DEFAULT priority while tasks with freshly
      allocated IO context will return 0 (IOPRIO_CLASS_NONE/0) IO priority.
      Tasks without IO context used to be rare before 5a9d041b ("block:
      move io_context creation into where it's needed") but after this commit
      they became common because now only BFQ IO scheduler setups task's IO
      context. Similar inconsistency is there for get_task_ioprio() so this
      inconsistency is now exposed to userspace and userspace will see
      different IO priority for tasks operating on devices with BFQ compared
      to devices without BFQ. Furthemore the changes done by commit
      e70344c0 change the behavior when no IO priority is set for BFQ IO
      scheduler which is also documented in ioprio_set(2) manpage:
      
      "If no I/O scheduler has been set for a thread, then by default the I/O
      priority will follow the CPU nice value (setpriority(2)).  In Linux
      kernels before version 2.6.24, once an I/O priority had been set using
      ioprio_set(), there was no way to reset the I/O scheduling behavior to
      the default. Since Linux 2.6.24, specifying ioprio as 0 can be used to
      reset to the default I/O scheduling behavior."
      
      So make sure we default to IOPRIO_CLASS_NONE as used to be the case
      before commit e70344c0. Also cleanup alloc_io_context() to
      explicitely set this IO priority for the allocated IO context to avoid
      future surprises. Note that we tweak ioprio_best() to maintain
      ioprio_get(2) behavior and make this commit easily backportable.
      
      CC: stable@vger.kernel.org
      Fixes: e70344c0 ("block: fix default IO priority handling")
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Tested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20220623074840.5960-1-jack@suse.cz
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a440836f
    • Ben Hutchings's avatar
      x86/speculation: Make all RETbleed mitigations 64-bit only · d73a6d60
      Ben Hutchings authored
      
      commit b648ab48 upstream.
      
      The mitigations for RETBleed are currently ineffective on x86_32 since
      entry_32.S does not use the required macros.  However, for an x86_32
      target, the kconfig symbols for them are still enabled by default and
      /sys/devices/system/cpu/vulnerabilities/retbleed will wrongly report
      that mitigations are in place.
      
      Make all of these symbols depend on X86_64, and only enable RETHUNK by
      default on X86_64.
      
      Fixes: f43b9876 ("x86/retbleed: Add fine grained Kconfig knobs")
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/YtwSR3NNsWp1ohfV@decadent.org.uk
      
      
      [bwh: Backported to 5.10/5.15/5.18: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d73a6d60
  2. Aug 03, 2022
Loading