linux-2.6-microblaze.git
3 years agoMerge tag 'for-5.10-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
Linus Torvalds [Fri, 27 Nov 2020 20:42:13 +0000 (12:42 -0800)]
Merge tag 'for-5.10-rc5-tag' of git://git./linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
 "A few fixes for various warnings that accumulated over past two weeks:

   - tree-checker: add missing return values for some errors

   - lockdep fixes
      - when reading qgroup config and starting quota rescan
      - reverse order of quota ioctl lock and VFS freeze lock

   - avoid accessing potentially stale fs info during device scan,
     reported by syzbot

   - add scope NOFS protection around qgroup relation changes

   - check for running transaction before flushing qgroups

   - fix tracking of new delalloc ranges for some cases"

* tag 'for-5.10-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix lockdep splat when enabling and disabling qgroups
  btrfs: do nofs allocations when adding and removing qgroup relations
  btrfs: fix lockdep splat when reading qgroup config on mount
  btrfs: tree-checker: add missing returns after data_ref alignment checks
  btrfs: don't access possibly stale fs_info data for printing duplicate device
  btrfs: tree-checker: add missing return after error in root_item
  btrfs: qgroup: don't commit transaction when we already hold the handle
  btrfs: fix missing delalloc new bit for new delalloc ranges

3 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Linus Torvalds [Fri, 27 Nov 2020 20:31:04 +0000 (12:31 -0800)]
Merge tag 'for-linus' of git://git./linux/kernel/git/rdma/rdma

Pull rdma fixes from Jason Gunthorpe:
 "Two security issues and several small bug fixes. Things seem to have
  stabilized for this release here.

  Summary:

   - Significant out of bounds access security issue in i40iw

   - Fix misuse of mmu notifiers in hfi1

   - Several errors in the register map/usage in hns

   - Missing error returns in mthca"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
  RDMA/hns: Bugfix for memory window mtpt configuration
  RDMA/hns: Fix retry_cnt and rnr_cnt when querying QP
  RDMA/hns: Fix wrong field of SRQ number the device supports
  IB/hfi1: Ensure correct mm is used at all times
  RDMA/i40iw: Address an mmap handler exploit in i40iw
  IB/mthca: fix return value of error branch in mthca_init_cq()

3 years agoMerge tag 'mtd/fixes-for-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Fri, 27 Nov 2020 20:03:07 +0000 (12:03 -0800)]
Merge tag 'mtd/fixes-for-5.10-rc6' of git://git./linux/kernel/git/mtd/linux

Pull mtd fixes from Miquel Raynal:
 "Because of a recent change in the core, NAND controller drivers
  initializing the ECC engine too early in the probe path are broken.

  Drivers should wait for the NAND device to be discovered and its
  memory layout known before doing any ECC related initialization, so
  instead of reverting the faulty change which is actually moving in the
  right direction, let's fix the drivers directly: socrates, sharpsl,
  r852, plat_nand, pasemi, tmio, txx9ndfmc, orion, mpc5121, lpc32xx_slc,
  lpc32xx_mlc, fsmc, diskonchip, davinci, cs553x, au1550, ams-delta,
  xway and gpio"

* tag 'mtd/fixes-for-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
  mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: sharpsl: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: r852: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: pasemi: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: tmio: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: txx9ndfmc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: orion: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: mpc5121: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: lpc32xx_slc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: lpc32xx_mlc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: fsmc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: diskonchip: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: davinci: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: cs553x: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()

3 years agoMerge tag 'spi-fix-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brooni...
Linus Torvalds [Fri, 27 Nov 2020 19:29:53 +0000 (11:29 -0800)]
Merge tag 'spi-fix-v5.10-rc5' of git://git./linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "A few fixes for v5.10,  one for the core which fixes some potential
  races for controllers with multiple chip selects when configuration of
  the chip select for one client device races with the addition and
  initial setup of an additional client"

* tag 'spi-fix-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: dw: Fix spi registration for controllers overriding CS
  spi: imx: fix the unbalanced spi runtime pm management
  spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
  spi: Take the SPI IO-mutex in the spi_setup() method

3 years agoMerge tag 'media/v5.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
Linus Torvalds [Fri, 27 Nov 2020 19:25:23 +0000 (11:25 -0800)]
Merge tag 'media/v5.10-3' of git://git./linux/kernel/git/mchehab/linux-media

Pull virtual digital TV driver fixes from Mauro Carvalho Chehab:
 "A series of fixes for the new virtual digital TV driver (vidtv), which
  is meant to help doing tests with the digital TV core and media
  userspace apps and libraries.

  They cover a series of issues I found on it, together with a few new
  things in order to make it easier to detect problems at the DVB core"

* tag 'media/v5.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (36 commits)
  media: vidtv.rst: add kernel-doc markups
  media: vidtv.rst: update vidtv documentation
  media: vidtv: simplify EIT write function
  media: vidtv: simplify NIT write function
  media: vidtv: simplify SDT write function
  media: vidtv: cleanup PMT write table function
  media: vidtv: cleanup PAT write function
  media: vidtv: cleanup PSI table header function
  media: vidtv: cleanup PSI descriptor write function
  media: vidtv: simplify the crc writing logic
  media: vidtv: simplify PSI write function
  media: vidtv: add date to the current event
  media: vidtv: fix service_id at SDT table
  media: vidtv: fix service type
  media: vidtv: add a PID entry for the NIT table
  media: vidtv: properly fill EIT service_id
  media: vidtv: fix the network ID range
  media: vidtv: improve EIT data
  media: vidtv: cleanup null packet initialization logic
  media: vidtv: pre-initialize mux arrays
  ...

3 years agoMerge tag 'drm-fixes-2020-11-27-1' of git://anongit.freedesktop.org/drm/drm
Linus Torvalds [Fri, 27 Nov 2020 19:19:49 +0000 (11:19 -0800)]
Merge tag 'drm-fixes-2020-11-27-1' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Dave Airlie:
 "Unfortunately this has a bit of thanksgiving stuffing in it, as it a
  bit larger (at least the vc4 patches) than I like at this point in
  time.

  The main thing is it has a bunch of regressions fixes for reports in
  the last couple of weeks, ast, nouveau and the amdgpu ttm init fix,
  along with the usual selection of amdgpu and i915 fixes.

  The vc4 fixes are a few but they are fixes and the nastiest one is a
  fix for when you have a 2.4Ghz Wifi and a HDMI signal with a clock in
  that range and there isn't enough shielding and interference happen
  between the two, the fix adjusts the mode clock to try and avoid the
  wifi channels in that case.

  Hopefully you can merge this between turkey slices, and next week
  should be quieter.

  ast:
   - LUT loading regression fix

  nouveau:
   - relocations regression fix

  amdgpu:
   - ttm init oops fix
   - Runtime pm fix
   - SI UVD suspend/resume fix
   - HDCP fix for headless cards
   - Sienna Cichlid golden register update

  i915:
   - Fix Perf/OA workaround register corruption (Lionel)
   - Correct a comment statement in GVT (Yan)
   - Fix GT enable/disable iterrupts, including a race condition that
     prevented GPU to go idle (Chris)
   - Free stale request on destroying the virtual engine (Chris)

  exynos:
   - config dependency fix

  mediatek:
   - unused var removal
   - horizonal front/back porch formula fix

  vc4:
   - wifi and hdmi interference fix
   - mode rejection fixes
   - use after free fix
   - cleanup some code"

* tag 'drm-fixes-2020-11-27-1' of git://anongit.freedesktop.org/drm/drm: (28 commits)
  drm/nouveau: fix relocations applying logic and a double-free
  drm/ast: Reload gamma LUT after changing primary plane's color format
  drm/amdgpu: Fix size calculation when init onchip memory
  drm/amdgpu: update golden setting for sienna_cichlid
  drm/amd/display: Avoid HDCP initialization in devices without output
  drm/i915/gt: Free stale request on destroying the virtual engine
  drm/i915/gt: Don't cancel the interrupt shadow too early
  drm/i915/gt: Track signaled breadcrumbs outside of the breadcrumb spinlock
  drm/amdgpu: fix a page fault
  drm/amdgpu: fix SI UVD firmware validate resume fail
  drm/amd/amdgpu: fix null pointer in runtime pm
  drm/i915/gt: Defer enabling the breadcrumb interrupt to after submission
  drm/i915/gvt: correct a false comment of flag F_UNALIGN
  drm/i915/perf: workaround register corruption in OATAILPTR
  drm/vc4: kms: Don't disable the muxing of an active CRTC
  drm/vc4: kms: Store the unassigned channel list in the state
  drm/exynos: depend on COMMON_CLK to fix compile tests
  drm/mediatek: dsi: Modify horizontal front/back porch byte formula
  drm/vc4: hdmi: Disable Wifi Frequencies
  dt-bindings: display: Add a property to deal with WiFi coexistence
  ...

3 years agoMerge tag 'platform-drivers-x86-v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 27 Nov 2020 19:09:13 +0000 (11:09 -0800)]
Merge tag 'platform-drivers-x86-v5.10-2' of git://git./linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:

 - thinkpad_acpi fixes: two bug-fixes and three model specific quirks

 - fixes for misc other drivers: two bug-fixes and three model specific
   quirks

