1. 01 12月, 2019 40 次提交
    • M
      powerpc/mm/radix: Fix small page at boundary when splitting · b43c5287
      Michael Ellerman 提交于
      [ Upstream commit 81d1b54dec95209ab5e5be2cf37182885f998753 ]
      
      When we have CONFIG_STRICT_KERNEL_RWX enabled, we want to split the
      linear mapping at the text/data boundary so we can map the kernel
      text read only.
      
      Currently we always use a small page at the text/data boundary, even
      when that's not necessary:
      
        Mapped 0x0000000000000000-0x0000000000e00000 with 2.00 MiB pages
        Mapped 0x0000000000e00000-0x0000000001000000 with 64.0 KiB pages
        Mapped 0x0000000001000000-0x0000000040000000 with 2.00 MiB pages
      
      This is because the check that the mapping crosses the __init_begin
      boundary is too strict, it also returns true when we map exactly up to
      the boundary.
      
      So fix it to check that the mapping would actually map past
      __init_begin, and with that we see:
      
        Mapped 0x0000000000000000-0x0000000040000000 with 2.00 MiB pages
        Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b43c5287
    • M
      powerpc/mm/radix: Fix overuse of small pages in splitting logic · b499fa07
      Michael Ellerman 提交于
      [ Upstream commit 3b5657ed5b4e27ccf593a41ff3c5aa27dae8df18 ]
      
      When we have CONFIG_STRICT_KERNEL_RWX enabled, we want to split the
      linear mapping at the text/data boundary so we can map the kernel text
      read only.
      
      But the current logic uses small pages for the entire text section,
      regardless of whether a larger page size would fit. eg. with the
      boundary at 16M we could use 2M pages, but instead we use 64K pages up
      to the 16M boundary:
      
        Mapped 0x0000000000000000-0x0000000001000000 with 64.0 KiB pages
        Mapped 0x0000000001000000-0x0000000040000000 with 2.00 MiB pages
        Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages
      
      This is because the test is checking if addr is < __init_begin
      and addr + mapping_size is >= _stext. But that is true for all pages
      between _stext and __init_begin.
      
      Instead what we want to check is if we are crossing the text/data
      boundary, which is at __init_begin. With that fixed we see:
      
        Mapped 0x0000000000000000-0x0000000000e00000 with 2.00 MiB pages
        Mapped 0x0000000000e00000-0x0000000001000000 with 64.0 KiB pages
        Mapped 0x0000000001000000-0x0000000040000000 with 2.00 MiB pages
        Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages
      
      ie. we're correctly using 2MB pages below __init_begin, but we still
      drop down to 64K pages unnecessarily at the boundary.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b499fa07
    • M
      powerpc/mm/radix: Fix off-by-one in split mapping logic · 434551e9
      Michael Ellerman 提交于
      [ Upstream commit 5c6499b7041b43807dfaeda28aa87fc0e62558f7 ]
      
      When we have CONFIG_STRICT_KERNEL_RWX enabled, we try to split the
      kernel linear (1:1) mapping so that the kernel text is in a separate
      page to kernel data, so we can mark the former read-only.
      
      We could achieve that just by always using 64K pages for the linear
      mapping, but we try to be smarter. Instead we use huge pages when
      possible, and only switch to smaller pages when necessary.
      
      However we have an off-by-one bug in that logic, which causes us to
      calculate the wrong boundary between text and data.
      
      For example with the end of the kernel text at 16M we see:
      
        radix-mmu: Mapped 0x0000000000000000-0x0000000001200000 with 64.0 KiB pages
        radix-mmu: Mapped 0x0000000001200000-0x0000000040000000 with 2.00 MiB pages
        radix-mmu: Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages
      
      ie. we mapped from 0 to 18M with 64K pages, even though the boundary
      between text and data is at 16M.
      
      With the fix we see we're correctly hitting the 16M boundary:
      
        radix-mmu: Mapped 0x0000000000000000-0x0000000001000000 with 64.0 KiB pages
        radix-mmu: Mapped 0x0000000001000000-0x0000000040000000 with 2.00 MiB pages
        radix-mmu: Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      434551e9
    • A
      powerpc/pseries: Export raw per-CPU VPA data via debugfs · ee35e01b
      Aravinda Prasad 提交于
      [ Upstream commit c6c26fb55e8e4b3fc376be5611685990a17de27a ]
      
      This patch exports the raw per-CPU VPA data via debugfs.
      A per-CPU file is created which exports the VPA data of
      that CPU to help debug some of the VPA related issues or
      to analyze the per-CPU VPA related statistics.
      
      v3: Removed offline CPU check.
      
      v2: Included offline CPU check and other review comments.
      Signed-off-by: NAravinda Prasad <aravinda@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ee35e01b
    • G
      scsi: hisi_sas: Fix NULL pointer dereference · 9ed143cf
      Gustavo A. R. Silva 提交于
      [ Upstream commit f4445bb93d82a984657b469e63118c2794a4c3d3 ]
      
      There is a NULL pointer dereference in case *slot* happens to be NULL at
      lines 1053 and 1878:
      
      struct hisi_sas_cq *cq =
      	&hisi_hba->cq[slot->dlvry_queue];
      
      Notice that *slot* is being NULL checked at lines 1057 and 1881:
      if (slot), which implies it may be NULL.
      
      Fix this by placing the declaration and definition of variable cq, which
      contains the pointer dereference slot->dlvry_queue, after slot has been
      properly NULL checked.
      
      Addresses-Coverity-ID: 1474515 ("Dereference before null check")
      Addresses-Coverity-ID: 1474520 ("Dereference before null check")
      Fixes: 584f53fe5f52 ("scsi: hisi_sas: Fix the race between IO completion and timeout for SMP/internal IO")
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: NXiang Chen <chenxiang66@hisilicon.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9ed143cf
    • D
      sparc: Fix parport build warnings. · ff6618e0
      David S. Miller 提交于
      [ Upstream commit 46b8306480fb424abd525acc1763da1c63a27d8a ]
      
      If PARPORT_PC_FIFO is not enabled, do not provide the dma lock
      macros and lock definition.  Otherwise:
      
      ./arch/sparc/include/asm/parport.h:24:24: warning: ‘dma_spin_lock’ defined but not used [-Wunused-variable]
       static DEFINE_SPINLOCK(dma_spin_lock);
                              ^~~~~~~~~~~~~
      ./include/linux/spinlock_types.h:81:39: note: in definition of macro ‘DEFINE_SPINLOCK’
       #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ff6618e0
    • J
      x86/intel_rdt: Prevent pseudo-locking from using stale pointers · 3d02e3bb
      Jithu Joseph 提交于
      [ Upstream commit b61b8bba18fe2b63d38fdaf9b83de25e2d787dfe ]
      
      When the last CPU in an rdt_domain goes offline, its rdt_domain struct gets
      freed. Current pseudo-locking code is unaware of this scenario and tries to
      dereference the freed structure in a few places.
      
      Add checks to prevent pseudo-locking code from doing this.
      
      While further work is needed to seamlessly restore resource groups (not
      just pseudo-locking) to their configuration when the domain is brought back
      online, the immediate issue of invalid pointers is addressed here.
      
      Fixes: f4e80d67 ("x86/intel_rdt: Resctrl files reflect pseudo-locked information")
      Fixes: 443810fe ("x86/intel_rdt: Create debugfs files for pseudo-locking testing")
      Fixes: 746e0859 ("x86/intel_rdt: Create character device exposing pseudo-locked region")
      Fixes: 33dc3e41 ("x86/intel_rdt: Make CPU information accessible for pseudo-locked regions")
      Signed-off-by: NJithu Joseph <jithu.joseph@intel.com>
      Signed-off-by: NReinette Chatre <reinette.chatre@intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: fenghua.yu@intel.com
      Cc: tony.luck@intel.com
      Cc: gavin.hindman@intel.com
      Cc: hpa@zytor.com
      Link: https://lkml.kernel.org/r/231f742dbb7b00a31cc104416860e27dba6b072d.1539384145.git.reinette.chatre@intel.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      3d02e3bb
    • V
      spi: omap2-mcspi: Set FIFO DMA trigger level to word length · b6e44f74
      Vignesh R 提交于
      [ Upstream commit b682cffa3ac6d9d9e16e9b413c45caee3b391fab ]
      
      McSPI has 32 byte FIFO in Transmit-Receive mode. Current code tries to
      configuration FIFO watermark level for DMA trigger to be GCD of transfer
      length and max FIFO size which would mean trigger level may be set to 32
      for transmit-receive mode if length is aligned. This does not work in
      case of SPI slave mode where FIFO always needs to have data ready
      whenever master starts the clock. With DMA trigger size of 32 there will
      be a small window during slave TX where DMA is still putting data into
      FIFO but master would have started clock for next byte, resulting in
      shifting out of stale data. Similarly, on Slave RX side there may be RX
      FIFO overflow
      Fix this by setting FIFO watermark for DMA trigger to word
      length. This means DMA is triggered as soon as FIFO has space for word
      length bytes and DMA would make sure FIFO is almost always full
      therefore improving FIFO occupancy in both master and slave mode.
      Signed-off-by: NVignesh R <vigneshr@ti.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b6e44f74
    • C
      swiotlb: do not panic on mapping failures · ad9a4e96
      Christoph Hellwig 提交于
      [ Upstream commit 8088546832aa2c0d8f99dd56edf6384f8a9b63b3 ]
      
      All properly written drivers now have error handling in the
      dma_map_single / dma_map_page callers.  As swiotlb_tbl_map_single already
      prints a useful warning when running out of swiotlb pool space we can
      also remove swiotlb_full entirely as it serves no purpose now.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ad9a4e96
    • T
      s390/perf: Return error when debug_register fails · 9b572e8b
      Thomas Richter 提交于
      [ Upstream commit ec0c0bb489727de0d4dca6a00be6970ab8a3b30a ]
      
      Return an error when the function debug_register() fails allocating
      the debug handle.
      Also remove the registered debug handle when the initialization fails
      later on.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9b572e8b
    • N
      atm: zatm: Fix empty body Clang warnings · 641f1f79
      Nathan Chancellor 提交于
      [ Upstream commit 64b9d16e2d02ca6e5dc8fcd30cfd52b0ecaaa8f4 ]
      
      Clang warns:
      
      drivers/atm/zatm.c:513:7: error: while loop has empty body
      [-Werror,-Wempty-body]
              zwait;
                   ^
      drivers/atm/zatm.c:513:7: note: put the semicolon on a separate line to
      silence this warning
      
      Get rid of this warning by using an empty do-while loop. While we're at
      it, add parentheses to make it clear that this is a function-like macro.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/42Suggested-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      641f1f79
    • J
      sunrpc: safely reallow resvport min/max inversion · f9304c62
      J. Bruce Fields 提交于
      [ Upstream commit 826799e66e8683e5698e140bb9ef69afc8c0014e ]
      
      Commits ffb6ca33 and e08ea3a9 prevent setting xprt_min_resvport
      greater than xprt_max_resvport, but may also break simple code that sets
      one parameter then the other, if the new range does not overlap the old.
      
      Also it looks racy to me, unless there's some serialization I'm not
      seeing.  Granted it would probably require malicious privileged processes
      (unless there's a chance these might eventually be settable in unprivileged
      containers), but still it seems better not to let userspace panic the
      kernel.
      
      Simpler seems to be to allow setting the parameters to whatever you want
      but interpret xprt_min_resvport > xprt_max_resvport as the empty range.
      
      Fixes: ffb6ca33 "sunrpc: Prevent resvport min/max inversion..."
      Fixes: e08ea3a9 "sunrpc: Prevent rexvport min/max inversion..."
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f9304c62
    • T
      SUNRPC: Fix a compile warning for cmpxchg64() · 7983dea8
      Trond Myklebust 提交于
      [ Upstream commit e732f4485a150492b286f3efc06f9b34dd6b9995 ]
      Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7983dea8
    • P
      selftests/bpf: fix file resource leak in load_kallsyms · a0ec7f6e
      Peng Hao 提交于
      [ Upstream commit 1bd70d2eba9d90eb787634361f0f6fa2c86b3f6d ]
      
      FILE pointer variable f is opened but never closed.
      Signed-off-by: NPeng Hao <peng.hao2@zte.com.cn>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a0ec7f6e
    • H
      dm raid: avoid bitmap with raid4/5/6 journal device · 56b8b183
      Heinz Mauelshagen 提交于
      [ Upstream commit d857ad75edf3c0066fcd920746f9dc75382b3324 ]
      
      With raid4/5/6, journal device and write intent bitmap are mutually exclusive.
      Signed-off-by: NHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      56b8b183
    • X
      sctp: use sk_wmem_queued to check for writable space · 4de506d5
      Xin Long 提交于
      [ Upstream commit cd305c74b0f8b49748a79a8f67fc8e5e3e0c4794 ]
      
      sk->sk_wmem_queued is used to count the size of chunks in out queue
      while sk->sk_wmem_alloc is for counting the size of chunks has been
      sent. sctp is increasing both of them before enqueuing the chunks,
      and using sk->sk_wmem_alloc to check for writable space.
      
      However, sk_wmem_alloc is also increased by 1 for the skb allocked
      for sending in sctp_packet_transmit() but it will not wake up the
      waiters when sk_wmem_alloc is decreased in this skb's destructor.
      
      If msg size is equal to sk_sndbuf and sendmsg is waiting for sndbuf,
      the check 'msg_len <= sctp_wspace(asoc)' in sctp_wait_for_sndbuf()
      will keep waiting if there's a skb allocked in sctp_packet_transmit,
      and later even if this skb got freed, the waiting thread will never
      get waked up.
      
      This issue has been there since very beginning, so we change to use
      sk->sk_wmem_queued to check for writable space as sk_wmem_queued is
      not increased for the skb allocked for sending, also as TCP does.
      
      SOCK_SNDBUF_LOCK check is also removed here as it's for tx buf auto
      tuning which I will add in another patch.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      4de506d5
    • C
      usbip: tools: fix atoi() on non-null terminated string · 1f7f2a06
      Colin Ian King 提交于
      [ Upstream commit e325808c0051b16729ffd472ff887c6cae5c6317 ]
      
      Currently the call to atoi is being passed a single char string
      that is not null terminated, so there is a potential read overrun
      along the stack when parsing for an integer value.  Fix this by
      instead using a 2 char string that is initialized to all zeros
      to ensure that a 1 char read into the string is always terminated
      with a \0.
      
      Detected by cppcheck:
      "Invalid atoi() argument nr 1. A nul-terminated string is required."
      
      Fixes: 3391ba0e ("usbip: tools: Extract generic code to be shared with vudc backend")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1f7f2a06
    • M
      USB: misc: appledisplay: fix backlight update_status return code · 283d9618
      Mattias Jacobsson 提交于
      [ Upstream commit 090158555ff8d194a98616034100b16697dd80d0 ]
      
      Upon success the update_status handler returns a positive number
      corresponding to the number of bytes transferred by usb_control_msg.
      However the return code of the update_status handler should indicate if
      an error occurred(negative) or how many bytes of the user's input to sysfs
      that was consumed. Return code zero indicates all bytes were consumed.
      
      The bug can for example result in the update_status handler being called
      twice, the second time with only the "unconsumed" part of the user's input
      to sysfs. Effectively setting an incorrect brightness.
      
      Change the update_status handler to return zero for all successful
      transactions and forward usb_control_msg's error code upon failure.
      Signed-off-by: NMattias Jacobsson <2pi@mok.nu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      283d9618
    • J
      PCI: vmd: Detach resources after stopping root bus · 80a23f70
      Jon Derrick 提交于
      [ Upstream commit dc8af3a827df6d4bb925d3b81b7ec94a7cce9482 ]
      
      The VMD removal path calls pci_stop_root_busi(), which tears down the pcie
      tree, including detaching all of the attached drivers. During driver
      detachment, devices may use pci_release_region() to release resources.
      This path relies on the resource being accessible in resource tree.
      
      By detaching the child domain from the parent resource domain prior to
      stopping the bus, we are preventing the list traversal from finding the
      resource to be freed. If we instead detach the resource after stopping
      the bus, we will have properly freed the resource and detaching is
      simply accounting at that point.
      
      Without this order, the resource is never freed and is orphaned on VMD
      removal, leading to a warning:
      
      [  181.940162] Trying to free nonexistent resource <e5a10000-e5a13fff>
      
      Fixes: 2c2c5c5c ("x86/PCI: VMD: Attach VMD resources to parent domain's resource tree")
      Signed-off-by: NJon Derrick <jonathan.derrick@intel.com>
      [lorenzo.pieralisi@arm.com: updated commit log]
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: NKeith Busch <keith.busch@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      80a23f70
    • B
      macintosh/windfarm_smu_sat: Fix debug output · b0f69ccf
      Benjamin Herrenschmidt 提交于
      [ Upstream commit fc0c8b36d379a046525eacb9c3323ca635283757 ]
      
      There's some antiquated debug output that's trying
      to do a hand-made hexdump and turning into horrible
      1-byte-per-line output these days.
      
      Use print_hex_dump() instead
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b0f69ccf
    • P
      ALSA: i2c/cs8427: Fix int to char conversion · 86f63146
      Philipp Klocke 提交于
      [ Upstream commit eb7ebfa3c1989aa8e59d5e68ab3cddd7df1bfb27 ]
      
      Compiling with clang yields the following warning:
      
      sound/i2c/cs8427.c:140:31: warning: implicit conversion from 'int'
      to 'char' changes value from 160 to -96 [-Wconstant-conversion]
          data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF;
                  ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      
      Because CS8427_REG_AUTOINC is defined as 128, it is too big for a
      char field.
      So change data from char to unsigned char, that it can hold the value.
      
      This patch does not change the generated code.
      Signed-off-by: NPhilipp Klocke <philipp97kl@gmail.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      86f63146
    • U
      PM / Domains: Deal with multiple states but no governor in genpd · 46729b27
      Ulf Hansson 提交于
      [ Upstream commit 2c9b7f8772033cc8bafbd4eefe2ca605bf3eb094 ]
      
      A caller of pm_genpd_init() that provides some states for the genpd via the
      ->states pointer in the struct generic_pm_domain, should also provide a
      governor. This because it's the job of the governor to pick a state that
      satisfies the constraints.
      
      Therefore, let's print a warning to inform the user about such bogus
      configuration and avoid to bail out, by instead picking the shallowest
      state before genpd invokes the ->power_off() callback.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NLina Iyer <ilina@codeaurora.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      46729b27
    • H
      ACPI / scan: Create platform device for INT33FE ACPI nodes · cf800f2b
      Hans de Goede 提交于
      [ Upstream commit 589edb56b424876cbbf61547b987a1f57d7ea99d ]
      
      Bay and Cherry Trail devices with a Dollar Cove or Whiskey Cove PMIC
      have an ACPI node with a HID of INT33FE which is a "virtual" battery
      device implementing a standard ACPI battery interface which depends upon
      a proprietary, undocument OpRegion called BMOP. Since we do have docs
      for the actual fuel-gauges used on these boards we instead use native
      fuel-gauge drivers talking directly to the fuel-gauge ICs on boards which
      rely on this INT33FE device for their battery monitoring.
      
      On boards with a Dollar Cove PMIC the INT33FE device's resources (_CRS)
      describe a non-existing I2C client at address 0x6b with a bus-speed of
      100KHz. This is a problem on some boards since there are actual devices
      on that same bus which need a speed of 400KHz to function properly.
      
      This commit adds the INT33FE HID to the list of devices with I2C resources
      which should be enumerated as a platform-device rather then letting the
      i2c-core instantiate an i2c-client matching the first I2C resource,
      so that its bus-speed will not influence the max speed of the I2C bus.
      This fixes e.g. the touchscreen not working on the Teclast X98 II Plus.
      
      The INT33FE device on boards with a Whiskey Cove PMIC is somewhat special.
      Its first I2C resource is for a secondary I2C address of the PMIC itself,
      which is already described in an ACPI device with an INT34D3 HID.
      
      But it has 3 more I2C resources describing 3 other chips for which we do
      need to instantiate I2C clients and which need device-connections added
      between them for things to work properly. This special case is handled by
      the drivers/platform/x86/intel_cht_int33fe.c code.
      
      Before this commit that code was binding to the i2c-client instantiated
      for the secondary I2C address of the PMIC, since we now instantiate a
      platform device for the INT33FE device instead, this commit also changes
      the intel_cht_int33fe driver from an i2c driver to a platform driver.
      
      This also brings the intel_cht_int33fe drv inline with how we instantiate
      multiple i2c clients from a single ACPI device in other cases, as done
      by the drivers/platform/x86/i2c-multi-instantiate.c code.
      Reported-and-tested-by: NAlexander Meiler <alex.meiler@protonmail.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      cf800f2b
    • S
      kprobes, x86/ptrace.h: Make regs_get_kernel_stack_nth() not fault on bad stack · cb6a3096
      Steven Rostedt (VMware) 提交于
      [ Upstream commit c2712b858187f5bcd7b042fe4daa3ba3a12635c0 ]
      
      Andy had some concerns about using regs_get_kernel_stack_nth() in a new
      function regs_get_kernel_argument() as if there's any error in the stack
      code, it could cause a bad memory access. To be on the safe side, call
      probe_kernel_read() on the stack address to be extra careful in accessing
      the memory. A helper function, regs_get_kernel_stack_nth_addr(), was added
      to just return the stack address (or NULL if not on the stack), that will be
      used to find the address (and could be used by other functions) and read the
      address with kernel_probe_read().
      Requested-by: NAndy Lutomirski <luto@amacapital.net>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Reviewed-by: NJoel Fernandes (Google) <joel@joelfernandes.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20181017165951.09119177@gandalf.local.homeSigned-off-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      cb6a3096
    • B
      xfs: clear ail delwri queued bufs on unmount of shutdown fs · f0f842a1
      Brian Foster 提交于
      [ Upstream commit efc3289cf8d39c34502a7cc9695ca2fa125aad0c ]
      
      In the typical unmount case, the AIL is forced out by the unmount
      sequence before the xfsaild task is stopped. Since AIL items are
      removed on writeback completion, this means that the AIL
      ->ail_buf_list delwri queue has been drained. This is not always
      true in the shutdown case, however.
      
      It's possible for buffers to sit on a delwri queue for a period of
      time across submission attempts if said items are locked or have
      been relogged and pinned since first added to the queue. If the
      attempt to log such an item results in a log I/O error, the error
      processing can shutdown the fs, remove the item from the AIL, stale
      the buffer (dropping the LRU reference) and clear its delwri queue
      state. The latter bit means the buffer will be released from a
      delwri queue on the next submission attempt, but this might never
      occur if the filesystem has shutdown and the AIL is empty.
      
      This means that such buffers are held indefinitely by the AIL delwri
      queue across destruction of the AIL. Aside from being a memory leak,
      these buffers can also hold references to in-core perag structures.
      The latter problem manifests as a generic/475 failure, reproducing
      the following asserts at unmount time:
      
        XFS: Assertion failed: atomic_read(&pag->pag_ref) == 0,
      	file: fs/xfs/xfs_mount.c, line: 151
        XFS: Assertion failed: atomic_read(&pag->pag_ref) == 0,
      	file: fs/xfs/xfs_mount.c, line: 132
      
      To prevent this problem, clear the AIL delwri queue as a final step
      before xfsaild() exit. The !empty state should never occur in the
      normal case, so add an assert to catch unexpected problems going
      forward.
      
      [dgc: add comment explaining need for xfs_buf_delwri_cancel() after
       calling xfs_buf_delwri_submit_nowait().]
      Signed-off-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f0f842a1
    • D
      xfs: fix use-after-free race in xfs_buf_rele · bb64349b
      Dave Chinner 提交于
      [ Upstream commit 37fd1678245f7a5898c1b05128bc481fb403c290 ]
      
      When looking at a 4.18 based KASAN use after free report, I noticed
      that racing xfs_buf_rele() may race on dropping the last reference
      to the buffer and taking the buffer lock. This was the symptom
      displayed by the KASAN report, but the actual issue that was
      reported had already been fixed in 4.19-rc1 by commit e339dd8d
      ("xfs: use sync buffer I/O for sync delwri queue submission").
      
      Despite this, I think there is still an issue with xfs_buf_rele()
      in this code:
      
              release = atomic_dec_and_lock(&bp->b_hold, &pag->pag_buf_lock);
              spin_lock(&bp->b_lock);
              if (!release) {
      .....
      
      If two threads race on the b_lock after both dropping a reference
      and one getting dropping the last reference so release = true, we
      end up with:
      
      CPU 0				CPU 1
      atomic_dec_and_lock()
      				atomic_dec_and_lock()
      				spin_lock(&bp->b_lock)
      spin_lock(&bp->b_lock)
      <spins>
      				<release = true bp->b_lru_ref = 0>
      				<remove from lists>
      				freebuf = true
      				spin_unlock(&bp->b_lock)
      				xfs_buf_free(bp)
      <gets lock, reading and writing freed memory>
      <accesses freed memory>
      spin_unlock(&bp->b_lock) <reads/writes freed memory>
      
      IOWs, we can't safely take bp->b_lock after dropping the hold
      reference because the buffer may go away at any time after we
      drop that reference. However, this can be fixed simply by taking the
      bp->b_lock before we drop the reference.
      
      It is safe to nest the pag_buf_lock inside bp->b_lock as the
      pag_buf_lock is only used to serialise against lookup in
      xfs_buf_find() and no other locks are held over or under the
      pag_buf_lock there. Make this clear by documenting the buffer lock
      orders at the top of the file.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      bb64349b
    • N
      net: ena: Fix Kconfig dependency on X86 · e0e8d83e
      Netanel Belgazal 提交于
      [ Upstream commit 8c590f9776386b8f697fd0b7ed6142ae6e3de79e ]
      
      The Kconfig limitation of X86 is to too wide.
      The ENA driver only requires a little endian dependency.
      
      Change the dependency to be on little endian CPU.
      Signed-off-by: NNetanel Belgazal <netanel@amazon.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e0e8d83e
    • K
      net: fix warning in af_unix · 7ac43755
      Kyeongdon Kim 提交于
      [ Upstream commit 33c4368ee2589c165aebd8d388cbd91e9adb9688 ]
      
      This fixes the "'hash' may be used uninitialized in this function"
      
      net/unix/af_unix.c:1041:20: warning: 'hash' may be used uninitialized in this function [-Wmaybe-uninitialized]
        addr->hash = hash ^ sk->sk_type;
      Signed-off-by: NKyeongdon Kim <kyeongdon.kim@lge.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7ac43755
    • M
      net: dsa: mv88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed · 5e110ec2
      Marek Behún 提交于
      [ Upstream commit 26422340da467538cd65eaa9c65538039ee99c8c ]
      
      This is a fix for the port_set_speed method for the Topaz family.
      Currently the same method is used as for the Peridot family, but
      this is wrong for the SERDES port.
      
      On Topaz, the SERDES port is port 5, not 9 and 10 as in Peridot.
      Moreover setting alt_bit on Topaz only makes sense for port 0 (for
      (differentiating 100mbps vs 200mbps). The SERDES port does not
      support more than 2500mbps, so alt_bit does not make any difference.
      Signed-off-by: NMarek Behún <marek.behun@nic.cz>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      5e110ec2
    • F
      scsi: zorro_esp: Limit DMA transfers to 65535 bytes · 274726bc
      Finn Thain 提交于
      [ Upstream commit b7ded0e8b0d11b6df1c4e5aa23a26e6629c21985 ]
      
      The core driver, esp_scsi, does not use the ESP_CONFIG2_FENAB bit, so the
      chip's Transfer Counter register is only 16 bits wide (not 24).  A larger
      transfer cannot work and will theoretically result in a failed command
      and a "DMA length is zero" error.
      
      Fixes: 3109e5ae ("scsi: zorro_esp: New driver for Amiga Zorro NCR53C9x boards")
      Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
      Cc: Michael Schmitz <schmitzmic@gmail.com>
      Tested-by: NMichael Schmitz <schmitzmic@gmail.com>
      Reviewed-by: NMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      274726bc
    • C
      scsi: dc395x: fix DMA API usage in sg_update_list · 1f13afca
      Christoph Hellwig 提交于
      [ Upstream commit 6c404a68bf83b4135a8a9aa1c388ebdf98e8ba7f ]
      
      We need to transfer device ownership to the CPU before we can manipulate
      the mapped data.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1f13afca
    • C
      scsi: dc395x: fix dma API usage in srb_done · e95ec662
      Christoph Hellwig 提交于
      [ Upstream commit 3a5bd7021184dec2946f2a4d7a8943f8a5713e52 ]
      
      We can't just transfer ownership to the CPU and then unmap, as this will
      break with swiotlb.
      
      Instead unmap the command and sense buffer a little earlier in the I/O
      completion handler and get rid of the pci_dma_sync_sg_for_cpu call
      entirely.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e95ec662
    • M
      ASoC: tegra_sgtl5000: fix device_node refcounting · 95655b10
      Marcel Ziswiler 提交于
      [ Upstream commit a85227da2dcc291b762c8482a505bc7d0d2d4b07 ]
      
      Similar to the following:
      
      commit 43217236 ("ASoC: tegra_alc5632: fix device_node refcounting")
      
      commit 7c5dfd54 ("ASoC: tegra: fix device_node refcounting")
      Signed-off-by: NMarcel Ziswiler <marcel.ziswiler@toradex.com>
      Acked-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      95655b10
    • A
      clk: at91: audio-pll: fix audio pmc type · f1f1002a
      Alexandre Belloni 提交于
      [ Upstream commit 7fa75007b7d7421aea59ff2b12ab1bd65a5abfa6 ]
      
      The allocation for the audio pmc is using the size of struct clk_audio_pad
      instead of struct clk_audio_pmc. This works fine because the former is
      larger than the latter but it is safer to be correct.
      
      Fixes: ("0865805d clk: at91: add audio pll clock drivers")
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f1f1002a
    • L
      clk: mmp2: fix the clock id for sdh2_clk and sdh3_clk · f15b8028
      Lubomir Rintel 提交于
      [ Upstream commit 4917fb90eec7c26dac1497ada3bd4a325f670fcc ]
      
      A typo that makes it impossible to get the correct clocks for
      MMP2_CLK_SDH2 and MMP2_CLK_SDH3.
      Signed-off-by: NLubomir Rintel <lkundrak@v3.sk>
      Fixes: 1ec770d9 ("clk: mmp: add mmp2 DT support for clock driver")
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f15b8028
    • H
      PCI: mediatek: Fixup MSI enablement logic by enabling MSI before clocks · 6391dd5e
      Honghui Zhang 提交于
      [ Upstream commit 3828d60fd2ef99f97a677c1f95af2ab3e65e2576 ]
      
      Commit 43e6409d ("PCI: mediatek: Add MSI support for MT2712 and
      MT7622") added MSI support but enabled MSI in the wrong place, at a step
      in the probe sequence where clocks were not still enabled.
      
      Fix this issue by calling mtk_pcie_enable_msi() in mtk_pcie_startup_port_v2()
      since clocks are enabled when mtk_pcie_startup_port_v2() is called.
      
      To avoid forward declaration of mtk_pcie_enable_msi(), move the
      mtk_pcie_startup_port_v2() function definition in the file.
      
      Fixes: 43e6409d ("PCI: mediatek: Add MSI support for MT2712 and MT7622")
      Signed-off-by: NHonghui Zhang <honghui.zhang@mediatek.com>
      [lorenzo.pieralisi@arm.com: squashed commit and adapted log]
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: NRyder Lee <ryder.lee@mediatek.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6391dd5e
    • K
      nvme-pci: fix hot removal during error handling · 305c262f
      Keith Busch 提交于
      [ Upstream commit cb4bfda62afa25b4eee3d635d33fccdd9485dd7c ]
      
      A removal waits for the reset_work to complete. If a surprise removal
      occurs around the same time as an error triggered controller reset, and
      reset work happened to dispatch a command to the removed controller, the
      command won't be recovered since the timeout work doesn't do anything
      during error recovery. We wouldn't want to wait for timeout handling
      anyway, so this patch fixes this by disabling the controller and killing
      admin queues prior to syncing with the reset_work.
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NSagi Grimberg <sagi@grimberg.me>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      305c262f
    • B
      nvmet-fcloop: suppress a compiler warning · 4e4b97f5
      Bart Van Assche 提交于
      [ Upstream commit 1216e9ef18b84f4fb5934792368fb01eb3540520 ]
      
      Building with W=1 enables the compiler warning -Wimplicit-fallthrough=3. That
      option does not recognize the fall-through comment in the fcloop driver. Add
      a fall-through comment that is recognized for -Wimplicit-fallthrough=3. This
      patch avoids that the compiler reports the following warning when building
      with W=1:
      
      drivers/nvme/target/fcloop.c:647:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
         if (op == NVMET_FCOP_READDATA)
            ^
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Reviewed-by: NJames Smart <james.smart@broadcom.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      4e4b97f5
    • B
      nvmet: avoid integer overflow in the discard code · 2f1e4e65
      Bart Van Assche 提交于
      [ Upstream commit 8eacd1bd21d6913ec27e6120e9a8733352e191d3 ]
      
      Although I'm not sure whether it is a good idea to support large discard
      commands, I think integer overflow for discard ranges larger than 4 GB
      should be avoided. This patch avoids that smatch reports the following:
      
      drivers/nvme/target/io-cmd-file.c:249:1 nvmet_file_execute_discard() warn: should '((range.nlb)) << req->ns->blksize_shift' be a 64 bit type?
      
      Fixes: d5eff33e ("nvmet: add simple file backed ns support")
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Reviewed-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2f1e4e65
    • N
      crypto: ccree - avoid implicit enum conversion · 30ca1af4
      Nathan Chancellor 提交于
      [ Upstream commit 18e732b8035d175181aae2ded127994cb01694f7 ]
      
      Clang warns when one enumerated type is implicitly converted to another
      and this happens in several locations in this driver, ultimately related
      to the set_cipher_{mode,config0} functions. set_cipher_mode expects a mode
      of type drv_cipher_mode and set_cipher_config0 expects a mode of type
      drv_crypto_direction.
      
      drivers/crypto/ccree/cc_ivgen.c:58:35: warning: implicit conversion from
      enumeration type 'enum cc_desc_direction' to different enumeration type
      'enum drv_crypto_direction' [-Wenum-conversion]
              set_cipher_config0(&iv_seq[idx], DESC_DIRECTION_ENCRYPT_ENCRYPT);
      
      drivers/crypto/ccree/cc_hash.c:99:28: warning: implicit conversion from
      enumeration type 'enum cc_hash_conf_pad' to different enumeration type
      'enum drv_crypto_direction' [-Wenum-conversion]
                      set_cipher_config0(desc, HASH_DIGEST_RESULT_LITTLE_ENDIAN);
      
      drivers/crypto/ccree/cc_aead.c:1643:30: warning: implicit conversion
      from enumeration type 'enum drv_hash_hw_mode' to different enumeration
      type 'enum drv_cipher_mode' [-Wenum-conversion]
              set_cipher_mode(&desc[idx], DRV_HASH_HW_GHASH);
      
      Since this fundamentally isn't a problem because these values just
      represent simple integers for a shift operation, make it clear to Clang
      that this is okay by making the mode parameter in both functions an int.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/46Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Acked-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      30ca1af4