1. 20 Apr, 2019 40 commits
    • Sean Christopherson's avatar
      KVM: nVMX: restore host state in nested_vmx_vmexit for VMFail · 05e78850
      Sean Christopherson authored
      [ Upstream commit bd18bffc ]
      
      A VMEnter that VMFails (as opposed to VMExits) does not touch host
      state beyond registers that are explicitly noted in the VMFail path,
      e.g. EFLAGS.  Host state does not need to be loaded because VMFail
      is only signaled for consistency checks that occur before the CPU
      starts to load guest state, i.e. there is no need to restore any
      state as nothing has been modified.  But in the case where a VMFail
      is detected by hardware and not by KVM (due to deferring consistency
      checks to hardware), KVM has already loaded some amount of guest
      state.  Luckily, "loaded" only means loaded to KVM's software model,
      i.e. vmcs01 has not been modified.  So, unwind our software model to
      the pre-VMEntry host state.
      
      Not restoring host state in this VMFail path leads to a variety of
      failures because we end up with stale data in vcpu->arch, e.g. CR0,
      CR4, EFER, etc... will all be out of sync relative to vmcs01.  Any
      significant delta in the stale data is all but guaranteed to crash
      L1, e.g. emulation of SMEP, SMAP, UMIP, WP, etc... will be wrong.
      
      An alternative to this "soft" reload would be to load host state from
      vmcs12 as if we triggered a VMExit (as opposed to VMFail), but that is
      wildly inconsistent with respect to the VMX architecture, e.g. an L1
      VMM with separate VMExit and VMFail paths would explode.
      
      Note that this approach does not mean KVM is 100% accurate with
      respect to VMX hardware behavior, even at an architectural level
      (the exact order of consistency checks is microarchitecture specific).
      But 100% emulation accuracy isn't the goal (with this patch), rather
      the goal is to be consistent in the information delivered to L1, e.g.
      a VMExit should not fall-through VMENTER, and a VMFail should not jump
      to HOST_RIP.
      
      This technically reverts commit "5af41573 (KVM: nVMX: Fix mmu
      context after VMLAUNCH/VMRESUME failure)", but retains the core
      aspects of that patch, just in an open coded form due to the need to
      pull state from vmcs01 instead of vmcs12.  Restoring host state
      resolves a variety of issues introduced by commit "4f350c6d
      (kvm: nVMX: Handle deferred early VMLAUNCH/VMRESUME failure properly)",
      which remedied the incorrect behavior of treating VMFail like VMExit
      but in doing so neglected to restore arch state that had been modified
      prior to attempting nested VMEnter.
      
      A sample failure that occurs due to stale vcpu.arch state is a fault
      of some form while emulating an LGDT (due to emulated UMIP) from L1
      after a failed VMEntry to L3, in this case when running the KVM unit
      test test_tpr_threshold_values in L1.  L0 also hits a WARN in this
      case due to a stale arch.cr4.UMIP.
      
      L1:
        BUG: unable to handle kernel paging request at ffffc90000663b9e
        PGD 276512067 P4D 276512067 PUD 276513067 PMD 274efa067 PTE 8000000271de2163
        Oops: 0009 [#1] SMP
        CPU: 5 PID: 12495 Comm: qemu-system-x86 Tainted: G        W         4.18.0-rc2+ #2
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
        RIP: 0010:native_load_gdt+0x0/0x10
      
        ...
      
        Call Trace:
         load_fixmap_gdt+0x22/0x30
         __vmx_load_host_state+0x10e/0x1c0 [kvm_intel]
         vmx_switch_vmcs+0x2d/0x50 [kvm_intel]
         nested_vmx_vmexit+0x222/0x9c0 [kvm_intel]
         vmx_handle_exit+0x246/0x15a0 [kvm_intel]
         kvm_arch_vcpu_ioctl_run+0x850/0x1830 [kvm]
         kvm_vcpu_ioctl+0x3a1/0x5c0 [kvm]
         do_vfs_ioctl+0x9f/0x600
         ksys_ioctl+0x66/0x70
         __x64_sys_ioctl+0x16/0x20
         do_syscall_64+0x4f/0x100
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      L0:
        WARNING: CPU: 2 PID: 3529 at arch/x86/kvm/vmx.c:6618 handle_desc+0x28/0x30 [kvm_intel]
        ...
        CPU: 2 PID: 3529 Comm: qemu-system-x86 Not tainted 4.17.2-coffee+ #76
        Hardware name: Intel Corporation Kabylake Client platform/KBL S
        RIP: 0010:handle_desc+0x28/0x30 [kvm_intel]
      
        ...
      
        Call Trace:
         kvm_arch_vcpu_ioctl_run+0x863/0x1840 [kvm]
         kvm_vcpu_ioctl+0x3a1/0x5c0 [kvm]
         do_vfs_ioctl+0x9f/0x5e0
         ksys_ioctl+0x66/0x70
         __x64_sys_ioctl+0x16/0x20
         do_syscall_64+0x49/0xf0
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 5af41573 (KVM: nVMX: Fix mmu context after VMLAUNCH/VMRESUME failure)
      Fixes: 4f350c6d (kvm: nVMX: Handle deferred early VMLAUNCH/VMRESUME failure properly)
      Cc: Jim Mattson <jmattson@google.com>
      Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim KrÄmáŠ<rkrcmar@redhat.com>
      Cc: Wanpeng Li <wanpeng.li@hotmail.com>
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      05e78850
    • Ronald Tschalär's avatar
      ACPI / SBS: Fix GPE storm on recent MacBookPro's · 00254adf
      Ronald Tschalär authored
      [ Upstream commit ca1721c5 ]
      
      On Apple machines, plugging-in or unplugging the power triggers a GPE
      for the EC. Since these machines expose an SBS device, this GPE ends
      up triggering the acpi_sbs_callback(). This in turn tries to get the
      status of the SBS charger. However, on MBP13,* and MBP14,* machines,
      performing the smbus-read operation to get the charger's status triggers
      the EC's GPE again. The result is an endless re-triggering and handling
      of that GPE, consuming significant CPU resources (> 50% in irq).
      
      In the end this is quite similar to commit 3031cdde (ACPI / SBS:
      Don't assume the existence of an SBS charger), except that on the above
      machines a status of all 1's is returned. And like there, we just want
      ignore the charger here.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=198169Signed-off-by: default avatarRonald Tschalär <ronald@innovation.ch>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      00254adf
    • Maciej Żenczykowski's avatar
      usbip: fix vhci_hcd controller counting · 0dd66375
      Maciej Żenczykowski authored
      [ Upstream commit e0a2e73e ]
      
      Without this usbip fails on a machine with devices
      that lexicographically come after vhci_hcd.
      
      ie.
        $ ls -l /sys/devices/platform
        ...
        drwxr-xr-x. 4 root root    0 Sep 19 16:21 serial8250
        -rw-r--r--. 1 root root 4096 Sep 19 23:50 uevent
        drwxr-xr-x. 6 root root    0 Sep 20 13:15 vhci_hcd.0
        drwxr-xr-x. 4 root root    0 Sep 19 16:22 w83627hf.656
      
      Because it detects 'w83627hf.656' as another vhci_hcd controller,
      and then fails to be able to talk to it.
      
      Note: this doesn't actually fix usbip's support for multiple
      controllers... that's still broken for other reasons
      ("vhci_hcd.0" is hardcoded in a string macro), but is enough to
      actually make it work on the above machine.
      
      See also:
        https://bugzilla.redhat.com/show_bug.cgi?id=1631148
      
      Cc: Jonathan Dieter <jdieter@gmail.com>
      Cc: Valentina Manea <valentina.manea.m@gmail.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: linux-usb@vger.kernel.org
      Signed-off-by: default avatarMaciej Żenczykowski <zenczykowski@gmail.com>
      Acked-by: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
      Tested-by: default avatarJonathan Dieter <jdieter@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0dd66375
    • Bartlomiej Zolnierkiewicz's avatar
      ARM: samsung: Limit SAMSUNG_PM_CHECK config option to non-Exynos platforms · ef9f4326
      Bartlomiej Zolnierkiewicz authored
      [ Upstream commit 6862fdf2 ]
      
      "S3C2410 PM Suspend Memory CRC" feature (controlled by
      SAMSUNG_PM_CHECK config option) is incompatible with highmem
      (uses phys_to_virt() instead of proper mapping) which is used by
      the majority of Exynos boards. The issue manifests itself in OOPS
      on affected boards, i.e. on Odroid-U3 I got the following one:
      
      Unable to handle kernel paging request at virtual address f0000000
      pgd = 1c0f9bb4
      [f0000000] *pgd=00000000
      Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      [<c0458034>] (crc32_le) from [<c0121f8c>] (s3c_pm_makecheck+0x34/0x54)
      [<c0121f8c>] (s3c_pm_makecheck) from [<c0121efc>] (s3c_pm_run_res+0x74/0x8c)
      [<c0121efc>] (s3c_pm_run_res) from [<c0121ecc>] (s3c_pm_run_res+0x44/0x8c)
      [<c0121ecc>] (s3c_pm_run_res) from [<c01210b8>] (exynos_suspend_enter+0x64/0x148)
      [<c01210b8>] (exynos_suspend_enter) from [<c018893c>] (suspend_devices_and_enter+0x9ec/0xe74)
      [<c018893c>] (suspend_devices_and_enter) from [<c0189534>] (pm_suspend+0x770/0xc04)
      [<c0189534>] (pm_suspend) from [<c0186ce8>] (state_store+0x6c/0xcc)
      [<c0186ce8>] (state_store) from [<c09db434>] (kobj_attr_store+0x14/0x20)
      [<c09db434>] (kobj_attr_store) from [<c02fa63c>] (sysfs_kf_write+0x4c/0x50)
      [<c02fa63c>] (sysfs_kf_write) from [<c02f97a4>] (kernfs_fop_write+0xfc/0x1e4)
      [<c02f97a4>] (kernfs_fop_write) from [<c027b198>] (__vfs_write+0x2c/0x140)
      [<c027b198>] (__vfs_write) from [<c027b418>] (vfs_write+0xa4/0x160)
      [<c027b418>] (vfs_write) from [<c027b5d8>] (ksys_write+0x40/0x8c)
      [<c027b5d8>] (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
      
      Add PLAT_S3C24XX, ARCH_S3C64XX and ARCH_S5PV210 dependencies to
      SAMSUNG_PM_CHECK config option to hide it on Exynos platforms.
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ef9f4326
    • Julian Sax's avatar
      HID: i2c-hid: override HID descriptors for certain devices · e058a6e5
      Julian Sax authored
      [ Upstream commit 9ee3e066 ]
      
      A particular touchpad (SIPODEV SP1064) refuses to supply the HID
      descriptors. This patch provides the framework for overriding these
      descriptors based on DMI data. It also includes the descriptors for
      said touchpad, which were extracted by listening to the traffic of the
      windows filter driver, as well as the DMI data for the laptops known
      to use this device.
      
      Relevant Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1526312
      
      Cc: Hans de Goede <hdegoede@redhat.com>
      Reported-and-tested-by: ahormann@gmx.net
      Reported-and-tested-by: default avatarBruno Jesus <bruno.fl.jesus@gmail.com>
      Reported-and-tested-by: default avatarDietrich <enaut.w@googlemail.com>
      Reported-and-tested-by: kloxdami@yahoo.com
      Signed-off-by: default avatarJulian Sax <jsbc@gmx.de>
      Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e058a6e5
    • Brad Love's avatar
      media: au0828: cannot kfree dev before usb disconnect · fec306b2
      Brad Love authored
      [ Upstream commit 4add7104 ]
      
      If au0828_analog_register fails, the dev is kfree'd and then flow
      jumps to done, which can call au0828_usb_disconnect. Since all USB
      error codes are negative, au0828_usb_disconnect will be called. The
      problem is au0828_usb_disconnect uses dev, if dev is NULL then there
      is immediate oops encountered.
      
      [    7.454307] au0828: au0828_usb_probe() au0282_dev_register failed to register on V4L2
      [    7.454323] BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
      [    7.454421] PGD 0 P4D 0
      [    7.454457] Oops: 0002 [#1] SMP PTI
      [    7.454500] CPU: 1 PID: 262 Comm: systemd-udevd Tainted: P           O      4.18.3 #1
      [    7.454584] Hardware name: Google Panther/Panther, BIOS MattDevo 04/27/2015
      [    7.454670] RIP: 0010:_raw_spin_lock_irqsave+0x2c/0x50
      [    7.454725] Code: 44 00 00 55 48 89 e5 41 54 53 48 89 fb 9c 58 0f 1f 44 00 00 49 89 c4 fa 66 0f 1f 44 00 00 e8 db 23 1b ff 31 c0 ba 01 00 00 00 <f0> 0f b1 13 85 c0 75 08 4c 89 e0 5b 41 5c 5d c3 89 c6 48 89 df e8
      [    7.455004] RSP: 0018:ffff9130f53ef988 EFLAGS: 00010046
      [    7.455063] RAX: 0000000000000000 RBX: 0000000000000050 RCX: 0000000000000000
      [    7.455139] RDX: 0000000000000001 RSI: 0000000000000003 RDI: 0000000000000050
      [    7.455216] RBP: ffff9130f53ef998 R08: 0000000000000018 R09: 0000000000000090
      [    7.455292] R10: ffffed4cc53cb000 R11: ffffed4cc53cb108 R12: 0000000000000082
      [    7.455369] R13: ffff9130cf2c6188 R14: 0000000000000000 R15: 0000000000000018
      [    7.455447] FS:  00007f2ff8514cc0(0000) GS:ffff9130fcb00000(0000) knlGS:0000000000000000
      [    7.455535] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    7.455597] CR2: 0000000000000050 CR3: 00000001753f0002 CR4: 00000000000606a0
      [    7.455675] Call Trace:
      [    7.455713]  __wake_up_common_lock+0x65/0xc0
      [    7.455764]  __wake_up+0x13/0x20
      [    7.455808]  ir_lirc_unregister+0x57/0xe0 [rc_core]
      [    7.455865]  rc_unregister_device+0xa0/0xc0 [rc_core]
      [    7.455935]  au0828_rc_unregister+0x25/0x40 [au0828]
      [    7.455999]  au0828_usb_disconnect+0x33/0x80 [au0828]
      [    7.456064]  au0828_usb_probe.cold.16+0x8d/0x2aa [au0828]
      [    7.456130]  usb_probe_interface+0xf1/0x300
      [    7.456184]  driver_probe_device+0x2e3/0x460
      [    7.456235]  __driver_attach+0xe4/0x110
      [    7.456282]  ? driver_probe_device+0x460/0x460
      [    7.456335]  bus_for_each_dev+0x74/0xb0
      [    7.456385]  ? kmem_cache_alloc_trace+0x15d/0x1d0
      [    7.456441]  driver_attach+0x1e/0x20
      [    7.456485]  bus_add_driver+0x159/0x230
      [    7.456532]  driver_register+0x70/0xc0
      [    7.456578]  usb_register_driver+0x7f/0x140
      [    7.456626]  ? 0xffffffffc0474000
      [    7.456674]  au0828_init+0xbc/0x1000 [au0828]
      [    7.456725]  do_one_initcall+0x4a/0x1c9
      [    7.456771]  ? _cond_resched+0x19/0x30
      [    7.456817]  ? kmem_cache_alloc_trace+0x15d/0x1d0
      [    7.456873]  do_init_module+0x60/0x210
      [    7.456918]  load_module+0x221b/0x2710
      [    7.456966]  ? vfs_read+0xf5/0x120
      [    7.457010]  __do_sys_finit_module+0xbd/0x120
      [    7.457061]  ? __do_sys_finit_module+0xbd/0x120
      [    7.457115]  __x64_sys_finit_module+0x1a/0x20
      [    7.457166]  do_syscall_64+0x5b/0x110
      [    7.457210]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
      Signed-off-by: default avatarBrad Love <brad@nextdimension.cc>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fec306b2
    • Nathan Fontenot's avatar
      powerpc/pseries: Remove prrn_work workqueue · 8b8fa987
      Nathan Fontenot authored
      [ Upstream commit cd24e457 ]
      
      When a PRRN event is received we are already running in a worker
      thread. Instead of spawning off another worker thread on the prrn_work
      workqueue to handle the PRRN event we can just call the PRRN handler
      routine directly.
      
      With this update we can also pass the scope variable for the PRRN
      event directly to the handler instead of it being a global variable.
      
      This patch fixes the following oops mnessage we are seeing in PRRN testing:
      
        Oops: Bad kernel stack pointer, sig: 6 [#1]
        SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in: nfsv3 nfs_acl rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc fscache binfmt_misc reiserfs vfat fat rpadlpar_io(X) rpaphp(X) tcp_diag udp_diag inet_diag unix_diag af_packet_diag netlink_diag af_packet xfs libcrc32c dm_service_time ibmveth(X) ses enclosure scsi_transport_sas rtc_generic btrfs xor raid6_pq sd_mod ibmvscsi(X) scsi_transport_srp ipr(X) libata sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod autofs4
        Supported: Yes, External                                                     54
        CPU: 7 PID: 18967 Comm: kworker/u96:0 Tainted: G                 X 4.4.126-94.22-default #1
        Workqueue: pseries hotplug workque pseries_hp_work_fn
        task: c000000775367790 ti: c00000001ebd4000 task.ti: c00000070d140000
        NIP: 0000000000000000 LR: 000000001fb3d050 CTR: 0000000000000000
        REGS: c00000001ebd7d40 TRAP: 0700   Tainted: G                 X  (4.4.126-94.22-default)
        MSR: 8000000102081000 <41,VEC,ME5  CR: 28000002  XER: 20040018   4
        CFAR: 000000001fb3d084 40 419   1                                3
        GPR00: 000000000000000040000000000010007 000000001ffff400 000000041fffe200
        GPR04: 000000000000008050000000000000000 000000001fb15fa8 0000000500000500
        GPR08: 000000000001f40040000000000000001 0000000000000000 000005:5200040002
        GPR12: 00000000000000005c000000007a05400 c0000000000e89f8 000000001ed9f668
        GPR16: 000000001fbeff944000000001fbeff94 000000001fb545e4 0000006000000060
        GPR20: ffffffffffffffff4ffffffffffffffff 0000000000000000 0000000000000000
        GPR24: 00000000000000005400000001fb3c000 0000000000000000 000000001fb1b040
        GPR28: 000000001fb240004000000001fb440d8 0000000000000008 0000000000000000
        NIP [0000000000000000] 5         (null)
        LR [000000001fb3d050] 031fb3d050
        Call Trace:            4
        Instruction dump:      4                                       5:47 12    2
        XXXXXXXX XXXXXXXX XXXXX4XX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
        XXXXXXXX XXXXXXXX XXXXX5XX XXXXXXXX 60000000 60000000 60000000 60000000
        ---[ end trace aa5627b04a7d9d6b ]---                                       3NMI watchdog: BUG: soft lockup - CPU#27 stuck for 23s! [kworker/27:0:13903]
        Modules linked in: nfsv3 nfs_acl rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc fscache binfmt_misc reiserfs vfat fat rpadlpar_io(X) rpaphp(X) tcp_diag udp_diag inet_diag unix_diag af_packet_diag netlink_diag af_packet xfs libcrc32c dm_service_time ibmveth(X) ses enclosure scsi_transport_sas rtc_generic btrfs xor raid6_pq sd_mod ibmvscsi(X) scsi_transport_srp ipr(X) libata sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod autofs4
        Supported: Yes, External
        CPU: 27 PID: 13903 Comm: kworker/27:0 Tainted: G      D          X 4.4.126-94.22-default #1
        Workqueue: events prrn_work_fn
        task: c000000747cfa390 ti: c00000074712c000 task.ti: c00000074712c000
        NIP: c0000000008002a8 LR: c000000000090770 CTR: 000000000032e088
        REGS: c00000074712f7b0 TRAP: 0901   Tainted: G      D          X  (4.4.126-94.22-default)
        MSR: 8000000100009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 22482044  XER: 20040000
        CFAR: c0000000008002c4 SOFTE: 1
        GPR00: c000000000090770 c00000074712fa30 c000000000f09800 c000000000fa1928 6:02
        GPR04: c000000775f5e000 fffffffffffffffe 0000000000000001 c000000000f42db8
        GPR08: 0000000000000001 0000000080000007 0000000000000000 0000000000000000
        GPR12: 8006210083180000 c000000007a14400
        NIP [c0000000008002a8] _raw_spin_lock+0x68/0xd0
        LR [c000000000090770] mobility_rtas_call+0x50/0x100
        Call Trace:            59                                        5
        [c00000074712fa60] [c000000000090770] mobility_rtas_call+0x50/0x100
        [c00000074712faf0] [c000000000090b08] pseries_devicetree_update+0xf8/0x530
        [c00000074712fc20] [c000000000031ba4] prrn_work_fn+0x34/0x50
        [c00000074712fc40] [c0000000000e0390] process_one_work+0x1a0/0x4e0
        [c00000074712fcd0] [c0000000000e0870] worker_thread+0x1a0/0x6105:57       2
        [c00000074712fd80] [c0000000000e8b18] kthread+0x128/0x150
        [c00000074712fe30] [c0000000000096f8] ret_from_kernel_thread+0x5c/0x64
        Instruction dump:
        2c090000 40c20010 7d40192d 40c2fff0 7c2004ac 2fa90000 40de0018 5:540030   3
        e8010010 ebe1fff8 7c0803a6 4e800020 <7c210b78> e92d0000 89290009 792affe3
      Signed-off-by: default avatarJohn Allen <jallen@linux.ibm.com>
      Signed-off-by: default avatarHaren Myneni <haren@us.ibm.com>
      Signed-off-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b8fa987
    • Michal Simek's avatar
      serial: uartps: console_setup() can't be placed to init section · 1fa5208a
      Michal Simek authored
      [ Upstream commit 4bb1ce23 ]
      
      When console device is rebinded, console_setup() is called again.
      But marking it as __init means that function will be clear after boot is
      complete. If console device is binded again console_setup() is not found
      and error "Unable to handle kernel paging request at virtual address"
      is reported.
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1fa5208a
    • Pablo Neira Ayuso's avatar
      netfilter: xt_cgroup: shrink size of v2 path · edbcdafa
      Pablo Neira Ayuso authored
      [ Upstream commit 0d704967 ]
      
      cgroup v2 path field is PATH_MAX which is too large, this is placing too
      much pressure on memory allocation for people with many rules doing
      cgroup v1 classid matching, side effects of this are bug reports like:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=200639
      
      This patch registers a new revision that shrinks the cgroup path to 512
      bytes, which is the same approach we follow in similar extensions that
      have a path field.
      
      Cc: Tejun Heo <tj@kernel.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      edbcdafa
    • Chao Yu's avatar
      f2fs: fix to do sanity check with current segment number · 40e8d128
      Chao Yu authored
      [ Upstream commit 042be0f8 ]
      
      https://bugzilla.kernel.org/show_bug.cgi?id=200219
      
      Reproduction way:
      - mount image
      - run poc code
      - umount image
      
      F2FS-fs (loop1): Bitmap was wrongly set, blk:15364
      ------------[ cut here ]------------
      kernel BUG at /home/yuchao/git/devf2fs/segment.c:2061!
      invalid opcode: 0000 [#1] PREEMPT SMP
      CPU: 2 PID: 17686 Comm: umount Tainted: G        W  O      4.18.0-rc2+ #39
      Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      EIP: update_sit_entry+0x459/0x4e0 [f2fs]
      Code: e8 1c b5 fd ff 0f 0b 0f 0b 8b 45 e4 c7 44 24 08 9c 7a 6c f8 c7 44 24 04 bc 4a 6c f8 89 44 24 0c 8b 06 89 04 24 e8 f7 b4 fd ff <0f> 0b 8b 45 e4 0f b6 d2 89 54 24 10 c7 44 24 08 60 7a 6c f8 c7 44
      EAX: 00000032 EBX: 000000f8 ECX: 00000002 EDX: 00000001
      ESI: d7177000 EDI: f520fe68 EBP: d6477c6c ESP: d6477c34
      DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010282
      CR0: 80050033 CR2: b7fbe000 CR3: 2a99b3c0 CR4: 000406f0
      Call Trace:
       f2fs_allocate_data_block+0x124/0x580 [f2fs]
       do_write_page+0x78/0x150 [f2fs]
       f2fs_do_write_node_page+0x25/0xa0 [f2fs]
       __write_node_page+0x2bf/0x550 [f2fs]
       f2fs_sync_node_pages+0x60e/0x6d0 [f2fs]
       ? sync_inode_metadata+0x2f/0x40
       ? f2fs_write_checkpoint+0x28f/0x7d0 [f2fs]
       ? up_write+0x1e/0x80
       f2fs_write_checkpoint+0x2a9/0x7d0 [f2fs]
       ? mark_held_locks+0x5d/0x80
       ? _raw_spin_unlock_irq+0x27/0x50
       kill_f2fs_super+0x68/0x90 [f2fs]
       deactivate_locked_super+0x3d/0x70
       deactivate_super+0x40/0x60
       cleanup_mnt+0x39/0x70
       __cleanup_mnt+0x10/0x20
       task_work_run+0x81/0xa0
       exit_to_usermode_loop+0x59/0xa7
       do_fast_syscall_32+0x1f5/0x22c
       entry_SYSENTER_32+0x53/0x86
      EIP: 0xb7f95c51
      Code: c1 1e f7 ff ff 89 e5 8b 55 08 85 d2 8b 81 64 cd ff ff 74 02 89 02 5d c3 8b 0c 24 c3 8b 1c 24 c3 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
      EAX: 00000000 EBX: 0871ab90 ECX: bfb2cd00 EDX: 00000000
      ESI: 00000000 EDI: 0871ab90 EBP: 0871ab90 ESP: bfb2cd7c
      DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00000246
      Modules linked in: f2fs(O) crc32_generic bnep rfcomm bluetooth ecdh_generic snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq pcbc joydev aesni_intel snd_seq_device aes_i586 snd_timer crypto_simd snd cryptd soundcore mac_hid serio_raw video i2c_piix4 parport_pc ppdev lp parport hid_generic psmouse usbhid hid e1000 [last unloaded: f2fs]
      ---[ end trace d423f83982cfcdc5 ]---
      
      The reason is, different log headers using the same segment, once
      one log's next block address is used by another log, it will cause
      panic as above.
      
      Main area: 24 segs, 24 secs 24 zones
        - COLD  data: 0, 0, 0
        - WARM  data: 1, 1, 1
        - HOT   data: 20, 20, 20
        - Dir   dnode: 22, 22, 22
        - File   dnode: 22, 22, 22
        - Indir nodes: 21, 21, 21
      
      So this patch adds sanity check to detect such condition to avoid
      this issue.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      40e8d128
    • Dinu-Razvan Chis-Serban's avatar
      9p locks: add mount option for lock retry interval · 85a2ad15
      Dinu-Razvan Chis-Serban authored
      [ Upstream commit 5e172f75 ]
      
      The default P9_LOCK_TIMEOUT can be too long for some users exporting
      a local file system to a guest VM (30s), make this configurable at
      mount time.
      
      Link: http://lkml.kernel.org/r/1536295827-3181-1-git-send-email-asmadeus@codewreck.org
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195727Signed-off-by: default avatarDinu-Razvan Chis-Serban <justcsdr@gmail.com>
      Signed-off-by: default avatarDominique Martinet <dominique.martinet@cea.fr>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      85a2ad15
    • Gertjan Halkes's avatar
      9p: do not trust pdu content for stat item size · fdf0c593
      Gertjan Halkes authored
      [ Upstream commit 2803cf43 ]
      
      v9fs_dir_readdir() could deadloop if a struct was sent with a size set
      to -2
      
      Link: http://lkml.kernel.org/r/1536134432-11997-1-git-send-email-asmadeus@codewreck.org
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88021Signed-off-by: default avatarGertjan Halkes <gertjan@google.com>
      Signed-off-by: default avatarDominique Martinet <dominique.martinet@cea.fr>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fdf0c593
    • Siva Rebbagondla's avatar
      rsi: improve kernel thread handling to fix kernel panic · ad78e2e0
      Siva Rebbagondla authored
      [ Upstream commit 4c62764d ]
      
      While running regressions, observed below kernel panic when sdio disconnect
      called. This is because of, kthread_stop() is taking care of
      wait_for_completion() by default. When wait_for_completion triggered
      in kthread_stop and as it was done already, giving kernel panic.
      Hence, removing redundant wait_for_completion() from rsi_kill_thread().
      
      ... skipping ...
      BUG: unable to handle kernel NULL pointer dereference at           (null)
      IP: [<ffffffff810a63df>] exit_creds+0x1f/0x50
      PGD 0
      Oops: 0002 [#1] SMP
      CPU: 0 PID: 6502 Comm: rmmod Tainted: G  OE   4.15.9-Generic #154-Ubuntu
      Hardware name: Dell Inc. Edge Gateway 3003/ , BIOS 01.00.00 04/17/2017
      Stack:
      ffff88007392e600 ffff880075847dc0 ffffffff8108160a 0000000000000000
      ffff88007392e600 ffff880075847de8 ffffffff810a484b ffff880076127000
      ffff88003cd3a800 ffff880074f12a00 ffff880075847e28 ffffffffc09bed15
      Call Trace:
      [<ffffffff8108160a>] __put_task_struct+0x5a/0x140
      [<ffffffff810a484b>] kthread_stop+0x10b/0x110
      [<ffffffffc09bed15>] rsi_disconnect+0x2f5/0x300 [ven_rsi_sdio]
      [<ffffffff81578bcb>] ? __pm_runtime_resume+0x5b/0x80
      [<ffffffff816f0918>] sdio_bus_remove+0x38/0x100
      [<ffffffff8156cc64>] __device_release_driver+0xa4/0x150
      [<ffffffff8156d7a5>] driver_detach+0xb5/0xc0
      [<ffffffff8156c6c5>] bus_remove_driver+0x55/0xd0
      [<ffffffff8156dfbc>] driver_unregister+0x2c/0x50
      [<ffffffff816f0b8a>] sdio_unregister_driver+0x1a/0x20
      [<ffffffffc09bf0f5>] rsi_module_exit+0x15/0x30 [ven_rsi_sdio]
      [<ffffffff8110cad8>] SyS_delete_module+0x1b8/0x210
      [<ffffffff81851dc8>] entry_SYSCALL_64_fastpath+0x1c/0xbb
      Signed-off-by: default avatarSiva Rebbagondla <siva.rebbagondla@redpinesignals.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad78e2e0
    • Robert Jarzmik's avatar
      gpio: pxa: handle corner case of unprobed device · 15fbb1fe
      Robert Jarzmik authored
      [ Upstream commit 9ce3ebe9 ]
      
      In the corner case where the gpio driver probe fails, for whatever
      reason, the suspend and resume handlers will still be called as they
      have to be registered as syscore operations. This applies as well when
      no probe was called while the driver has been built in the kernel.
      
      Nicolas tracked this in :
      https://bugzilla.kernel.org/show_bug.cgi?id=200905
      
      Therefore, add a failsafe in these function, and test if a proper probe
      succeeded and the driver is functional.
      Signed-off-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
      Reported-by: default avatarNicolas Chauvet <kwizart@gmail.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      15fbb1fe
    • Darrick J. Wong's avatar
      ext4: prohibit fstrim in norecovery mode · 6fee657d
      Darrick J. Wong authored
      [ Upstream commit 18915b58 ]
      
      The ext4 fstrim implementation uses the block bitmaps to find free space
      that can be discarded.  If we haven't replayed the journal, the bitmaps
      will be stale and we absolutely *cannot* use stale metadata to zap the
      underlying storage.
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6fee657d
    • Steve French's avatar
      fix incorrect error code mapping for OBJECTID_NOT_FOUND · 329f34e8
      Steve French authored
      [ Upstream commit 85f9987b ]
      
      It was mapped to EIO which can be confusing when user space
      queries for an object GUID for an object for which the server
      file system doesn't support (or hasn't saved one).
      
      As Amir Goldstein suggested this is similar to ENOATTR
      (equivalently ENODATA in Linux errno definitions) so
      changing NT STATUS code mapping for OBJECTID_NOT_FOUND
      to ENODATA.
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Amir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      329f34e8
    • Nathan Chancellor's avatar
      x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() return an error · 727344f1
      Nathan Chancellor authored
      [ Upstream commit e898e69d ]
      
      When building with -Wsometimes-uninitialized, Clang warns:
      
      arch/x86/kernel/hw_breakpoint.c:355:2: warning: variable 'align' is used
      uninitialized whenever switch default is taken
      [-Wsometimes-uninitialized]
      
      The default cannot be reached because arch_build_bp_info() initializes
      hw->len to one of the specified cases. Nevertheless the warning is valid
      and returning -EINVAL makes sure that this cannot be broken by future
      modifications.
      Suggested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: clang-built-linux@googlegroups.com
      Link: https://github.com/ClangBuiltLinux/linux/issues/392
      Link: https://lkml.kernel.org/r/20190307212756.4648-1-natechancellor@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      727344f1
    • Lu Baolu's avatar
      iommu/vt-d: Check capability before disabling protected memory · 486d8220
      Lu Baolu authored
      [ Upstream commit 5bb71fc7 ]
      
      The spec states in 10.4.16 that the Protected Memory Enable
      Register should be treated as read-only for implementations
      not supporting protected memory regions (PLMR and PHMR fields
      reported as Clear in the Capability register).
      
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: mark gross <mgross@intel.com>
      Suggested-by: default avatarAshok Raj <ashok.raj@intel.com>
      Fixes: f8bab735 ("intel-iommu: PMEN support")
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      486d8220
    • YueHaibing's avatar
      drm/nouveau/debugfs: Fix check of pm_runtime_get_sync failure · 19525f7b
      YueHaibing authored
      [ Upstream commit 909e9c9c ]
      
      pm_runtime_get_sync returns negative on failure.
      
      Fixes: eaeb9010 ("drm/nouveau/debugfs: Wake up GPU before doing any reclocking")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19525f7b
    • Matthew Whitehead's avatar
      x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors · 20afb90f
      Matthew Whitehead authored
      [ Upstream commit 18fb053f ]
      
      There are comments in processor-cyrix.h advising you to _not_ make calls
      using the deprecated macros in this style:
      
        setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
      
      This is because it expands the macro into a non-functioning calling
      sequence. The calling order must be:
      
        outb(CX86_CCR2, 0x22);
        inb(0x23);
      
      From the comments:
      
       * When using the old macros a line like
       *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
       * gets expanded to:
       *  do {
       *    outb((CX86_CCR2), 0x22);
       *    outb((({
       *        outb((CX86_CCR2), 0x22);
       *        inb(0x23);
       *    }) | 0x88), 0x23);
       *  } while (0);
      
      The new macros fix this problem, so use them instead. Tested on an
      actual Geode processor.
      Signed-off-by: default avatarMatthew Whitehead <tedheadster@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: luto@kernel.org
      Link: https://lkml.kernel.org/r/1552596361-8967-2-git-send-email-tedheadster@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      20afb90f
    • Aditya Pakki's avatar
      x86/hpet: Prevent potential NULL pointer dereference · c65812de
      Aditya Pakki authored
      [ Upstream commit 2e84f116 ]
      
      hpet_virt_address may be NULL when ioremap_nocache fail, but the code lacks
      a check.
      
      Add a check to prevent NULL pointer dereference.
      Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: kjlu@umn.edu
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Nicolai Stange <nstange@suse.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Link: https://lkml.kernel.org/r/20190319021958.17275-1-pakki001@umn.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      c65812de
    • Jianguo Chen's avatar
      irqchip/mbigen: Don't clear eventid when freeing an MSI · 04260753
      Jianguo Chen authored
      [ Upstream commit fca269f2 ]
      
      mbigen_write_msg clears eventid bits of a mbigen register
      when free a interrupt, because msi_domain_deactivate memset
      struct msg to zero. Then multiple mbigen pins with zero eventid
      will report the same interrupt number.
      
      The eventid clear call trace:
                      free_irq
                      __free_irq
                      irq_shutdown
                      irq_domain_deactivate_irq
                      __irq_domain_deactivate_irq
                      __irq_domain_deactivate_irq
                      msi_domain_deactivate
                      platform_msi_write_msg
                      mbigen_write_msg
      Signed-off-by: default avatarJianguo Chen <chenjianguo3@huawei.com>
      [maz: massaged subject]
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04260753
    • Changbin Du's avatar
      perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test() · b1930a27
      Changbin Du authored
      [ Upstream commit d982b331 ]
      
        =================================================================
        ==20875==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 1160 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc84138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x55bd50005599 in zalloc util/util.h:23
            #2 0x55bd500068f5 in perf_evsel__newtp_idx util/evsel.c:327
            #3 0x55bd4ff810fc in perf_evsel__newtp /home/work/linux/tools/perf/util/evsel.h:216
            #4 0x55bd4ff81608 in test__perf_evsel__tp_sched_test tests/evsel-tp-sched.c:69
            #5 0x55bd4ff528e6 in run_test tests/builtin-test.c:358
            #6 0x55bd4ff52baf in test_and_print tests/builtin-test.c:388
            #7 0x55bd4ff543fe in __cmd_test tests/builtin-test.c:583
            #8 0x55bd4ff5572f in cmd_test tests/builtin-test.c:722
            #9 0x55bd4ffc4087 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #10 0x55bd4ffc45c6 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #11 0x55bd4ffc49ca in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #12 0x55bd4ffc5138 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #13 0x7f1b6e34809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 19 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc83f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x7f1b6e3ac30f in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x8830f)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 6a6cd11d ("perf test: Add test for the sched tracepoint format fields")
      Link: http://lkml.kernel.org/r/20190316080556.3075-17-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b1930a27
    • Changbin Du's avatar
      perf tests: Fix memory leak by expr__find_other() in test__expr() · 4c66a273
      Changbin Du authored
      [ Upstream commit f97a8991 ]
      
        =================================================================
        ==7506==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 13 byte(s) in 3 object(s) allocated from:
            #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x5625e53aaef0 in expr__find_other util/expr.y:221
            #2 0x5625e51bcd3f in test__expr tests/expr.c:52
            #3 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #4 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #6 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 07516736 ("perf tools: Add a simple expression parser for JSON")
      Link: http://lkml.kernel.org/r/20190316080556.3075-16-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4c66a273
    • Changbin Du's avatar
      perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test · a0898f57
      Changbin Du authored
      [ Upstream commit 93faa52e ]
      
        =================================================================
        ==7497==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 40 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a88f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x5625e5326213 in cpu_map__trim_new util/cpumap.c:45
            #2 0x5625e5326703 in cpu_map__read util/cpumap.c:103
            #3 0x5625e53267ef in cpu_map__read_all_cpu_map util/cpumap.c:120
            #4 0x5625e5326915 in cpu_map__new util/cpumap.c:135
            #5 0x5625e517b355 in test__openat_syscall_event_on_all_cpus tests/openat-syscall-all-cpus.c:36
            #6 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #7 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #8 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #9 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #10 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #11 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #12 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #13 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #14 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: f30a79b0 ("perf tools: Add reference counting for cpu_map object")
      Link: http://lkml.kernel.org/r/20190316080556.3075-15-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0898f57
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Free evsel->counts in perf_evsel__exit() · 952d449d
      Arnaldo Carvalho de Melo authored
      [ Upstream commit 42dfa451 ]
      
      Using gcc's ASan, Changbin reports:
      
        =================================================================
        ==7494==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 48 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e5330a5e in zalloc util/util.h:23
            #2 0x5625e5330a9b in perf_counts__new util/counts.c:10
            #3 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #4 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #5 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #6 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #7 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #8 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #9 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #10 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #11 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #12 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #13 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #14 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #15 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 72 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e532560d in zalloc util/util.h:23
            #2 0x5625e532566b in xyarray__new util/xyarray.c:10
            #3 0x5625e5330aba in perf_counts__new util/counts.c:15
            #4 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #5 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #6 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #7 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #8 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #9 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #10 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #11 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #12 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #13 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #14 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #15 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #16 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
      His patch took care of evsel->prev_raw_counts, but the above backtraces
      are about evsel->counts, so fix that instead.
      Reported-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: https://lkml.kernel.org/n/tip-hd1x13g59f0nuhe4anxhsmfp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      952d449d
    • Changbin Du's avatar
      perf hist: Add missing map__put() in error case · ff22178b
      Changbin Du authored
      [ Upstream commit cb6186ae ]
      
      We need to map__put() before returning from failure of
      sample__resolve_callchain().
      
      Detected with gcc's ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 9c68ae98 ("perf callchain: Reference count maps")
      Link: http://lkml.kernel.org/r/20190316080556.3075-10-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff22178b
    • Changbin Du's avatar
      perf top: Fix error handling in cmd_top() · dac5fedf
      Changbin Du authored
      [ Upstream commit 70c819e4 ]
      
      We should go to the cleanup path, to avoid leaks, detected using gcc's
      ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-9-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dac5fedf
    • Changbin Du's avatar
      perf build-id: Fix memory leak in print_sdt_events() · 801a5901
      Changbin Du authored
      [ Upstream commit 8bde8516 ]
      
      Detected with gcc's ASan:
      
        Direct leak of 4356 byte(s) in 120 object(s) allocated from:
            #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215
            #2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339
            #3 0x55719af66272 in print_events util/parse-events.c:2542
            #4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
            #5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520
            #9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 40218dae ("perf list: Show SDT and pre-cached events")
      Link: http://lkml.kernel.org/r/20190316080556.3075-7-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      801a5901
    • Changbin Du's avatar
      perf config: Fix a memory leak in collect_config() · b820793a
      Changbin Du authored
      [ Upstream commit 54569ba4 ]
      
      Detected with gcc's ASan:
      
        Direct leak of 66 byte(s) in 5 object(s) allocated from:
            #0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x560c8761034d in collect_config util/config.c:597
            #2 0x560c8760d9cb in get_value util/config.c:169
            #3 0x560c8760dfd7 in perf_parse_file util/config.c:285
            #4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
            #5 0x560c876108fd in perf_config_set__init util/config.c:661
            #6 0x560c87610c72 in perf_config_set__new util/config.c:709
            #7 0x560c87610d2f in perf_config__init util/config.c:718
            #8 0x560c87610e5d in perf_config util/config.c:730
            #9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
            #10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Fixes: 20105ca1 ("perf config: Introduce perf_config_set class")
      Link: http://lkml.kernel.org/r/20190316080556.3075-6-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b820793a
    • Changbin Du's avatar
      perf config: Fix an error in the config template documentation · 0d85f280
      Changbin Du authored
      [ Upstream commit 9b40dff7 ]
      
      The option 'sort-order' should be 'sort_order'.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 893c5c79 ("perf config: Show default report configuration in example and docs")
      Link: http://lkml.kernel.org/r/20190316080556.3075-5-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d85f280
    • Changbin Du's avatar
      perf list: Don't forget to drop the reference to the allocated thread_map · 96f74822
      Changbin Du authored
      [ Upstream commit 39df730b ]
      
      Detected via gcc's ASan:
      
        Direct leak of 2048 byte(s) in 64 object(s) allocated from:
          6     #0 0x7f606512e370 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee370)
          7     #1 0x556b0f1d7ddd in thread_map__realloc util/thread_map.c:43
          8     #2 0x556b0f1d84c7 in thread_map__new_by_tid util/thread_map.c:85
          9     #3 0x556b0f0e045e in is_event_supported util/parse-events.c:2250
         10     #4 0x556b0f0e1aa1 in print_hwcache_events util/parse-events.c:2382
         11     #5 0x556b0f0e3231 in print_events util/parse-events.c:2514
         12     #6 0x556b0ee0a66e in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
         13     #7 0x556b0f01e0ae in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
         14     #8 0x556b0f01e859 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
         15     #9 0x556b0f01edc8 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
         16     #10 0x556b0f01f71f in main /home/changbin/work/linux/tools/perf/perf.c:520
         17     #11 0x7f6062ccf09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 89896051 ("perf tools: Do not put a variable sized type not at the end of a struct")
      Link: http://lkml.kernel.org/r/20190316080556.3075-3-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96f74822
    • David Arcari's avatar
      tools/power turbostat: return the exit status of a command · 182d2649
      David Arcari authored
      [ Upstream commit 2a954966 ]
      
      turbostat failed to return a non-zero exit status even though the
      supplied command (turbostat <command>) failed.  Currently when turbostat
      forks a command it returns zero instead of the actual exit status of the
      command.  Modify the code to return the exit status.
      Signed-off-by: default avatarDavid Arcari <darcari@redhat.com>
      Acked-by: default avatarLen Brown <len.brown@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      182d2649
    • Matteo Croce's avatar
      x86/mm: Don't leak kernel addresses · 3fb2d0a2
      Matteo Croce authored
      [ Upstream commit a3151724 ]
      
      Since commit:
      
        ad67b74d ("printk: hash addresses printed with %p")
      
      at boot "____ptrval____" is printed instead of actual addresses:
      
          found SMP MP-table at [mem 0x000f5cc0-0x000f5ccf] mapped at [(____ptrval____)]
      
      Instead of changing the print to "%px", and leaking a kernel addresses,
      just remove the print completely, like in:
      
        071929db ("arm64: Stop printing the virtual memory layout").
      Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3fb2d0a2
    • Maurizio Lombardi's avatar
      scsi: iscsi: flush running unbind operations when removing a session · 58ad2f1b
      Maurizio Lombardi authored
      [ Upstream commit 165aa2bf ]
      
      In some cases, the iscsi_remove_session() function is called while an
      unbind_work operation is still running.  This may cause a situation where
      sysfs objects are removed in an incorrect order, triggering a kernel
      warning.
      
      [  605.249442] ------------[ cut here ]------------
      [  605.259180] sysfs group 'power' not found for kobject 'target2:0:0'
      [  605.321371] WARNING: CPU: 1 PID: 26794 at fs/sysfs/group.c:235 sysfs_remove_group+0x76/0x80
      [  605.341266] Modules linked in: dm_service_time target_core_user target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod nls_utf8 isofs ppdev bochs_drm nfit ttm libnvdimm drm_kms_helper syscopyarea sysfillrect sysimgblt joydev pcspkr fb_sys_fops drm i2c_piix4 sg parport_pc parport xfs libcrc32c dm_multipath sr_mod sd_mod cdrom ata_generic 8021q garp mrp ata_piix stp crct10dif_pclmul crc32_pclmul llc libata crc32c_intel virtio_net net_failover ghash_clmulni_intel serio_raw failover sunrpc dm_mirror dm_region_hash dm_log dm_mod be2iscsi bnx2i cnic uio cxgb4i cxgb4 libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi
      [  605.627479] CPU: 1 PID: 26794 Comm: kworker/u32:2 Not tainted 4.18.0-60.el8.x86_64 #1
      [  605.721401] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20180724_192412-buildhw-07.phx2.fedoraproject.org-1.fc29 04/01/2014
      [  605.823651] Workqueue: scsi_wq_2 __iscsi_unbind_session [scsi_transport_iscsi]
      [  605.830940] RIP: 0010:sysfs_remove_group+0x76/0x80
      [  605.922907] Code: 48 89 df 5b 5d 41 5c e9 38 c4 ff ff 48 89 df e8 e0 bf ff ff eb cb 49 8b 14 24 48 8b 75 00 48 c7 c7 38 73 cb a7 e8 24 77 d7 ff <0f> 0b 5b 5d 41 5c c3 0f 1f 00 0f 1f 44 00 00 41 56 41 55 41 54 55
      [  606.122304] RSP: 0018:ffffbadcc8d1bda8 EFLAGS: 00010286
      [  606.218492] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [  606.326381] RDX: ffff98bdfe85eb40 RSI: ffff98bdfe856818 RDI: ffff98bdfe856818
      [  606.514498] RBP: ffffffffa7ab73e0 R08: 0000000000000268 R09: 0000000000000007
      [  606.529469] R10: 0000000000000000 R11: ffffffffa860d9ad R12: ffff98bdf978e838
      [  606.630535] R13: ffff98bdc2cd4010 R14: ffff98bdc2cd3ff0 R15: ffff98bdc2cd4000
      [  606.824707] FS:  0000000000000000(0000) GS:ffff98bdfe840000(0000) knlGS:0000000000000000
      [  607.018333] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  607.117844] CR2: 00007f84b78ac024 CR3: 000000002c00a003 CR4: 00000000003606e0
      [  607.117844] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  607.420926] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  607.524236] Call Trace:
      [  607.530591]  device_del+0x56/0x350
      [  607.624393]  ? ata_tlink_match+0x30/0x30 [libata]
      [  607.727805]  ? attribute_container_device_trigger+0xb4/0xf0
      [  607.829911]  scsi_target_reap_ref_release+0x39/0x50
      [  607.928572]  scsi_remove_target+0x1a2/0x1d0
      [  608.017350]  __iscsi_unbind_session+0xb3/0x160 [scsi_transport_iscsi]
      [  608.117435]  process_one_work+0x1a7/0x360
      [  608.132917]  worker_thread+0x30/0x390
      [  608.222900]  ? pwq_unbound_release_workfn+0xd0/0xd0
      [  608.323989]  kthread+0x112/0x130
      [  608.418318]  ? kthread_bind+0x30/0x30
      [  608.513821]  ret_from_fork+0x35/0x40
      [  608.613909] ---[ end trace 0b98c310c8a6138c ]---
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Acked-by: default avatarChris Leech <cleech@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      58ad2f1b
    • Zhang Rui's avatar
      thermal/intel_powerclamp: fix truncated kthread name · f1e062e8
      Zhang Rui authored
      [ Upstream commit e925b5be ]
      
      kthread name only allows 15 characters (TASK_COMMON_LEN is 16).
      Thus rename the kthreads created by intel_powerclamp driver from
      "kidle_inject/ + decimal cpuid" to "kidle_inj/ + decimal cpuid"
      to avoid truncated kthead name for cpu 100 and later.
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1e062e8
    • Matthew Garrett's avatar
      thermal/int340x_thermal: fix mode setting · 637f86d2
      Matthew Garrett authored
      [ Upstream commit 396ee4d0 ]
      
      int3400 only pushes the UUID into the firmware when the mode is flipped
      to "enable". The current code only exposes the mode flag if the firmware
      supports the PASSIVE_1 UUID, which not all machines do. Remove the
      restriction.
      Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      637f86d2
    • Matthew Garrett's avatar
      thermal/int340x_thermal: Add additional UUIDs · f37079c7
      Matthew Garrett authored
      [ Upstream commit 16fc8eca ]
      
      Add more supported DPTF policies than the driver currently exposes.
      Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
      Cc: Nisha Aram <nisha.aram@intel.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f37079c7
    • Phil Elwell's avatar
      thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs · 6aa84e8a
      Phil Elwell authored
      [ Upstream commit 35122495 ]
      
      "cat /sys/kernel/debug/bcm2835_thermal/regset" causes a NULL pointer
      dereference in bcm2835_thermal_debugfs. The driver makes use of the
      implementation details of the thermal framework to retrieve a pointer
      to its private data from a struct thermal_zone_device, and gets it
      wrong - leading to the crash. Instead, store its private data as the
      drvdata and retrieve the thermal_zone_device pointer from it.
      
      Fixes: bcb7dd9e ("thermal: bcm2835: add thermal driver for bcm2835 SoC")
      Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.org>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6aa84e8a
    • Luc Van Oostenryck's avatar
      thermal/intel_powerclamp: fix __percpu declaration of worker_data · 643deb59
      Luc Van Oostenryck authored
      [ Upstream commit aa36e361 ]
      
      This variable is declared as:
      	static struct powerclamp_worker_data * __percpu worker_data;
      In other words, a percpu pointer to struct ...
      
      But this variable not used like so but as a pointer to a percpu
      struct powerclamp_worker_data.
      
      So fix the declaration as:
      	static struct powerclamp_worker_data __percpu *worker_data;
      
      This also quiets Sparse's warnings from __verify_pcpu_ptr(), like:
        494:49: warning: incorrect type in initializer (different address spaces)
        494:49:    expected void const [noderef] <asn:3> *__vpp_verify
        494:49:    got struct powerclamp_worker_data *
      Signed-off-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      643deb59