* tag 'platform-drivers-x86-v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: touchscreen_dmi: Add info for the Irbis TW118 tablet
  platform/x86: touchscreen_dmi: Add info for the Predia Basic tablet
  platform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13 x360 PC
  platform/x86: toshiba_acpi: Fix the wrong variable assignment
  platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE
  platform/x86: thinkpad_acpi: Whitelist P15 firmware for dual fan control
  platform/x86: thinkpad_acpi: Send tablet mode switch at wakeup time
  platform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for Thinkpad Yoga 11e 4th gen
  platform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e
  platform/x86: thinkpad_acpi: add P1 gen3 second fan support

3 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Fri, 27 Nov 2020 19:04:13 +0000 (11:04 -0800)]
Merge tag 'for-linus' of git://git./virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
 "ARM:
   - Fix alignment of the new HYP sections
   - Fix GICR_TYPER access from userspace

  S390:
   - do not reset the global diag318 data for per-cpu reset
   - do not mark memory as protected too early
   - fix for destroy page ultravisor call

  x86:
   - fix for SEV debugging
   - fix incorrect return code
   - fix for 'noapic' with PIC in userspace and LAPIC in kernel
   - fix for 5-level paging"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  kvm: x86/mmu: Fix get_mmio_spte() on CPUs supporting 5-level PT
  KVM: x86: Fix split-irqchip vs interrupt injection window request
  KVM: x86: handle !lapic_in_kernel case in kvm_cpu_*_extint
  MAINTAINERS: Update email address for Sean Christopherson
  MAINTAINERS: add uv.c also to KVM/s390
  s390/uv: handle destroy page legacy interface
  KVM: arm64: vgic-v3: Drop the reporting of GICR_TYPER.Last for userspace
  KVM: SVM: fix error return code in svm_create_vcpu()
  KVM: SVM: Fix offset computation bug in __sev_dbg_decrypt().
  KVM: arm64: Correctly align nVHE percpu data
  KVM: s390: remove diag318 reset code
  KVM: s390: pv: Mark mm as protected after the set secure parameters and improve cleanup

3 years agoMerge tag 'powerpc-5.10-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Fri, 27 Nov 2020 18:59:02 +0000 (10:59 -0800)]
Merge tag 'powerpc-5.10-4' of git://git./linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
 "Some more powerpc fixes for 5.10:

   - regression fix for a boot failure on some 32-bit machines.

   - fix for host crashes in the KVM system reset handling.

   - fix for a possible oops in the KVM XIVE interrupt handling on
     Power9.

   - fix for host crashes triggerable via the KVM emulated MMIO handling
     when running HPT guests.

   - a couple of small build fixes.

  Thanks to Andreas Schwab, Cédric Le Goater, Christophe Leroy, Erhard
  Furtner, Greg Kurz, Greg Kurz, Németh Márton, Nicholas Piggin, Nick
  Desaulniers, Serge Belyshev, and Stephen Rothwell"

* tag 'powerpc-5.10-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/64s: Fix allnoconfig build since uaccess flush
  powerpc/64s/exception: KVM Fix for host DSI being taken in HPT guest MMU context
  powerpc: Drop -me200 addition to build flags
  KVM: PPC: Book3S HV: XIVE: Fix possible oops when accessing ESB page
  powerpc/64s: Fix KVM system reset handling when CONFIG_PPC_PSERIES=y
  powerpc/32s: Use relocation offset when setting early hash table

3 years agoMerge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Linus Torvalds [Fri, 27 Nov 2020 18:44:59 +0000 (10:44 -0800)]
Merge tag 'arm64-fixes' of git://git./linux/kernel/git/arm64/linux

Pull arm64 fixes from Will Deacon:
 "The main changes are relating to our handling of access/dirty bits,
  where our low-level page-table helpers could lead to stale young
  mappings and loss of the dirty bit in some cases (the latter has not
  been observed in practice, but could happen when clearing "soft-dirty"
  if we enabled that). These were posted as part of a larger series, but
  the rest of that is less urgent and needs a v2 which I'll get to
  shortly.

  In other news, we've now got a set of fixes to resolve the
  lockdep/tracing problems that have been plaguing us for a while, but
  they're still a bit "fresh" and I plan to send them to you next week
  after we've got some more confidence in them (although initial CI
  results look good).

  Summary:

   - Fix kerneldoc warnings generated by ACPI IORT code

   - Fix pte_accessible() so that access flag is ignored

   - Fix missing header #include

   - Fix loss of software dirty bit across pte_wrprotect() when HW DBM
     is enabled"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64: pgtable: Ensure dirty bit is preserved across pte_wrprotect()
  arm64: pgtable: Fix pte_accessible()
  ACPI/IORT: Fix doc warnings in iort.c
  arm64/fpsimd: add <asm/insn.h> to <asm/kprobes.h> to fix fpsimd build

3 years agoMerge tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Linus Torvalds [Fri, 27 Nov 2020 18:41:19 +0000 (10:41 -0800)]
Merge tag 'iommu-fixes' of git://git./linux/kernel/git/arm64/linux

Pull iommu fixes from Will Deacon:
 "Here's another round of IOMMU fixes for -rc6 consisting mainly of a
  bunch of independent driver fixes. Thomas agreed for me to take the
  x86 'tboot' fix here, as it fixes a regression introduced by a vt-d
  change.

   - Fix intel iommu driver when running on devices without VCCAP_REG

   - Fix swiotlb and "iommu=pt" interaction under TXT (tboot)

   - Fix missing return value check during device probe()

   - Fix probe ordering for Qualcomm SMMU implementation

   - Ensure page-sized mappings are used for AMD IOMMU buffers with SNP
     RMP"

* tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  iommu/vt-d: Don't read VCCAP register unless it exists
  x86/tboot: Don't disable swiotlb when iommu is forced on
  iommu: Check return of __iommu_attach_device()
  arm-smmu-qcom: Ensure the qcom_scm driver has finished probing
  iommu/amd: Enforce 4k mapping for certain IOMMU data structures

3 years agoMerge tag 'printk-for-5.10-rc6-fixup' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 27 Nov 2020 18:38:36 +0000 (10:38 -0800)]
Merge tag 'printk-for-5.10-rc6-fixup' of git://git./linux/kernel/git/printk/linux

Pull printk fixes from Petr Mladek:

 - do not lose trailing newline in pr_cont() calls

 - two trivial fixes for a dead store and a config description

* tag 'printk-for-5.10-rc6-fixup' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
  printk: finalize records with trailing newlines
  printk: remove unneeded dead-store assignment
  init/Kconfig: Fix CPU number in LOG_CPU_MAX_BUF_SHIFT description

3 years agoMerge tag 'writeback_for_v5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 27 Nov 2020 18:36:38 +0000 (10:36 -0800)]
Merge tag 'writeback_for_v5.10-rc6' of git://git./linux/kernel/git/jack/linux-fs

Pull writeback fix from Jan Kara:
 "A fix of possible missing string termination in writeback tracepoints"

* tag 'writeback_for_v5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  trace: fix potenial dangerous pointer

3 years agokvm: x86/mmu: Fix get_mmio_spte() on CPUs supporting 5-level PT
Vitaly Kuznetsov [Thu, 26 Nov 2020 11:02:06 +0000 (12:02 +0100)]
kvm: x86/mmu: Fix get_mmio_spte() on CPUs supporting 5-level PT

Commit 95fb5b0258b7 ("kvm: x86/mmu: Support MMIO in the TDP MMU") caused
the following WARNING on an Intel Ice Lake CPU:

 get_mmio_spte: detect reserved bits on spte, addr 0xb80a0, dump hierarchy:
 ------ spte 0xb80a0 level 5.
 ------ spte 0xfcd210107 level 4.
 ------ spte 0x1004c40107 level 3.
 ------ spte 0x1004c41107 level 2.
 ------ spte 0x1db00000000b83b6 level 1.
 WARNING: CPU: 109 PID: 10254 at arch/x86/kvm/mmu/mmu.c:3569 kvm_mmu_page_fault.cold.150+0x54/0x22f [kvm]
...
 Call Trace:
  ? kvm_io_bus_get_first_dev+0x55/0x110 [kvm]
  vcpu_enter_guest+0xaa1/0x16a0 [kvm]
  ? vmx_get_cs_db_l_bits+0x17/0x30 [kvm_intel]
  ? skip_emulated_instruction+0xaa/0x150 [kvm_intel]
  kvm_arch_vcpu_ioctl_run+0xca/0x520 [kvm]

The guest triggering this crashes. Note, this happens with the traditional
MMU and EPT enabled, not with the newly introduced TDP MMU. Turns out,
there was a subtle change in the above mentioned commit. Previously,
walk_shadow_page_get_mmio_spte() was setting 'root' to 'iterator.level'
which is returned by shadow_walk_init() and this equals to
'vcpu->arch.mmu->shadow_root_level'. Now, get_mmio_spte() sets it to
'int root = vcpu->arch.mmu->root_level'.

The difference between 'root_level' and 'shadow_root_level' on CPUs
supporting 5-level page tables is that in some case we don't want to
use 5-level, in particular when 'cpuid_maxphyaddr(vcpu) <= 48'
kvm_mmu_get_tdp_level() returns '4'. In case upper layer is not used,
the corresponding SPTE will fail '__is_rsvd_bits_set()' check.

Revert to using 'shadow_root_level'.

Fixes: 95fb5b0258b7 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20201126110206.2118959-1-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
3 years agoKVM: x86: Fix split-irqchip vs interrupt injection window request
Paolo Bonzini [Fri, 27 Nov 2020 08:18:20 +0000 (09:18 +0100)]
KVM: x86: Fix split-irqchip vs interrupt injection window request

kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are
a hodge-podge of conditions, hacked together to get something that
more or less works.  But what is actually needed is much simpler;
in both cases the fundamental question is, do we have a place to stash
an interrupt if userspace does KVM_INTERRUPT?

In userspace irqchip mode, that is !vcpu->arch.interrupt.injected.
Currently kvm_event_needs_reinjection(vcpu) covers it, but it is
unnecessarily restrictive.

In split irqchip mode it's a bit more complicated, we need to check
kvm_apic_accept_pic_intr(vcpu) (the IRQ window exit is basically an INTACK
cycle and thus requires ExtINTs not to be masked) as well as
!pending_userspace_extint(vcpu).  However, there is no need to
check kvm_event_needs_reinjection(vcpu), since split irqchip keeps
pending ExtINT state separate from event injection state, and checking
kvm_cpu_has_interrupt(vcpu) is wrong too since ExtINT has higher
priority than APIC interrupts.  In fact the latter fixes a bug:
when userspace requests an IRQ window vmexit, an interrupt in the
local APIC can cause kvm_cpu_has_interrupt() to be true and thus
kvm_vcpu_ready_for_interrupt_injection() to return false.  When this
happens, vcpu_run does not exit to userspace but the interrupt window
vmexits keep occurring.  The VM loops without any hope of making progress.

Once we try to fix these with something like

     return kvm_arch_interrupt_allowed(vcpu) &&
-        !kvm_cpu_has_interrupt(vcpu) &&
-        !kvm_event_needs_reinjection(vcpu) &&
-        kvm_cpu_accept_dm_intr(vcpu);
+        (!lapic_in_kernel(vcpu)
+         ? !vcpu->arch.interrupt.injected
+         : (kvm_apic_accept_pic_intr(vcpu)
+            && !pending_userspace_extint(v)));

we realize two things.  First, thanks to the previous patch the complex
conditional can reuse !kvm_cpu_has_extint(vcpu).  Second, the interrupt
window request in vcpu_enter_guest()

        bool req_int_win =
                dm_request_for_irq_injection(vcpu) &&
                kvm_cpu_accept_dm_intr(vcpu);

should be kept in sync with kvm_vcpu_ready_for_interrupt_injection():
it is unnecessary to ask the processor for an interrupt window
if we would not be able to return to userspace.  Therefore,
kvm_cpu_accept_dm_intr(vcpu) is basically !kvm_cpu_has_extint(vcpu)
ANDed with the existing check for masked ExtINT.  It all makes sense:

- we can accept an interrupt from userspace if there is a place
  to stash it (and, for irqchip split, ExtINTs are not masked).
  Interrupts from userspace _can_ be accepted even if right now
  EFLAGS.IF=0.

- in order to tell userspace we will inject its interrupt ("IRQ
  window open" i.e. kvm_vcpu_ready_for_interrupt_injection), both
  KVM and the vCPU need to be ready to accept the interrupt.

... and this is what the patch implements.

Reported-by: David Woodhouse <dwmw@amazon.co.uk>
Analyzed-by: David Woodhouse <dwmw@amazon.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Nikos Tsironis <ntsironis@arrikto.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Tested-by: David Woodhouse <dwmw@amazon.co.uk>
3 years agoKVM: x86: handle !lapic_in_kernel case in kvm_cpu_*_extint
Paolo Bonzini [Fri, 27 Nov 2020 07:53:52 +0000 (08:53 +0100)]
KVM: x86: handle !lapic_in_kernel case in kvm_cpu_*_extint

Centralize handling of interrupts from the userspace APIC
in kvm_cpu_has_extint and kvm_cpu_get_extint, since
userspace APIC interrupts are handled more or less the
same as ExtINTs are with split irqchip.  This removes
duplicated code from kvm_cpu_has_injectable_intr and
kvm_cpu_has_interrupt, and makes the code more similar
between kvm_cpu_has_{extint,interrupt} on one side
and kvm_cpu_get_{extint,interrupt} on the other.

Cc: stable@vger.kernel.org
Reviewed-by: Filippo Sironi <sironi@amazon.de>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Tested-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
3 years agoMerge tag 'kvmarm-fixes-5.10-4' of git://git.kernel.org/pub/scm/linux/kernel/git...
Paolo Bonzini [Fri, 27 Nov 2020 14:17:13 +0000 (09:17 -0500)]
Merge tag 'kvmarm-fixes-5.10-4' of git://git./linux/kernel/git/kvmarm/kvmarm into kvm-master

KVM/arm64 fixes for v5.10, take #4

- Fix alignment of the new HYP sections
- Fix GICR_TYPER access from userspace

3 years agoMerge branch 'for-5.10-pr_cont-fixup' into for-linus
Petr Mladek [Fri, 27 Nov 2020 12:41:23 +0000 (13:41 +0100)]
Merge branch 'for-5.10-pr_cont-fixup' into for-linus

3 years agoprintk: finalize records with trailing newlines
John Ogness [Thu, 26 Nov 2020 11:48:36 +0000 (12:54 +0106)]
printk: finalize records with trailing newlines

Any record with a trailing newline (LOG_NEWLINE flag) cannot
be continued because the newline has been stripped and will
not be visible if the message is appended. This was already
handled correctly when committing in log_output() but was
not handled correctly when committing in log_store().

Fixes: f5f022e53b87 ("printk: reimplement log_cont using record extension")
Link: https://lore.kernel.org/r/20201126114836.14750-1-john.ogness@linutronix.de
Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Tested-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
3 years agoMerge tag 'drm-misc-fixes-2020-11-26' of ssh://git.freedesktop.org/git/drm/drm-misc...
Dave Airlie [Thu, 26 Nov 2020 23:39:39 +0000 (09:39 +1000)]
Merge tag 'drm-misc-fixes-2020-11-26' of ssh://git.freedesktop.org/git/drm/drm-misc into drm-fixes

A bunch of fixes for vc4 fixing some coexistence issue between wifi and
HDMI, unsupported modes, and vblank timeouts, a fix for ast to reload
the gamma LUT after changing the plane format and a double-free fix for
nouveau

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20201126085450.r3i7wvj7pizsa4l6@gilmour
3 years agoMerge tag 'mediatek-drm-fixes-5.10' of https://git.kernel.org/pub/scm/linux/kernel...
Dave Airlie [Thu, 26 Nov 2020 23:37:01 +0000 (09:37 +1000)]
Merge tag 'mediatek-drm-fixes-5.10' of https://git./linux/kernel/git/chunkuang.hu/linux into drm-fixes

Mediatek DRM Fixes for Linux 5.10

1. Remove unused variable.
2. Modify horizontal front/back porch byte formula.

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20201123234131.387-1-chunkuang.hu@kernel.org
3 years agoMerge tag 'exynos-drm-fixes-for-v5.10-rc6' of git://git.kernel.org/pub/scm/linux...
Dave Airlie [Thu, 26 Nov 2020 23:21:10 +0000 (09:21 +1000)]
Merge tag 'exynos-drm-fixes-for-v5.10-rc6' of git://git./linux/kernel/git/daeinki/drm-exynos into drm-fixes

One bug fix
. Add COMMON_CLK dependency to fix a build error below,
/usr/bin/mips-linux-gnu-ld: drivers/gpu/drm/exynos/exynos_mixer.o: in function `mixer_bind':
exynos_mixer.c:(.text+0x958): undefined reference to `clk_set_parent'

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Inki Dae <inki.dae@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1606184478-23384-1-git-send-email-inki.dae@samsung.com
3 years agoMerge tag 'pm-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Linus Torvalds [Thu, 26 Nov 2020 19:17:37 +0000 (11:17 -0800)]
Merge tag 'pm-5.10-rc6' of git://git./linux/kernel/git/rafael/linux-pm

Pull power management fix from Rafael Wysocki:
 "Fix a recently introduced build issue in the cpufreq SCMI driver
  (Sudeep Holla)"

* tag 'pm-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpufreq: scmi: Fix build for !CONFIG_COMMON_CLK

3 years agomm: memcg: relayout structure mem_cgroup to avoid cache interference
Feng Tang [Wed, 25 Nov 2020 05:22:21 +0000 (13:22 +0800)]
mm: memcg: relayout structure mem_cgroup to avoid cache interference

0day reported one -22.7% regression for will-it-scale page_fault2
case [1] on a 4 sockets 144 CPU platform, and bisected to it to be
caused by Waiman's optimization (commit bd0b230fe1) of saving one
'struct page_counter' space for 'struct mem_cgroup'.

Initially we thought it was due to the cache alignment change introduced
by the patch, but further debug shows that it is due to some hot data
members ('vmstats_local', 'vmstats_percpu', 'vmstats') sit in 2 adjacent
cacheline (2N and 2N+1 cacheline), and when adjacent cache line prefetch
is enabled, it triggers an "extended level" of cache false sharing for
2 adjacent cache lines.

So exchange the 2 member blocks, while keeping mostly the original
cache alignment, which can restore and even enhance the performance,
and save 64 bytes of space for 'struct mem_cgroup' (from 2880 to 2816,
with 0day's default RHEL-8.3 kernel config)

[1]. https://lore.kernel.org/lkml/20201102091543.GM31092@shao2-debian/

Fixes: bd0b230fe145 ("mm/memcg: unify swap and memsw page counters")
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agoRDMA/hns: Bugfix for memory window mtpt configuration
Yixian Liu [Thu, 26 Nov 2020 10:26:12 +0000 (18:26 +0800)]
RDMA/hns: Bugfix for memory window mtpt configuration

When a memory window is bound to a memory region, the local write access
should be set for its mtpt table.

Fixes: c7c28191408b ("RDMA/hns: Add MW support for hip08")
Link: https://lore.kernel.org/r/1606386372-21094-1-git-send-email-liweihang@huawei.com
Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
3 years agoRDMA/hns: Fix retry_cnt and rnr_cnt when querying QP
Wenpeng Liang [Thu, 26 Nov 2020 09:29:37 +0000 (17:29 +0800)]
RDMA/hns: Fix retry_cnt and rnr_cnt when querying QP

The maximum number of retransmission should be returned when querying QP,
not the value of retransmission counter.

Fixes: 99fcf82521d9 ("RDMA/hns: Fix the wrong value of rnr_retry when querying qp")
Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC")
Link: https://lore.kernel.org/r/1606382977-21431-1-git-send-email-liweihang@huawei.com
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
3 years agoRDMA/hns: Fix wrong field of SRQ number the device supports
Wenpeng Liang [Thu, 26 Nov 2020 09:26:52 +0000 (17:26 +0800)]
RDMA/hns: Fix wrong field of SRQ number the device supports

The SRQ capacity is got from the firmware, whose field should be ended at
bit 19.

Fixes: ba6bb7e97421 ("RDMA/hns: Add interfaces to get pf capabilities from firmware")
Link: https://lore.kernel.org/r/1606382812-23636-1-git-send-email-liweihang@huawei.com
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
3 years agoiommu/vt-d: Don't read VCCAP register unless it exists
David Woodhouse [Thu, 26 Nov 2020 11:13:51 +0000 (11:13 +0000)]
iommu/vt-d: Don't read VCCAP register unless it exists

My virtual IOMMU implementation is whining that the guest is reading a
register that doesn't exist. Only read the VCCAP_REG if the corresponding
capability is set in ECAP_REG to indicate that it actually exists.

Fixes: 3375303e8287 ("iommu/vt-d: Add custom allocator for IOASID")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Liu Yi L <yi.l.liu@intel.com>
Cc: stable@vger.kernel.org # v5.7+
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/de32b150ffaa752e0cff8571b17dfb1213fbe71c.camel@infradead.org
Signed-off-by: Will Deacon <will@kernel.org>
3 years agoplatform/x86: touchscreen_dmi: Add info for the Irbis TW118 tablet
Hans de Goede [Tue, 24 Nov 2020 11:04:54 +0000 (12:04 +0100)]
platform/x86: touchscreen_dmi: Add info for the Irbis TW118 tablet

Add touchscreen info for the Irbis TW118 tablet.

Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20201124110454.114286-1-hdegoede@redhat.com
3 years agoplatform/x86: touchscreen_dmi: Add info for the Predia Basic tablet
Hans de Goede [Thu, 15 Oct 2020 19:49:49 +0000 (21:49 +0200)]
platform/x86: touchscreen_dmi: Add info for the Predia Basic tablet

Add touchscreen info for the Predia Basic tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201015194949.50566-1-hdegoede@redhat.com
3 years agoplatform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13 x360 PC
Max Verevkin [Tue, 24 Nov 2020 13:16:52 +0000 (15:16 +0200)]
platform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13 x360 PC

The Pavilion 13 x360 PC has a chassis-type which does not indicate it is
a convertible, while it is actually a convertible. Add it to the
dmi_switches_allow_list.

Signed-off-by: Max Verevkin <me@maxverevkin.tk>
Link: https://lore.kernel.org/r/20201124131652.11165-1-me@maxverevkin.tk
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoplatform/x86: toshiba_acpi: Fix the wrong variable assignment
Kaixu Xia [Sun, 22 Nov 2020 05:49:37 +0000 (13:49 +0800)]
platform/x86: toshiba_acpi: Fix the wrong variable assignment

The commit 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up
variable declaration") cleans up variable declaration in
video_proc_write(). Seems it does the variable assignment in the
wrong place, this results in dead code and changes the source code
logic. Fix it by doing the assignment at the beginning of the funciton.

Fixes: 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up variable declaration")
Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Link: https://lore.kernel.org/r/1606024177-16481-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoplatform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIG...
Timo Witte [Tue, 4 Aug 2020 00:14:23 +0000 (02:14 +0200)]
platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE

Got a dmesg message on my AMD Renoir based Acer laptop:
"acer_wmi: Unknown key number - 0x84" when toggling keyboard
background light

Signed-off-by: Timo Witte <timo.witte@gmail.com>
Reviewed-by: "Lee, Chun-Yi" <jlee@suse.com>
Link: https://lore.kernel.org/r/20200804001423.36778-1-timo.witte@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoplatform/x86: thinkpad_acpi: Whitelist P15 firmware for dual fan control
Matthias Maier [Thu, 26 Nov 2020 00:04:16 +0000 (18:04 -0600)]
platform/x86: thinkpad_acpi: Whitelist P15 firmware for dual fan control

This commit enables dual fan control for the following new Lenovo
models: P15, P15v.

Signed-off-by: Matthias Maier <tamiko@43-1.org>
Link: https://lore.kernel.org/r/20201126000416.2459645-2-tamiko-ibm-acpi-devel@43-1.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoplatform/x86: thinkpad_acpi: Send tablet mode switch at wakeup time
Benjamin Berg [Mon, 23 Nov 2020 13:21:57 +0000 (14:21 +0100)]
platform/x86: thinkpad_acpi: Send tablet mode switch at wakeup time

The lid state may change while the machine is suspended. As such, we may
need to re-check the state at wake-up time (at least when waking up from
hibernation).
Add the appropriate call to the resume handler in order to sync the
SW_TABLET_MODE switch state with the hardware state.

Fixes: dda3ec0aa631 ("platform/x86: thinkpad_acpi: Implement tablet mode using GMMS method")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=210269
Signed-off-by: Benjamin Berg <bberg@redhat.com>
Acked-by: Henrique de Moraes Holschuh <hnh@hmh.eng.br>
Link: https://lore.kernel.org/r/20201123132157.866303-1-benjamin@sipsolutions.net
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoplatform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for Thinkpad Yoga...
Hans de Goede [Mon, 9 Nov 2020 10:35:50 +0000 (11:35 +0100)]
platform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for Thinkpad Yoga 11e 4th gen

The Thinkpad Yoga 11e 4th gen with the N3450 / Celeron CPU only has
one battery which is named BAT1 instead of the expected BAT0, add a
quirk for this. This fixes not being able to set the charging tresholds
on this model; and this alsoe fixes the following errors in dmesg:

ACPI: \_SB_.PCI0.LPCB.EC__.HKEY: BCTG evaluated but flagged as error
thinkpad_acpi: Error probing battery 2
battery: extension failed to load: ThinkPad Battery Extension
battery: extension unregistered: ThinkPad Battery Extension

Note that the added quirk is for the "R0K" BIOS versions which are
used on the Thinkpad Yoga 11e 4th gen's with a Celeron CPU, there
is a separate "R0L" BIOS for the i3/i5 based versions. This may also
need the same quirk, but if that really is necessary is unknown.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20201109103550.16265-1-hdegoede@redhat.com
3 years agoplatform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e
Hans de Goede [Fri, 6 Nov 2020 14:01:30 +0000 (15:01 +0100)]
platform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e

The Yoga 11e series has 2 accelerometers described by a BOSC0200 ACPI node.
This setup relies on a Windows service which reads both accelerometers and
then calculates the angle between the 2 halves to determine laptop / tent /
tablet mode and then reports the calculated mode back to the EC by calling
special ACPI methods on the BOSC0200 node.

The bmc150 iio driver does not support this (it involves double
calculations requiring sqrt and arccos so this really needs to be done
in userspace), as a result of this on the Yoga 11e the thinkpad_acpi
code always reports SW_TABLET_MODE=0, starting with GNOME 3.38 reporting
SW_TABLET_MODE=0 causes GNOME to:

1. Not show the onscreen keyboard when a text-input field is focussed
   with the touchscreen.
2. Disable accelerometer based auto display-rotation.

This makes sense when in laptop-mode but not when in tablet-mode. But
since for the Yoga 11e the thinkpad_acpi code always reports
SW_TABLET_MODE=0, GNOME does not know when the device is in tablet-mode.

Stop reporting the broken (always 0) SW_TABLET_MODE on Yoga 11e models
to fix this.

Note there are plans for userspace to support 360 degree hinges style
2-in-1s with 2 accelerometers and figure out the mode by itself, see:
https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/issues/216

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20201106140130.46820-1-hdegoede@redhat.com
3 years agoplatform/x86: thinkpad_acpi: add P1 gen3 second fan support
Iakov 'Jake' Kirilenko [Thu, 5 Nov 2020 15:25:56 +0000 (18:25 +0300)]
platform/x86: thinkpad_acpi: add P1 gen3 second fan support

Tested on my P1 gen3, works fine with `thinkfan`. Since thinkpad_acpi fan
control is off by default, it is safe to add 2nd fan control for brave
overclockers

Signed-off-by: Iakov 'Jake' Kirilenko <jake.kirilenko@gmail.com>
Link: https://lore.kernel.org/r/20201105152556.34073-1-jake.kirilenko@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3 years agoMerge tag 'drm-intel-fixes-2020-11-25' of git://anongit.freedesktop.org/drm/drm-intel...
Dave Airlie [Thu, 26 Nov 2020 07:58:04 +0000 (17:58 +1000)]
Merge tag 'drm-intel-fixes-2020-11-25' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes

- Fix Perf/OA workaround register corruption (Lionel)
- Correct a comment statement in GVT (Yan)
- Fix GT enable/disable iterrupts, including a race condition that prevented GPU to go idle (Chris)
- Free stale request on destroying the virtual engine (Chris)

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201126010623.GA827684@intel.com
3 years agoMerge tag 'amd-drm-fixes-5.10-2020-11-25' of git://people.freedesktop.org/~agd5f...
Dave Airlie [Thu, 26 Nov 2020 07:31:47 +0000 (17:31 +1000)]
Merge tag 'amd-drm-fixes-5.10-2020-11-25' of git://people.freedesktop.org/~agd5f/linux into drm-fixes

amd-drm-fixes-5.10-2020-11-25:

amdgpu:
- Runtime pm fix
- SI UVD suspend/resume fix
- HDCP fix for headless cards
- Sienna Cichlid golden register update

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexdeucher@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201125151145.4263-1-alexander.deucher@amd.com
3 years agomedia: vidtv.rst: add kernel-doc markups
Mauro Carvalho Chehab [Tue, 24 Nov 2020 10:27:42 +0000 (11:27 +0100)]
media: vidtv.rst: add kernel-doc markups

Fix existing issues at the kernel-doc markups and add them to
the vidtv.rst file.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv.rst: update vidtv documentation
Mauro Carvalho Chehab [Thu, 19 Nov 2020 11:17:49 +0000 (12:17 +0100)]
media: vidtv.rst: update vidtv documentation

Update the vidtv documentation with the relevant changes
after the last patches.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify EIT write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 09:50:58 +0000 (10:50 +0100)]
media: vidtv: simplify EIT write function

- pass struct vidtv_psi_eit_write_args as a pointer;
- avoid initializing struct fields multiple times.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify NIT write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 09:37:12 +0000 (10:37 +0100)]
media: vidtv: simplify NIT write function

- pass struct vidtv_psi_nit_write_args as a pointer;
- avoid initializing struct fields multiple times.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify SDT write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 09:20:23 +0000 (10:20 +0100)]
media: vidtv: simplify SDT write function

- pass struct vidtv_psi_sdt_write_args as a pointer;
- avoid initializing struct fields multiple times.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup PMT write table function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 08:58:31 +0000 (09:58 +0100)]
media: vidtv: cleanup PMT write table function

- Pass struct vidtv_psi_pmt_write_args as a pointer;
- Avoid initializing structs multiple times.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup PAT write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 08:45:49 +0000 (09:45 +0100)]
media: vidtv: cleanup PAT write function

Avoid initializing the structs multiple times and pass the
PAT struct as a pointer, instead of a var.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup PSI table header function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 08:33:44 +0000 (09:33 +0100)]
media: vidtv: cleanup PSI table header function

- Pass struct header_write_args as a pointer, instead of
  passing as a var;

- Initialize the psi_args struct only once.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup PSI descriptor write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 08:25:00 +0000 (09:25 +0100)]
media: vidtv: cleanup PSI descriptor write function

This function initializes the psi_args twice, and receives
a struct, instead of a pointer to a struct.

Clean it up.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify the crc writing logic
Mauro Carvalho Chehab [Tue, 24 Nov 2020 07:54:58 +0000 (08:54 +0100)]
media: vidtv: simplify the crc writing logic

Cleanup the table_section_crc32_write_into() function
by initializing struct psi_write_args only once and by
passing the args as a pointer.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify PSI write function
Mauro Carvalho Chehab [Tue, 24 Nov 2020 07:42:20 +0000 (08:42 +0100)]
media: vidtv: simplify PSI write function

The function vidtv_psi_ts_psi_write_into() initializes the
ts_header fields several times, and receives a struct
as argument, instead of using a pointer to struct.

Cleanup the function, in order to reduce its stack usage
and to avoid initializing the ts_header multiple times.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: add date to the current event
Mauro Carvalho Chehab [Mon, 23 Nov 2020 15:57:49 +0000 (16:57 +0100)]
media: vidtv: add date to the current event

The current event is using an undefined date. Instead, it
should be the timestamp when the EIT table was generated.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix service_id at SDT table
Mauro Carvalho Chehab [Mon, 23 Nov 2020 17:40:29 +0000 (18:40 +0100)]
media: vidtv: fix service_id at SDT table

The service_id there should be equal to the one used
on other tables, otherwise, EIT entries won't be valid.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix service type
Mauro Carvalho Chehab [Mon, 23 Nov 2020 17:04:14 +0000 (18:04 +0100)]
media: vidtv: fix service type

As the service currently broadcasts just audio, change the
service type to reflect that.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: add a PID entry for the NIT table
Mauro Carvalho Chehab [Mon, 23 Nov 2020 13:16:40 +0000 (14:16 +0100)]
media: vidtv: add a PID entry for the NIT table

On normal TS streams, the NIT table has its own entry at PAT,
but not at PMT.

While here, properly handle alloc problems when creating
PMT entries.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: properly fill EIT service_id
Mauro Carvalho Chehab [Mon, 23 Nov 2020 12:51:31 +0000 (13:51 +0100)]
media: vidtv: properly fill EIT service_id

The EIT header ID field should not contain the network ID, but,
instead, the service_id of the program described at EIT.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix the network ID range
Mauro Carvalho Chehab [Mon, 23 Nov 2020 11:20:45 +0000 (12:20 +0100)]
media: vidtv: fix the network ID range

As defined at ETSI TS 101 162, original network IDs up to 0xfebf
are reserved for registration at dvb.org.

Let's use, instead, an original network ID at the range
0xff00-0xffff, as this is for private temporary usage.

As the same value is also used for the network ID,
the range 0xff01-0xffff also fits better, as values
lower than that depend if the network is used for
satellite, terrestrial, cable of CI.

While here, move the TS ID to the bridge code, where it
is used, and change its value, as it was identical to
the value previously used by network ID. While we could
keep the same value, let's change it, just to make easier
to check for the new code while reading it with DVB tools
like dvbinspector.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: improve EIT data
Mauro Carvalho Chehab [Mon, 23 Nov 2020 10:24:11 +0000 (11:24 +0100)]
media: vidtv: improve EIT data

Place some text at EIT data, and use ISO 8859-15 encoding for
the German letter "ü" (u mit umlat) letter.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup null packet initialization logic
Mauro Carvalho Chehab [Fri, 20 Nov 2020 10:15:24 +0000 (11:15 +0100)]
media: vidtv: cleanup null packet initialization logic

Initialize the destination buffer/size and the initial
offset when creating the local var.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: pre-initialize mux arrays
Mauro Carvalho Chehab [Fri, 20 Nov 2020 09:51:50 +0000 (10:51 +0100)]
media: vidtv: pre-initialize mux arrays

Instead of first zeroing all fields at the mux structs and
then filling, do some initialization for the const data
when they're created.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: remove some unused functions
Mauro Carvalho Chehab [Fri, 20 Nov 2020 08:39:03 +0000 (09:39 +0100)]
media: vidtv: remove some unused functions

Right now, there's no need to access the length of some
tables. So, drop the unused functions.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: do some cleanups at the driver
Mauro Carvalho Chehab [Tue, 22 Sep 2020 14:43:56 +0000 (16:43 +0200)]
media: vidtv: do some cleanups at the driver

Do some cleanups at the coding style of the driver:
- remove "inline" declarations;
- use reverse xmas-tree for local var declarations;
- Adjust some indent to avoid breaking 80-cols;
- Cleanup some comments.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agodrm/nouveau: fix relocations applying logic and a double-free
Matti Hamalainen [Fri, 20 Nov 2020 15:23:38 +0000 (17:23 +0200)]
drm/nouveau: fix relocations applying logic and a double-free

Commit 03e0d26fcf79 ("drm/nouveau: slowpath for pushbuf ioctl") included
a logic-bug which results in the relocations not actually getting
applied at all as the call to nouveau_gem_pushbuf_reloc_apply() is
never reached. This causes a regression with graphical corruption,
triggered when relocations need to be done (for example after a
suspend/resume cycle.)

Fix by setting *apply_relocs value only if there were more than 0
relocations.

Additionally, the never reached code had a leftover u_free() call,
which, after fixing the logic, now got called and resulted in a
double-free. Fix by removing one u_free(), moving the other
and adding check for errors.

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: nouveau@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Matti Hamalainen <ccr@tnsp.org>
Fixes: 03e0d26fcf79 ("drm/nouveau: slowpath for pushbuf ioctl")
References: https://gitlab.freedesktop.org/drm/nouveau/-/issues/11
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20201120152338.1203257-1-ccr@tnsp.org
3 years agomedia: vidtv: avoid copying data for PES structs
Mauro Carvalho Chehab [Tue, 22 Sep 2020 09:01:17 +0000 (11:01 +0200)]
media: vidtv: avoid copying data for PES structs

Minimize the number of data copies and initialization at
the code, passing them as pointers instead of duplicating
the data.

The only case where we're keeping the data copy is at
vidtv_pes_write_h(), as it needs a copy of the passed
arguments. On such case, we're being more explicit.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: avoid data copy when initializing the multiplexer
Mauro Carvalho Chehab [Tue, 22 Sep 2020 08:28:12 +0000 (10:28 +0200)]
media: vidtv: avoid data copy when initializing the multiplexer

Initialize the fields of the arguments directly when
declaring it, and pass the args as a pointer, instead of
copying them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix some notes at the tone generator
Mauro Carvalho Chehab [Thu, 19 Nov 2020 10:20:38 +0000 (11:20 +0100)]
media: vidtv: fix some notes at the tone generator

The sheet music used to generate the tones had a few
polyphonic notes. Due to that, its conversion to a
tones sequence had a few errors.

Also, due to a bug at the tone generator, it was missing
the pause at the initial compass.

Fix them.

While here, reduce the compass to 100bpm.

The music was converted from a Music XML file using
this small script:

<snip>
my $count = 0;
my $silent = 0;
my $note;
my $octave;
print "\t";
while (<>) {
$note = $1 if (m,\<step\>(.*)\</step\>,);
$octave = "_$1" if (m,\<octave\>(.*)\</octave\>,);
if (m,\<alter\>1\</alter\>,) {
$note .= "S";
$sharp = 1;
}
if (m,\<rest/\>,) {
$note = "SILENT";
$silent = 1;
}
if (m,\<duration\>(.*)\</duration\>,) {
printf "{ NOTE_${note}${octave}, %d},", $1 * 128 / 480;
$count++;
if ($silent || $count >= 3) {
print "\n\t";
$count = 0;
$silent = 0;
} else {
print " ";
print " " if (!$sharp);
}
$sharp = 0;
$note = "";
$octave = "";
};
};
print "\n";
</snip>

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix the tone generator logic
Mauro Carvalho Chehab [Thu, 19 Nov 2020 10:20:46 +0000 (11:20 +0100)]
media: vidtv: fix the tone generator logic

The tone generator logic were repeating the song after the
first silent. There's also a wrong logic at the note
offset calculus, which may create some noise.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix the name of the program
Mauro Carvalho Chehab [Thu, 19 Nov 2020 08:41:22 +0000 (09:41 +0100)]
media: vidtv: fix the name of the program

While the original plan was to use the first movement of
the 5th Symphony, it was opted to use the Für Elise song,
instead.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: don't use recursive functions
Mauro Carvalho Chehab [Tue, 17 Nov 2020 16:38:36 +0000 (17:38 +0100)]
media: vidtv: don't use recursive functions

The Linux stack is too short. So, using recursive functions
is a very bad idea. Convert those into non-recursive ones.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: add error checks
Mauro Carvalho Chehab [Mon, 21 Sep 2020 13:11:50 +0000 (15:11 +0200)]
media: vidtv: add error checks

Currently, there are not checks if something gets bad during
memory allocation: it will simply use NULL pointers and
crash.

Add error path at the logic which allocates memory for the
MPEG-TS generator code, propagating the errors up to the
vidtv_bridge. Now, if something wents bad, start_streaming
will return an error that userspace can detect:

ERROR    DMX_SET_PES_FILTER failed (PID = 0x2000): 12 Cannot allocate memory

and the driver doesn't crash.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: reorganize includes
Mauro Carvalho Chehab [Mon, 21 Sep 2020 12:19:08 +0000 (14:19 +0200)]
media: vidtv: reorganize includes

- Place the includes on alphabetical order;
- get rid of asm/byteorder.h;
- add bug.h at vidtv_s302m.c, as it is needed by
  inux/fixp-arith.h

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: psi: fix missing assignments in while loops
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:52 +0000 (16:05 +0100)]
media: vidtv: psi: fix missing assignments in while loops

Some variables were only assigned once but were used in while
loops as if they had been updated at every iteration. Fix this.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: Move s302m specific fields into encoder context
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:51 +0000 (16:05 +0100)]
media: vidtv: Move s302m specific fields into encoder context

A few fields used only by the tone generator in the s302m encoder
are stored in struct vidtv_encoder. Move them into
struct vidtv_s302m_ctx instead. While we are at it: fix a
checkpatch warning for long lines.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: psi: extract descriptor chaining code into a helper
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:50 +0000 (16:05 +0100)]
media: vidtv: psi: extract descriptor chaining code into a helper

The code to append a descriptor to the end of a chain is repeated
throughout the psi generator code. Extract it into its own helper
function to avoid cluttering.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: psi: Implement an Event Information Table (EIT)
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:49 +0000 (16:05 +0100)]
media: vidtv: psi: Implement an Event Information Table (EIT)

Implement an Event Information Table (EIT) as per EN 300 468
5.2.4.

The EIT provides information in chronological order regarding
the events contained within each service.

For now only present event information is supported.

[mchehab+huawei@kernel.org: removed an extra blank line]
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: psi: add a Network Information Table (NIT)
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:48 +0000 (16:05 +0100)]
media: vidtv: psi: add a Network Information Table (NIT)

Add a Network Information Table (NIT) as specified in ETSI EN 300 468.

This table conveys information relating to the physical organization of
the multiplexes carried via a given network and the characteristics of
the network itself.

It is conveyed in the output of vidtv as packets with TS PID of 0x0010

[mchehab+huawei@kernel.org: removed an extra blank line]
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: extract the initial CRC value to into a #define
Daniel W. S. Almeida [Sat, 31 Oct 2020 15:05:47 +0000 (16:05 +0100)]
media: vidtv: extract the initial CRC value to into a #define

The same constant (0xffffffff) is used in three different functions.

Extract it into a #define to avoid repetition.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agoIB/hfi1: Ensure correct mm is used at all times
Dennis Dalessandro [Wed, 25 Nov 2020 21:01:12 +0000 (16:01 -0500)]
IB/hfi1: Ensure correct mm is used at all times

Two earlier bug fixes have created a security problem in the hfi1
driver. One fix aimed to solve an issue where current->mm was not valid
when closing the hfi1 cdev. It attempted to do this by saving a cached
value of the current->mm pointer at file open time. This is a problem if
another process with access to the FD calls in via write() or ioctl() to
pin pages via the hfi driver. The other fix tried to solve a use after
free by taking a reference on the mm.

To fix this correctly we use the existing cached value of the mm in the
mmu notifier. Now we can check in the insert, evict, etc. routines that
current->mm matched what the notifier was registered for. If not, then
don't allow access. The register of the mmu notifier will save the mm
pointer.

Since in do_exit() the exit_mm() is called before exit_files(), which
would call our close routine a reference is needed on the mm. We rely on
the mmgrab done by the registration of the notifier, whereas before it was
explicit. The mmu notifier deregistration happens when the user context is
torn down, the creation of which triggered the registration.

Also of note is we do not do any explicit work to protect the interval
tree notifier. It doesn't seem that this is going to be needed since we
aren't actually doing anything with current->mm. The interval tree
notifier stuff still has a FIXME noted from a previous commit that will be
addressed in a follow on patch.

Cc: <stable@vger.kernel.org>
Fixes: e0cf75deab81 ("IB/hfi1: Fix mm_struct use after free")
Fixes: 3faa3d9a308e ("IB/hfi1: Make use of mm consistent")
Link: https://lore.kernel.org/r/20201125210112.104301.51331.stgit@awfm-01.aw.intel.com
Suggested-by: Jann Horn <jannh@google.com>
Reported-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
3 years agoMerge tag 'media/v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
Linus Torvalds [Wed, 25 Nov 2020 18:35:44 +0000 (10:35 -0800)]
Merge tag 'media/v5.10-2' of git://git./linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:

 - a rand Kconfig fixup for mtk-vcodec

 - a fix at h264 handling at cedrus codec driver

 - some warning fixes when config PM is not enabled at marvell-ccic

 - two fixes at venus codec driver: one related to codec profile and the
   other one related to a bad error path which causes an OOPS on module
   re-bind

* tag 'media/v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: venus: pm_helpers: Fix kernel module reload
  media: venus: venc: Fix setting of profile and level
  media: cedrus: h264: Fix check for presence of scaling matrix
  media: media/platform/marvell-ccic: fix warnings when CONFIG_PM is not enabled
  media: mtk-vcodec: fix build breakage when one of VPU or SCP is enabled
  media: mtk-vcodec: move firmware implementations into their own files

3 years agoRDMA/i40iw: Address an mmap handler exploit in i40iw
Shiraz Saleem [Wed, 25 Nov 2020 00:56:16 +0000 (18:56 -0600)]
RDMA/i40iw: Address an mmap handler exploit in i40iw

i40iw_mmap manipulates the vma->vm_pgoff to differentiate a push page mmap
vs a doorbell mmap, and uses it to compute the pfn in remap_pfn_range
without any validation. This is vulnerable to an mmap exploit as described
in: https://lore.kernel.org/r/20201119093523.7588-1-zhudi21@huawei.com

The push feature is disabled in the driver currently and therefore no push
mmaps are issued from user-space. The feature does not work as expected in
the x722 product.

Remove the push module parameter and all VMA attribute manipulations for
this feature in i40iw_mmap. Update i40iw_mmap to only allow DB user
mmapings at offset = 0. Check vm_pgoff for zero and if the mmaps are bound
to a single page.

Cc: <stable@kernel.org>
Fixes: d37498417947 ("i40iw: add files for iwarp interface")
Link: https://lore.kernel.org/r/20201125005616.1800-2-shiraz.saleem@intel.com
Reported-by: Di Zhu <zhudi21@huawei.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
3 years agospi: dw: Fix spi registration for controllers overriding CS
Lars Povlsen [Fri, 20 Nov 2020 21:34:14 +0000 (22:34 +0100)]
spi: dw: Fix spi registration for controllers overriding CS

When SPI DW memory ops support was introduced, there was a check for
excluding controllers which supplied their own CS function. Even so,
the mem_ops pointer is *always* presented to the SPI core.

This causes the SPI core sanity check in spi_controller_check_ops() to
refuse registration, since a mem_ops pointer is being supplied without
an exec_op member function.

The end result is failure of the SPI DW driver on sparx5 and similar
platforms.

The fix in the core SPI DW driver is to avoid presenting the mem_ops
pointer if the exec_op function is not set.

Fixes: 6423207e57ea (spi: dw: Add memory operations support)
Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Acked-by: Serge Semin <fancer.lancer@gmail.com>
Link: https://lore.kernel.org/r/20201120213414.339701-1-lars.povlsen@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agox86/tboot: Don't disable swiotlb when iommu is forced on
Lu Baolu [Wed, 25 Nov 2020 01:41:24 +0000 (09:41 +0800)]
x86/tboot: Don't disable swiotlb when iommu is forced on

After commit 327d5b2fee91c ("iommu/vt-d: Allow 32bit devices to uses DMA
domain"), swiotlb could also be used for direct memory access if IOMMU
is enabled but a device is configured to pass through the DMA translation.
Keep swiotlb when IOMMU is forced on, otherwise, some devices won't work
if "iommu=pt" kernel parameter is used.

Fixes: 327d5b2fee91 ("iommu/vt-d: Allow 32bit devices to uses DMA domain")
Reported-and-tested-by: Adrian Huang <ahuang12@lenovo.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20201125014124.4070776-1-baolu.lu@linux.intel.com
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=210237
Signed-off-by: Will Deacon <will@kernel.org>
3 years agotrace: fix potenial dangerous pointer
Hui Su [Tue, 24 Nov 2020 16:52:05 +0000 (00:52 +0800)]
trace: fix potenial dangerous pointer

The bdi_dev_name() returns a char [64], and
the __entry->name is a char [32].

It maybe dangerous to TP_printk("%s", __entry->name)
after the strncpy().

CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20201124165205.GA23937@rlk
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Hui Su <sh_def@163.com>
Signed-off-by: Jan Kara <jack@suse.cz>
3 years agodrm/ast: Reload gamma LUT after changing primary plane's color format
Thomas Zimmermann [Tue, 22 Sep 2020 14:46:55 +0000 (16:46 +0200)]
drm/ast: Reload gamma LUT after changing primary plane's color format

The gamma LUT has to be reloaded after changing the primary plane's
color format. This used to be done implicitly by the CRTC atomic_enable()
helper after updating the primary plane. With the recent reordering of
the steps, the primary plane's setup was moved last and invalidated
the gamma LUT. Fix this by setting the LUT from within atomic_flush().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Fixes: 2f0ddd89fe32 ("drm/ast: Enable CRTC before planes")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200922144655.23624-1-tzimmermann@suse.de
(cherry-picked from 8e3784dfef8a03143b13e7e4011f276a954f1bc6)

3 years agodrm/amdgpu: Fix size calculation when init onchip memory
xinhui pan [Fri, 23 Oct 2020 05:41:12 +0000 (13:41 +0800)]
drm/amdgpu: Fix size calculation when init onchip memory

Size is page count here.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1372
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d836917da7e5ca9b33ef4d499972f1feeb519e00)
[airlied: from drm-next]
Signed-off-by: Dave Airlie <airlied@redhat.com>
3 years agoMerge tag '5.10-rc5-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Tue, 24 Nov 2020 23:33:18 +0000 (15:33 -0800)]
Merge tag '5.10-rc5-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "Four smb3 fixes for stable: one fixes a memleak, the other three
  address a problem found with decryption offload that can cause a use
  after free"

* tag '5.10-rc5-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  smb3: Handle error case during offload read path
  smb3: Avoid Mid pending list corruption
  smb3: Call cifs reconnect from demultiplex thread
  cifs: fix a memleak with modefromsid

3 years agomm: fix VM_BUG_ON(PageTail) and BUG_ON(PageWriteback)
Hugh Dickins [Tue, 24 Nov 2020 16:46:43 +0000 (08:46 -0800)]
mm: fix VM_BUG_ON(PageTail) and BUG_ON(PageWriteback)

Twice now, when exercising ext4 looped on shmem huge pages, I have crashed
on the PF_ONLY_HEAD check inside PageWaiters(): ext4_finish_bio() calling
end_page_writeback() calling wake_up_page() on tail of a shmem huge page,
no longer an ext4 page at all.

The problem is that PageWriteback is not accompanied by a page reference
(as the NOTE at the end of test_clear_page_writeback() acknowledges): as
soon as TestClearPageWriteback has been done, that page could be removed
from page cache, freed, and reused for something else by the time that
wake_up_page() is reached.

https://lore.kernel.org/linux-mm/20200827122019.GC14765@casper.infradead.org/
Matthew Wilcox suggested avoiding or weakening the PageWaiters() tail
check; but I'm paranoid about even looking at an unreferenced struct page,
lest its memory might itself have already been reused or hotremoved (and
wake_up_page_bit() may modify that memory with its ClearPageWaiters()).

Then on crashing a second time, realized there's a stronger reason against
that approach.  If my testing just occasionally crashes on that check,
when the page is reused for part of a compound page, wouldn't it be much
more common for the page to get reused as an order-0 page before reaching
wake_up_page()?  And on rare occasions, might that reused page already be
marked PageWriteback by its new user, and already be waited upon?  What
would that look like?

It would look like BUG_ON(PageWriteback) after wait_on_page_writeback()
in write_cache_pages() (though I have never seen that crash myself).

Matthew Wilcox explaining this to himself:
 "page is allocated, added to page cache, dirtied, writeback starts,

  --- thread A ---
  filesystem calls end_page_writeback()
        test_clear_page_writeback()
  --- context switch to thread B ---
  truncate_inode_pages_range() finds the page, it doesn't have writeback set,
  we delete it from the page cache.  Page gets reallocated, dirtied, writeback
  starts again.  Then we call write_cache_pages(), see
  PageWriteback() set, call wait_on_page_writeback()
  --- context switch back to thread A ---
  wake_up_page(page, PG_writeback);
  ... thread B is woken, but because the wakeup was for the old use of
  the page, PageWriteback is still set.

  Devious"

And prior to 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common() logic")
this would have been much less likely: before that, wake_page_function()'s
non-exclusive case would stop walking and not wake if it found Writeback
already set again; whereas now the non-exclusive case proceeds to wake.

I have not thought of a fix that does not add a little overhead: the
simplest fix is for end_page_writeback() to get_page() before calling
test_clear_page_writeback(), then put_page() after wake_up_page().

Was there a chance of missed wakeups before, since a page freed before
reaching wake_up_page() would have PageWaiters cleared?  I think not,
because each waiter does hold a reference on the page.  This bug comes
when the old use of the page, the one we do TestClearPageWriteback on,
had *no* waiters, so no additional page reference beyond the page cache
(and whoever racily freed it).  The reuse of the page has a waiter
holding a reference, and its own PageWriteback set; but the belated
wake_up_page() has woken the reuse to hit that BUG_ON(PageWriteback).

Reported-by: syzbot+3622cea378100f45d59f@syzkaller.appspotmail.com
Reported-by: Qian Cai <cai@lca.pw>
Fixes: 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common() logic")
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: stable@vger.kernel.org # v5.8+
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agoMerge tag 's390-5.10-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Linus Torvalds [Tue, 24 Nov 2020 20:15:44 +0000 (12:15 -0800)]
Merge tag 's390-5.10-5' of git://git./linux/kernel/git/s390/linux

Pull s390 fix from Heiko Carstens:
 "Disable interrupts when restoring fpu and vector registers, otherwise
  KVM guests might see corrupted register contents"

* tag 's390-5.10-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
  s390: fix fpu restore in entry.S

3 years agoMerge tag 'arc-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
Linus Torvalds [Tue, 24 Nov 2020 20:12:55 +0000 (12:12 -0800)]
Merge tag 'arc-5.10-rc6' of git://git./linux/kernel/git/vgupta/arc

Pull ARC fixes from Vineet Gupta:
 "A couple more stack unwinder related fixes:

   - More stack unwinding updates

   - Misc minor fixes"

* tag 'arc-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc:
  ARC: stack unwinding: reorganize how initial register state setup
  ARC: stack unwinding: don't assume non-current task is sleeping
  ARC: mm: fix spelling mistakes
  ARC: bitops: Remove unecessary operation and value

3 years agodrm/amdgpu: update golden setting for sienna_cichlid
Likun Gao [Mon, 23 Nov 2020 02:28:46 +0000 (10:28 +0800)]
drm/amdgpu: update golden setting for sienna_cichlid

Update golden setting for sienna_cichlid.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org # 5.9.x
3 years agodrm/amd/display: Avoid HDCP initialization in devices without output
Rodrigo Siqueira [Tue, 17 Nov 2020 20:25:48 +0000 (15:25 -0500)]
drm/amd/display: Avoid HDCP initialization in devices without output

The HDCP feature requires at least one connector attached to the device;
however, some GPUs do not have a physical output, making the HDCP
initialization irrelevant. This patch disables HDCP initialization when
the graphic card does not have output.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
3 years agodrm/i915/gt: Free stale request on destroying the virtual engine
Chris Wilson [Mon, 23 Nov 2020 11:37:17 +0000 (11:37 +0000)]
drm/i915/gt: Free stale request on destroying the virtual engine

Since preempt-to-busy, we may unsubmit a request while it is still on
the HW and completes asynchronously. That means it may be retired and in
the process destroy the virtual engine (as the user has closed their
context), but that engine may still be holding onto the unsubmitted
compelted request. Therefore we need to potentially cleanup the old
request on destroying the virtual engine. We also have to keep the
virtual_engine alive until after the sibling's execlists_dequeue() have
finished peeking into the virtual engines, for which we serialise with
RCU.

v2: Be paranoid and flush the tasklet as well.
v3: And flush the tasklet before the engines, as the tasklet may
re-attach an rb_node after our removal from the siblings.

Fixes: 6d06779e8672 ("drm/i915: Load balancing across a virtual engine")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201123113717.20500-4-chris@chris-wilson.co.uk
(cherry picked from commit 46eecfccb4c2b0f258adbafb2e53ca3b822cd663)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
3 years agodrm/i915/gt: Don't cancel the interrupt shadow too early
Chris Wilson [Mon, 23 Nov 2020 11:37:16 +0000 (11:37 +0000)]
drm/i915/gt: Don't cancel the interrupt shadow too early

We currently want to keep the interrupt enabled until the interrupt after
which we have no more work to do. This heuristic was broken by us
kicking the irq-work on adding a completed request without attaching a
signaler -- hence it appearing to the irq-worker that an interrupt had
fired when we were idle.

Fixes: 2854d866327a ("drm/i915/gt: Replace intel_engine_transfer_stale_breadcrumbs")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201123113717.20500-3-chris@chris-wilson.co.uk
(cherry picked from commit 3aef910d26ef48b8a79d48b006dc04383b86dd31)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
3 years agodrm/i915/gt: Track signaled breadcrumbs outside of the breadcrumb spinlock
Chris Wilson [Mon, 23 Nov 2020 11:37:15 +0000 (11:37 +0000)]
drm/i915/gt: Track signaled breadcrumbs outside of the breadcrumb spinlock

Make b->signaled_requests a lockless-list so that we can manipulate it
outside of the b->irq_lock.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201123113717.20500-2-chris@chris-wilson.co.uk
(cherry picked from commit 6cfe66eb71b638968350b5f0fff051fd25eb75fb)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
3 years agodrm/amdgpu: fix a page fault
Sonny Jiang [Fri, 20 Nov 2020 07:38:09 +0000 (02:38 -0500)]
drm/amdgpu: fix a page fault

The UVD firmware is copied to cpu addr in uvd_resume, so it
should be used after that. This is to fix a bug introduced by
patch drm/amdgpu: fix SI UVD firmware validate resume fail.

Signed-off-by: Sonny Jiang <sonny.jiang@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
CC: stable@vger.kernel.org
3 years agodrm/amdgpu: fix SI UVD firmware validate resume fail
Sonny Jiang [Fri, 6 Nov 2020 21:42:47 +0000 (16:42 -0500)]
drm/amdgpu: fix SI UVD firmware validate resume fail

The SI UVD firmware validate key is stored at the end of firmware,
which is changed during resume while playing video. So get the key
at sw_init and store it for fw validate using.

Signed-off-by: Sonny Jiang <sonny.jiang@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
3 years agodrm/amd/amdgpu: fix null pointer in runtime pm
Kenneth Feng [Tue, 17 Nov 2020 13:10:59 +0000 (21:10 +0800)]
drm/amd/amdgpu: fix null pointer in runtime pm

fix the null pointer issue when runtime pm is triggered.

Signed-off-by: Kenneth Feng <kenneth.feng@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
3 years agodrm/i915/gt: Defer enabling the breadcrumb interrupt to after submission
Chris Wilson [Mon, 23 Nov 2020 11:37:14 +0000 (11:37 +0000)]
drm/i915/gt: Defer enabling the breadcrumb interrupt to after submission

Move the register slow register write and readback from out of the
critical path for execlists submission and delay it until the following
worker, shaving off around 200us. Note that the same signal_irq_work() is
allowed to run concurrently on each CPU (but it will only be queued once,
once running though it can be requeued and reexecuted) so we have to
remember to lock the global interactions as we cannot rely on the
signal_irq_work() itself providing the serialisation (in constrast to a
tasklet).

By pushing the arm/disarm into the central signaling worker we can close
the race for disarming the interrupt (and dropping its associated
GT wakeref) on parking the engine. If we loose the race, that GT wakeref
may be held indefinitely, preventing the machine from sleeping while
the GPU is ostensibly idle.

v2: Move the self-arming parking of the signal_irq_work to a flush of
the irq-work from intel_breadcrumbs_park().

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2271
Fixes: e23005604b2f ("drm/i915/gt: Hold context/request reference while breadcrumbs are active")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201123113717.20500-1-chris@chris-wilson.co.uk
(cherry picked from commit 9d5612ca165a58aacc160465532e7998b9aab270)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
3 years agodrm/i915/gvt: correct a false comment of flag F_UNALIGN
Yan Zhao [Thu, 10 Sep 2020 03:54:05 +0000 (11:54 +0800)]
drm/i915/gvt: correct a false comment of flag F_UNALIGN

Correct falsely removed comment of flag F_UNALIGN.

Fixes: a6c5817a38cf ("drm/i915/gvt: remove flag F_CMD_ACCESSED")
Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200910035405.20273-1-yan.y.zhao@intel.com
(cherry picked from commit 6594094f819e0020e926e137e47e2edb97ba500b)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
3 years agodrm/i915/perf: workaround register corruption in OATAILPTR
Lionel Landwerlin [Tue, 17 Nov 2020 13:01:24 +0000 (15:01 +0200)]
drm/i915/perf: workaround register corruption in OATAILPTR

After having written the entire OA buffer with reports, the HW will
write again at the beginning of the OA buffer. It'll indicate it by
setting the WRAP bits in the OASTATUS register.

When a wrap happens and that at the end of the read vfunc we write the
OASTATUS register back to clear the REPORT_LOST bit, we sometimes see
that the OATAILPTR register is reset to a previous position on Gen8/9
(apparently not the case on Gen11+). This leads the next call to the
read vfunc to process reports we've already read. Because we've marked
those as read by clearing the reason & timestamp dwords, they're
discarded and a "Skipping spurious, invalid OA report" message is
emitted.

The workaround to avoid this OATAILPTR value reset seems to be to set
the wrap bits when writing back OASTATUS.

This change has no impact on userspace, it only avoids a bunch of
DRM_NOTE("Skipping spurious, invalid OA report\n") messages.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 19f81df2859eb1 ("drm/i915/perf: Add OA unit support for Gen 8+")
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201117130124.829979-1-lionel.g.landwerlin@intel.com
(cherry picked from commit 059a0beb486344a577ff476acce75e69eab704be)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>