Skip to content
  1. Sep 22, 2021
    • Sean Christopherson's avatar
      KVM: SEV: Pin guest memory for write for RECEIVE_UPDATE_DATA · 50c03801
      Sean Christopherson authored
      Require the target guest page to be writable when pinning memory for
      RECEIVE_UPDATE_DATA.  Per the SEV API, the PSP writes to guest memory:
      
        The result is then encrypted with GCTX.VEK and written to the memory
        pointed to by GUEST_PADDR field.
      
      Fixes: 15fb7de1
      
       ("KVM: SVM: Add KVM_SEV_RECEIVE_UPDATE_DATA command")
      Cc: stable@vger.kernel.org
      Cc: Peter Gonda <pgonda@google.com>
      Cc: Marc Orr <marcorr@google.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210914210951.2994260-2-seanjc@google.com>
      Reviewed-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Reviewed-by: default avatarPeter Gonda <pgonda@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      50c03801
    • Mingwei Zhang's avatar
      KVM: SVM: fix missing sev_decommission in sev_receive_start · f1815e0a
      Mingwei Zhang authored
      DECOMMISSION the current SEV context if binding an ASID fails after
      RECEIVE_START.  Per AMD's SEV API, RECEIVE_START generates a new guest
      context and thus needs to be paired with DECOMMISSION:
      
           The RECEIVE_START command is the only command other than the LAUNCH_START
           command that generates a new guest context and guest handle.
      
      The missing DECOMMISSION can result in subsequent SEV launch failures,
      as the firmware leaks memory and might not able to allocate more SEV
      guest contexts in the future.
      
      Note, LAUNCH_START suffered the same bug, but was previously fixed by
      commit 934002cd
      
       ("KVM: SVM: Call SEV Guest Decommission if ASID
      binding fails").
      
      Cc: Alper Gun <alpergun@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Cc: David Rienjes <rientjes@google.com>
      Cc: Marc Orr <marcorr@google.com>
      Cc: John Allen <john.allen@amd.com>
      Cc: Peter Gonda <pgonda@google.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Vipin Sharma <vipinsh@google.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarMarc Orr <marcorr@google.com>
      Acked-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Fixes: af43cbbf
      
       ("KVM: SVM: Add support for KVM_SEV_RECEIVE_START command")
      Signed-off-by: default avatarMingwei Zhang <mizhang@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210912181815.3899316-1-mizhang@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f1815e0a
    • Peter Gonda's avatar
      KVM: SEV: Acquire vcpu mutex when updating VMSA · bb18a677
      Peter Gonda authored
      The update-VMSA ioctl touches data stored in struct kvm_vcpu, and
      therefore should not be performed concurrently with any VCPU ioctl
      that might cause KVM or the processor to use the same data.
      
      Adds vcpu mutex guard to the VMSA updating code. Refactors out
      __sev_launch_update_vmsa() function to deal with per vCPU parts
      of sev_launch_update_vmsa().
      
      Fixes: ad73109a
      
       ("KVM: SVM: Provide support to launch and run an SEV-ES guest")
      Signed-off-by: default avatarPeter Gonda <pgonda@google.com>
      Cc: Marc Orr <marcorr@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Cc: kvm@vger.kernel.org
      Cc: stable@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Message-Id: <20210915171755.3773766-1-pgonda@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      bb18a677
    • Sergey Senozhatsky's avatar
      KVM: do not shrink halt_poll_ns below grow_start · ae232ea4
      Sergey Senozhatsky authored
      
      
      grow_halt_poll_ns() ignores values between 0 and
      halt_poll_ns_grow_start (10000 by default). However,
      when we shrink halt_poll_ns we may fall way below
      halt_poll_ns_grow_start and endup with halt_poll_ns
      values that don't make a lot of sense: like 1 or 9,
      or 19.
      
      VCPU1 trace (halt_poll_ns_shrink equals 2):
      
      VCPU1 grow 10000
      VCPU1 shrink 5000
      VCPU1 shrink 2500
      VCPU1 shrink 1250
      VCPU1 shrink 625
      VCPU1 shrink 312
      VCPU1 shrink 156
      VCPU1 shrink 78
      VCPU1 shrink 39
      VCPU1 shrink 19
      VCPU1 shrink 9
      VCPU1 shrink 4
      
      Mirror what grow_halt_poll_ns() does and set halt_poll_ns
      to 0 as soon as new shrink-ed halt_poll_ns value falls
      below halt_poll_ns_grow_start.
      
      Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20210902031100.252080-1-senozhatsky@chromium.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ae232ea4
    • Yu Zhang's avatar
      KVM: nVMX: fix comments of handle_vmon() · ed7023a1
      Yu Zhang authored
      "VMXON pointer" is saved in vmx->nested.vmxon_ptr since
      commit 3573e22c
      
       ("KVM: nVMX: additional checks on
      vmxon region"). Also, handle_vmptrld() & handle_vmclear()
      now have logic to check the VMCS pointer against the VMXON
      pointer.
      
      So just remove the obsolete comments of handle_vmon().
      
      Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
      Message-Id: <20210908171731.18885-1-yu.c.zhang@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ed7023a1
    • Haimin Zhang's avatar
      KVM: x86: Handle SRCU initialization failure during page track init · eb7511bf
      Haimin Zhang authored
      
      
      Check the return of init_srcu_struct(), which can fail due to OOM, when
      initializing the page track mechanism.  Lack of checking leads to a NULL
      pointer deref found by a modified syzkaller.
      
      Reported-by: default avatarTCS Robot <tcs_robot@tencent.com>
      Signed-off-by: default avatarHaimin Zhang <tcs_kernel@tencent.com>
      Message-Id: <1630636626-12262-1-git-send-email-tcs_kernel@tencent.com>
      [Move the call towards the beginning of kvm_arch_init_vm. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      eb7511bf
    • Sean Christopherson's avatar
      KVM: VMX: Remove defunct "nr_active_uret_msrs" field · cd36ae87
      Sean Christopherson authored
      Remove vcpu_vmx.nr_active_uret_msrs and its associated comment, which are
      both defunct now that KVM keeps the list constant and instead explicitly
      tracks which entries need to be loaded into hardware.
      
      No functional change intended.
      
      Fixes: ee9d22e0
      
       ("KVM: VMX: Use flag to indicate "active" uret MSRs instead of sorting list")
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210908002401.1947049-1-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cd36ae87
    • Oliver Upton's avatar
      selftests: KVM: Align SMCCC call with the spec in steal_time · 01f91acb
      Oliver Upton authored
      
      
      The SMC64 calling convention passes a function identifier in w0 and its
      parameters in x1-x17. Given this, there are two deviations in the
      SMC64 call performed by the steal_time test: the function identifier is
      assigned to a 64 bit register and the parameter is only 32 bits wide.
      
      Align the call with the SMCCC by using a 32 bit register to handle the
      function identifier and increasing the parameter width to 64 bits.
      
      Suggested-by: default avatarAndrew Jones <drjones@redhat.com>
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
      Message-Id: <20210921171121.2148982-3-oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      01f91acb
    • Oliver Upton's avatar
      selftests: KVM: Fix check for !POLLIN in demand_paging_test · 90b54129
      Oliver Upton authored
      The logical not operator applies only to the left hand side of a bitwise
      operator. As such, the check for POLLIN not being set in revents wrong.
      Fix it by adding parentheses around the bitwise expression.
      
      Fixes: 4f72180e
      
       ("KVM: selftests: Add demand paging content to the demand paging test")
      Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Message-Id: <20210921171121.2148982-2-oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      90b54129
    • Sean Christopherson's avatar
      KVM: x86: Clear KVM's cached guest CR3 at RESET/INIT · 03a6e840
      Sean Christopherson authored
      
      
      Explicitly zero the guest's CR3 and mark it available+dirty at RESET/INIT.
      Per Intel's SDM and AMD's APM, CR3 is zeroed at both RESET and INIT.  For
      RESET, this is a nop as vcpu is zero-allocated.  For INIT, the bug has
      likely escaped notice because no firmware/kernel puts its page tables root
      at PA=0, let alone relies on INIT to get the desired CR3 for such page
      tables.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210921000303.400537-3-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      03a6e840
    • Sean Christopherson's avatar
      KVM: x86: Mark all registers as avail/dirty at vCPU creation · 7117003f
      Sean Christopherson authored
      Mark all registers as available and dirty at vCPU creation, as the vCPU has
      obviously not been loaded into hardware, let alone been given the chance to
      be modified in hardware.  On SVM, reading from "uninitialized" hardware is
      a non-issue as VMCBs are zero allocated (thus not truly uninitialized) and
      hardware does not allow for arbitrary field encoding schemes.
      
      On VMX, backing memory for VMCSes is also zero allocated, but true
      initialization of the VMCS _technically_ requires VMWRITEs, as the VMX
      architectural specification technically allows CPU implementations to
      encode fields with arbitrary schemes.  E.g. a CPU could theoretically store
      the inverted value of every field, which would result in VMREAD to a
      zero-allocated field returns all ones.
      
      In practice, only the AR_BYTES fields are known to be manipulated by
      hardware during VMREAD/VMREAD; no known hardware or VMM (for nested VMX)
      does fancy encoding of cacheable field values (CR0, CR3, CR4, etc...).  In
      other words, this is technically a bug fix, but practically speakings it's
      a glorified nop.
      
      Failure to mark registers as available has been a lurking bug for quite
      some time.  The original register caching supported only GPRs (+RIP, which
      is kinda sorta a GPR), with the masks initialized at ->vcpu_reset().  That
      worked because the two cacheable registers, RIP and RSP, are generally
      speaking not read as side effects in other flows.
      
      Arguably, commit aff48baa ("KVM: Fetch guest cr3 from hardware on
      demand") was the first instance of failure to mark regs available.  While
      _just_ marking CR3 available during vCPU creation wouldn't have fixed the
      VMREAD from an uninitialized VMCS bug because ept_update_paging_mode_cr0()
      unconditionally read vmcs.GUEST_CR3, marking CR3 _and_ intentionally not
      reading GUEST_CR3 when it's available would have avoided VMREAD to a
      technically-uninitialized VMCS.
      
      Fixes: aff48baa ("KVM: Fetch guest cr3 from hardware on demand")
      Fixes: 6de4f3ad ("KVM: Cache pdptrs")
      Fixes: 6de12732 ("KVM: VMX: Optimize vmx_get_rflags()")
      Fixes: 2fb92db1 ("KVM: VMX: Cache vmcs segment fields")
      Fixes: bd31fe49 ("KVM: VMX: Add proper cache tracking for CR0")
      Fixes: f98c1e77 ("KVM: VMX: Add proper cache tracking for CR4")
      Fixes: 5addc235 ("KVM: VMX: Cache vmcs.EXIT_QUALIFICATION using arch avail_reg flags")
      Fixes: 87915858
      
       ("KVM: VMX: Cache vmcs.EXIT_INTR_INFO using arch avail_reg flags")
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210921000303.400537-2-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7117003f
    • Sean Christopherson's avatar
      KVM: selftests: Remove __NR_userfaultfd syscall fallback · 2da4a235
      Sean Christopherson authored
      
      
      Revert the __NR_userfaultfd syscall fallback added for KVM selftests now
      that x86's unistd_{32,63}.h overrides are under uapi/ and thus not in
      KVM selftests' search path, i.e. now that KVM gets x86 syscall numbers
      from the installed kernel headers.
      
      No functional change intended.
      
      Reviewed-by: default avatarBen Gardon <bgardon@google.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210901203030.1292304-6-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2da4a235
    • Sean Christopherson's avatar
      KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs · 61e52f16
      Sean Christopherson authored
      Add a test to verify an rseq's CPU ID is updated correctly if the task is
      migrated while the kernel is handling KVM_RUN.  This is a regression test
      for a bug introduced by commit 72c3c0fe
      
       ("x86/kvm: Use generic xfer
      to guest work function"), where TIF_NOTIFY_RESUME would be cleared by KVM
      without updating rseq, leading to a stale CPU ID and other badness.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Message-Id: <20210901203030.1292304-5-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      61e52f16
    • Sean Christopherson's avatar
      tools: Move x86 syscall number fallbacks to .../uapi/ · de5f4213
      Sean Christopherson authored
      Move unistd_{32,64}.h from x86/include/asm to x86/include/uapi/asm so
      that tools/selftests that install kernel headers, e.g. KVM selftests, can
      include non-uapi tools headers, e.g. to get 'struct list_head', without
      effectively overriding the installed non-tool uapi headers.
      
      Swapping KVM's search order, e.g. to search the kernel headers before
      tool headers, is not a viable option as doing results in linux/type.h and
      other core headers getting pulled from the kernel headers, which do not
      have the kernel-internal typedefs that are used through tools, including
      many files outside of selftests/kvm's control.
      
      Prior to commit cec07f53
      
       ("perf tools: Move syscall number fallbacks
      from perf-sys.h to tools/arch/x86/include/asm/"), the handcoded numbers
      were actual fallbacks, i.e. overriding unistd_{32,64}.h from the kernel
      headers was unintentional.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210901203030.1292304-4-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      de5f4213
    • Sean Christopherson's avatar
      entry: rseq: Call rseq_handle_notify_resume() in tracehook_notify_resume() · a68de80f
      Sean Christopherson authored
      Invoke rseq_handle_notify_resume() from tracehook_notify_resume() now
      that the two function are always called back-to-back by architectures
      that have rseq.  The rseq helper is stubbed out for architectures that
      don't support rseq, i.e. this is a nop across the board.
      
      Note, tracehook_notify_resume() is horribly named and arguably does not
      belong in tracehook.h as literally every line of code in it has nothing
      to do with tracing.  But, that's been true since commit a42c6ded
      
      
      ("move key_repace_session_keyring() into tracehook_notify_resume()")
      first usurped tracehook_notify_resume() back in 2012.  Punt cleaning that
      mess up to future patches.
      
      No functional change intended.
      
      Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210901203030.1292304-3-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a68de80f
    • Sean Christopherson's avatar
      KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest · 8646e536
      Sean Christopherson authored
      Invoke rseq's NOTIFY_RESUME handler when processing the flag prior to
      transferring to a KVM guest, which is roughly equivalent to an exit to
      userspace and processes many of the same pending actions.  While the task
      cannot be in an rseq critical section as the KVM path is reachable only
      by via ioctl(KVM_RUN), the side effects that apply to rseq outside of a
      critical section still apply, e.g. the current CPU needs to be updated if
      the task is migrated.
      
      Clearing TIF_NOTIFY_RESUME without informing rseq can lead to segfaults
      and other badness in userspace VMMs that use rseq in combination with KVM,
      e.g. due to the CPU ID being stale after task migration.
      
      Fixes: 72c3c0fe
      
       ("x86/kvm: Use generic xfer to guest work function")
      Reported-by: default avatarPeter Foley <pefoley@google.com>
      Bisected-by: default avatarDoug Evans <dje@google.com>
      Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210901203030.1292304-2-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8646e536
  2. Sep 20, 2021
    • Linus Torvalds's avatar
      Linux 5.15-rc2 · e4e737bb
      Linus Torvalds authored
      e4e737bb
    • Linus Torvalds's avatar
      pci_iounmap'2: Electric Boogaloo: try to make sense of it all · 316e8d79
      Linus Torvalds authored
      Nathan Chancellor reports that the recent change to pci_iounmap in
      commit 9caea000 ("parisc: Declare pci_iounmap() parisc version only
      when CONFIG_PCI enabled") causes build errors on arm64.
      
      It took me about two hours to convince myself that I think I know what
      the logic of that mess of #ifdef's in the <asm-generic/io.h> header file
      really aim to do, and rewrite it to be easier to follow.
      
      Famous last words.
      
      Anyway, the code has now been lifted from that grotty header file into
      lib/pci_iomap.c, and has fairly extensive comments about what the logic
      is.  It also avoids indirecting through another confusing (and badly
      named) helper function that has other preprocessor config conditionals.
      
      Let's see what odd architecture did something else strange in this area
      to break things.  But my arm64 cross build is clean.
      
      Fixes: 9caea000
      
       ("parisc: Declare pci_iounmap() parisc version only when CONFIG_PCI enabled")
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Ulrich Teichert <krypton@ulrich-teichert.org>
      Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      316e8d79
    • Linus Torvalds's avatar
      Merge tag 'x86_urgent_for_v5.15_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 20621d2f
      Linus Torvalds authored
      Pull x86 fixes from Borislav Petkov:
      
       - Prevent a infinite loop in the MCE recovery on return to user space,
         which was caused by a second MCE queueing work for the same page and
         thereby creating a circular work list.
      
       - Make kern_addr_valid() handle existing PMD entries, which are marked
         not present in the higher level page table, correctly instead of
         blindly dereferencing them.
      
       - Pass a valid address to sanitize_phys(). This was caused by the
         mixture of inclusive and exclusive ranges. memtype_reserve() expect
         'end' being exclusive, but sanitize_phys() wants it inclusive. This
         worked so far, but with end being the end of the physical address
         space the fail is exposed.
      
       - Increase the maximum supported GPIO numbers for 64bit. Newer SoCs
         exceed the previous maximum.
      
      * tag 'x86_urgent_for_v5.15_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/mce: Avoid infinite loop for copy from user recovery
        x86/mm: Fix kern_addr_valid() to cope with existing but not present entries
        x86/platform: Increase maximum GPIO number for X86_64
        x86/pat: Pass valid address to sanitize_phys()
      20621d2f
    • Linus Torvalds's avatar
      Merge tag 'perf-urgent-2021-09-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · fec30362
      Linus Torvalds authored
      Pull perf event fix from Thomas Gleixner:
       "A single fix for the perf core where a value read with READ_ONCE() was
        checked and then reread which makes all the checks invalid. Reuse the
        already read value instead"
      
      * tag 'perf-urgent-2021-09-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        events: Reuse value read using READ_ONCE instead of re-reading it
      fec30362
    • Linus Torvalds's avatar
      Merge tag 'locking-urgent-2021-09-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · f5e29a26
      Linus Torvalds authored
      Pull locking fixes from Thomas Gleixner:
       "A set of updates for the RT specific reader/writer locking base code:
      
         - Make the fast path reader ordering guarantees correct.
      
         - Code reshuffling to make the fix simpler"
      
      [ This plays ugly games with atomic_add_return_release() because we
        don't have a plain atomic_add_release(), and should really be cleaned
        up, I think    - Linus ]
      
      * tag 'locking-urgent-2021-09-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        locking/rwbase: Take care of ordering guarantee for fastpath reader
        locking/rwbase: Extract __rwbase_write_trylock()
        locking/rwbase: Properly match set_and_save_state() to restore_state()
      f5e29a26
    • Linus Torvalds's avatar
      Merge tag 'powerpc-5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 62453a46
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
      
       - Fix crashes when scv (System Call Vectored) is used to make a syscall
         when a transaction is active, on Power9 or later.
      
       - Fix bad interactions between rfscv (Return-from scv) and Power9
         fake-suspend mode.
      
       - Fix crashes when handling machine checks in LPARs using the Hash MMU.
      
       - Partly revert a recent change to our XICS interrupt controller code,
         which broke the recently added Microwatt support.
      
      Thanks to Cédric Le Goater, Eirik Fuller, Ganesh Goudar, Gustavo Romero,
      Joel Stanley, Nicholas Piggin.
      
      * tag 'powerpc-5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/xics: Set the IRQ chip data for the ICS native backend
        powerpc/mce: Fix access error in mce handler
        KVM: PPC: Book3S HV: Tolerate treclaim. in fake-suspend mode changing registers
        powerpc/64s: system call rfscv workaround for TM bugs
        selftests/powerpc: Add scv versions of the basic TM syscall tests
        powerpc/64s: system call scv tabort fix for corrupt irq soft-mask state
      62453a46
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v5.15' of... · 2f629969
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Fix bugs in checkkconfigsymbols.py
      
       - Fix missing sys import in gen_compile_commands.py
      
       - Fix missing FORCE warning for ARCH=sh builds
      
       - Fix -Wignored-optimization-argument warnings for Clang builds
      
       - Turn -Wignored-optimization-argument into an error in order to stop
         building instead of sprinkling warnings
      
      * tag 'kbuild-fixes-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        kbuild: Add -Werror=ignored-optimization-argument to CLANG_FLAGS
        x86/build: Do not add -falign flags unconditionally for clang
        kbuild: Fix comment typo in scripts/Makefile.modpost
        sh: Add missing FORCE prerequisites in Makefile
        gen_compile_commands: fix missing 'sys' package
        checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file
        checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit
      2f629969
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.15-2021-09-18' of... · d94f3957
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.15-2021-09-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix ip display in 'perf script' when output type != attr->type.
      
       - Ignore deprecation warning when using libbpf'sg btf__get_from_id(),
         fixing the build with libbpf v0.6+.
      
       - Make use of FD() robust in libperf, fixing a segfault with 'perf stat
         --iostat list'.
      
       - Initialize addr_location:srcline pointer to NULL when resolving
         callchain addresses.
      
       - Fix fused instruction logic for assembly functions in 'perf
         annotate'.
      
      * tag 'perf-tools-fixes-for-v5.15-2021-09-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf bpf: Ignore deprecation warning when using libbpf's btf__get_from_id()
        libperf evsel: Make use of FD robust.
        perf machine: Initialize srcline string member in add_location struct
        perf script: Fix ip display when type != attr->type
        perf annotate: Fix fused instr logic for assembly functions
      d94f3957
    • Linus Torvalds's avatar
      dmascc: use proper 'virt_to_bus()' rather than casting to 'int' · bc1abb9e
      Linus Torvalds authored
      
      
      The old dmascc driver depends on the legacy ISA_DMA_API, and blindly
      just casts the kernel virtual address to 'int' for set_dma_addr().
      
      That works only incidentally, and because the high bits of the address
      will be ignored anyway. And on 64-bit architectures it causes warnings.
      
      Admittedly, 64-bit architectures with ISA are basically dead - I think
      the only example of this is alpha, and nobody would ever use the dmascc
      driver there.  But hey, the fix is easy enough, the end result is
      cleaner, and it's yet another configuration that now builds without
      warnings.
      
      If somebody actually uses this driver on an alpha and this fixes it for
      you, please email me.  Because that is just incredibly bizarre.
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      bc1abb9e
    • Linus Torvalds's avatar
      alpha: enable GENERIC_PCI_IOMAP unconditionally · 4fef6115
      Linus Torvalds authored
      With the previous commit (9caea000
      
      : "parisc: Declare pci_iounmap()
      parisc version only when CONFIG_PCI enabled") we can now enable
      GENERIC_PCI_IOMAP unconditionally on alpha, and if PCI is not enabled we
      will just get the nice empty helper functions that allow mixed-bus
      drivers to build.
      
      Example driver: the old 3com/3c59x.c driver works with either the PCI or
      the EISA version of the 3x59x card, but wouldn't build in an EISA-only
      configuration because of missing pci_iomap() and pci_iounmap() dummy
      wrappers.
      
      Most of the other PCI infrastructure just becomes empty wrappers even
      without GENERIC_PCI_IOMAP, and it's not obvious that the pci_iomap
      functionality shouldn't do the same, but this works.
      
      Cc: Ulrich Teichert <krypton@ulrich-teichert.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4fef6115
    • Helge Deller's avatar
      parisc: Declare pci_iounmap() parisc version only when CONFIG_PCI enabled · 9caea000
      Helge Deller authored
      
      
      Linus noticed odd declaration rules for pci_iounmap() in iomap.h and
      pci_iomap.h, where it dependend on either NO_GENERIC_PCI_IOPORT_MAP or
      GENERIC_IOMAP when CONFIG_PCI was disabled.
      
      Testing on parisc seems to indicate that we need pci_iounmap() only when
      CONFIG_PCI is enabled, so the declaration of pci_iounmap() can be moved
      cleanly into pci_iomap.h in sync with the declarations of pci_iomap().
      
      Link: https://lore.kernel.org/all/CAHk-=wjRrh98pZoQ+AzfWmsTZacWxTJKXZ9eKU2X_0+jM=O8nw@mail.gmail.com/
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Fixes: 97a29d59
      
       ("[PARISC] fix compile break caused by iomap: make IOPORT/PCI mapping functions conditional")
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Ulrich Teichert <krypton@ulrich-teichert.org>
      Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9caea000
    • Linus Torvalds's avatar
      Revert "drm/vc4: hdmi: Remove drm_encoder->crtc usage" · 31ad37bd
      Linus Torvalds authored
      This reverts commit 27da370e
      
      .
      
      Sudip Mukherjee reports that this broke pulseaudio with a NULL pointer
      dereference in vc4_hdmi_audio_prepare(), bisected it to this commit, and
      confirmed that a revert fixed the problem.
      
      Revert the problematic commit until fixed.
      
      Link: https://lore.kernel.org/all/CADVatmPB9-oKd=ypvj25UYysVo6EZhQ6bCM7EvztQBMyiZfAyw@mail.gmail.com/
      Link: https://lore.kernel.org/all/CADVatmN5EpRshGEPS_JozbFQRXg5w_8LFB3OMP1Ai-ghxd3w4g@mail.gmail.com/
      Reported-and-tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Maxime Ripard <maxime@cerno.tech>
      Cc: Emma Anholt <emma@anholt.net>
      Cc: Dave Airlie <airlied@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      31ad37bd
    • Linus Torvalds's avatar
      Revert drm/vc4 hdmi runtime PM changes · b1044a9b
      Linus Torvalds authored
      This reverts commits
      
        9984d666 ("drm/vc4: hdmi: Make sure the controller is powered in detect")
        411efa18 ("drm/vc4: hdmi: Move the HSM clock enable to runtime_pm")
      
      as Michael Stapelberg reports that the new runtime PM changes cause his
      Raspberry Pi 3 to hang on boot, probably due to interactions with other
      changes in the DRM tree (because a bisect points to the merge in commit
      e058a84b
      
      : "Merge tag 'drm-next-2021-07-01' of git://.../drm").
      
      Revert these two commits until it's been resolved.
      
      Link: https://lore.kernel.org/all/871r5mp7h2.fsf@midna.i-did-not-set--mail-host-address--so-tickle-me/
      Reported-and-tested-by: default avatarMichael Stapelberg <michael@stapelberg.ch>
      Cc: Maxime Ripard <maxime@cerno.tech>
      Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
      Cc: Dave Airlie <airlied@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1044a9b
  3. Sep 19, 2021
    • Nathan Chancellor's avatar
      kbuild: Add -Werror=ignored-optimization-argument to CLANG_FLAGS · 0664684e
      Nathan Chancellor authored
      Similar to commit 589834b3
      
       ("kbuild: Add
      -Werror=unknown-warning-option to CLANG_FLAGS").
      
      Clang ignores certain GCC flags that it has not implemented, only
      emitting a warning:
      
      $ echo | clang -fsyntax-only -falign-jumps -x c -
      clang-14: warning: optimization flag '-falign-jumps' is not supported
      [-Wignored-optimization-argument]
      
      When one of these flags gets added to KBUILD_CFLAGS unconditionally, all
      subsequent cc-{disable-warning,option} calls fail because -Werror was
      added to these invocations to turn the above warning and the equivalent
      -W flag warning into errors.
      
      To catch the presence of these flags earlier, turn
      -Wignored-optimization-argument into an error so that the flags can
      either be implemented or ignored via cc-option and there are no more
      weird errors.
      
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      0664684e
    • Nathan Chancellor's avatar
      x86/build: Do not add -falign flags unconditionally for clang · 7fa6a274
      Nathan Chancellor authored
      
      
      clang does not support -falign-jumps and only recently gained support
      for -falign-loops. When one of the configuration options that adds these
      flags is enabled, clang warns and all cc-{disable-warning,option} that
      follow fail because -Werror gets added to test for the presence of this
      warning:
      
      clang-14: warning: optimization flag '-falign-jumps=0' is not supported
      [-Wignored-optimization-argument]
      
      To resolve this, add a couple of cc-option calls when building with
      clang; gcc has supported these options since 3.2 so there is no point in
      testing for their support. -falign-functions was implemented in clang-7,
      -falign-loops was implemented in clang-14, and -falign-jumps has not
      been implemented yet.
      
      Link: https://lore.kernel.org/r/YSQE2f5teuvKLkON@Ryzen-9-3900X.localdomain/
      Link: https://lore.kernel.org/r/20210824022640.2170859-2-nathan@kernel.org/
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7fa6a274
    • Ramji Jiyani's avatar
      kbuild: Fix comment typo in scripts/Makefile.modpost · 7c801446
      Ramji Jiyani authored
      
      
      Change comment "create one <module>.mod.c file pr. module"
      to "create one <module>.mod.c file per module"
      
      Signed-off-by: default avatarRamji Jiyani <ramjiyani@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7c801446
    • Geert Uytterhoeven's avatar
      sh: Add missing FORCE prerequisites in Makefile · 4e70b646
      Geert Uytterhoeven authored
      make:
      
          arch/sh/boot/Makefile:87: FORCE prerequisite is missing
      
      Add the missing FORCE prerequisites for all build targets identified by
      "make help".
      
      Fixes: e1f86d7b
      
       ("kbuild: warn if FORCE is missing for if_changed(_dep,_rule) and filechk")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      4e70b646
    • Kortan's avatar
      gen_compile_commands: fix missing 'sys' package · ec783c7c
      Kortan authored
      We need to import the 'sys' package since the script has called
      sys.exit() method.
      
      Fixes: 6ad7cbc0
      
       ("Makefile: Add clang-tidy and static analyzer support to makefile")
      Signed-off-by: default avatarKortan <kortanzh@gmail.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ec783c7c
    • Ariel Marcovitch's avatar
      checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file · aa0f5ea1
      Ariel Marcovitch authored
      
      
      When parsing Kconfig files to find symbol definitions and references,
      lines after a 'help' line are skipped until a new config definition
      starts.
      
      However, Kconfig statements can actually be after a help section, as
      long as these have shallower indentation. These are skipped by the
      parser.
      
      This means that symbols referenced in this kind of statements are
      ignored by this function and thus are not considered undefined
      references in case the symbol is not defined.
      
      Remove the 'skip' logic entirely, as it is not needed if we just use the
      STMT regex to find the end of help lines.
      
      However, this means that keywords that appear as part of the help
      message (i.e. with the same indentation as the help lines) it will be
      considered as a reference/definition. This can happen now as well, but
      only with REGEX_KCONFIG_DEF lines. Also, the keyword must have a SYMBOL
      after it, which probably means that someone referenced a config in the
      help so it seems like a bonus :)
      
      The real solution is to keep track of the indentation when a the first
      help line in encountered and then handle DEF and STMT lines only if the
      indentation is shallower.
      
      Signed-off-by: default avatarAriel Marcovitch <arielmarcovitch@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      aa0f5ea1
    • Ariel Marcovitch's avatar
      checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit · d62d5aed
      Ariel Marcovitch authored
      
      
      As opposed to the --diff option, --commit can get ref names instead of
      commit hashes.
      
      When using the --commit option, the script resets the working directory
      to the commit before the given ref, by adding '~' to the end of the ref.
      
      However, the 'HEAD' ref is relative, and so when the working directory
      is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the
      script resets to 'HEAD' it actually stays in the same commit. In this
      case, the script won't report any cases because there is no diff between
      the cases of the two refs.
      
      Prevent the user from using HEAD refs.
      
      A better solution might be to resolve the refs before doing the
      reset, but for now just disallow such refs.
      
      Signed-off-by: default avatarAriel Marcovitch <arielmarcovitch@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d62d5aed
    • Linus Torvalds's avatar
      alpha: move __udiv_qrnnd library function to arch/alpha/lib/ · d4d016ca
      Linus Torvalds authored
      
      
      We already had the implementation for __udiv_qrnnd (unsigned divide for
      multi-precision arithmetic) as part of the alpha math emulation code.
      
      But you can disable the math emulation code - even if you shouldn't -
      and then the MPI code that actually wants this functionality (and is
      needed by various crypto functions) will fail to build.
      
      So move the extended-precision divide code to be a regular library
      function, just like all the regular division code is.  That way ie is
      available regardless of math-emulation.
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d4d016ca
    • Linus Torvalds's avatar
      alpha: mark 'Jensen' platform as no longer broken · ab41f75e
      Linus Torvalds authored
      Ok, it almost certainly is still broken on actual hardware, but the
      immediate reason for it having been marked BROKEN was a build error that
      is fixed by just making sure the low-level IO header file is included
      sufficiently early that the __EXTERN_INLINE hackery takes effect.
      
      This was marked broken back in 2017 by commit 1883c9f4
      
       ("alpha: mark
      jensen as broken"), but Ulrich Teichert made me look at it as part of my
      cross-build work to make sure -Werror actually does the right thing.
      
      There are lots of alpha configurations that do not build cleanly, but
      now it's no longer because Jensen wouldn't be buildable.  That said,
      because the Jensen platform doesn't force PCI to be enabled (Jensen only
      had EISA), it ends up being somewhat interesting as a source of odd
      configs.
      
      Reported-by: default avatarUlrich Teichert <krypton@ulrich-teichert.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ab41f75e
    • Andrii Nakryiko's avatar
      perf bpf: Ignore deprecation warning when using libbpf's btf__get_from_id() · 219d720e
      Andrii Nakryiko authored
      
      
      Perf code re-implements libbpf's btf__load_from_kernel_by_id() API as
      a weak function, presumably to dynamically link against old version of
      libbpf shared library. Unfortunately this causes compilation warning
      when perf is compiled against libbpf v0.6+.
      
      For now, just ignore deprecation warning, but there might be a better
      solution, depending on perf's needs.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: kernel-team@fb.com
      LPU-Reference: 20210914170004.4185659-1-andrii@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      219d720e
    • Ian Rogers's avatar
      libperf evsel: Make use of FD robust. · aba5daeb
      Ian Rogers authored
      
      
      FD uses xyarray__entry that may return NULL if an index is out of
      bounds. If NULL is returned then a segv happens as FD unconditionally
      dereferences the pointer. This was happening in a case of with perf
      iostat as shown below. The fix is to make FD an "int*" rather than an
      int and handle the NULL case as either invalid input or a closed fd.
      
        $ sudo gdb --args perf stat --iostat  list
        ...
        Breakpoint 1, perf_evsel__alloc_fd (evsel=0x5555560951a0, ncpus=1, nthreads=1) at evsel.c:50
        50      {
        (gdb) bt
         #0  perf_evsel__alloc_fd (evsel=0x5555560951a0, ncpus=1, nthreads=1) at evsel.c:50
         #1  0x000055555585c188 in evsel__open_cpu (evsel=0x5555560951a0, cpus=0x555556093410,
            threads=0x555556086fb0, start_cpu=0, end_cpu=1) at util/evsel.c:1792
         #2  0x000055555585cfb2 in evsel__open (evsel=0x5555560951a0, cpus=0x0, threads=0x555556086fb0)
            at util/evsel.c:2045
         #3  0x000055555585d0db in evsel__open_per_thread (evsel=0x5555560951a0, threads=0x555556086fb0)
            at util/evsel.c:2065
         #4  0x00005555558ece64 in create_perf_stat_counter (evsel=0x5555560951a0,
            config=0x555555c34700 <stat_config>, target=0x555555c2f1c0 <target>, cpu=0) at util/stat.c:590
         #5  0x000055555578e927 in __run_perf_stat (argc=1, argv=0x7fffffffe4a0, run_idx=0)
            at builtin-stat.c:833
         #6  0x000055555578f3c6 in run_perf_stat (argc=1, argv=0x7fffffffe4a0, run_idx=0)
            at builtin-stat.c:1048
         #7  0x0000555555792ee5 in cmd_stat (argc=1, argv=0x7fffffffe4a0) at builtin-stat.c:2534
         #8  0x0000555555835ed3 in run_builtin (p=0x555555c3f540 <commands+288>, argc=3,
            argv=0x7fffffffe4a0) at perf.c:313
         #9  0x0000555555836154 in handle_internal_command (argc=3, argv=0x7fffffffe4a0) at perf.c:365
         #10 0x000055555583629f in run_argv (argcp=0x7fffffffe2ec, argv=0x7fffffffe2e0) at perf.c:409
         #11 0x0000555555836692 in main (argc=3, argv=0x7fffffffe4a0) at perf.c:539
        ...
        (gdb) c
        Continuing.
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_iio_0/event=0x83,umask=0x04,ch_mask=0xF,fc_mask=0x07/).
        /bin/dmesg | grep -i perf may provide additional information.
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00005555559b03ea in perf_evsel__close_fd_cpu (evsel=0x5555560951a0, cpu=1) at evsel.c:166
        166                     if (FD(evsel, cpu, thread) >= 0)
      
      v3. fixes a bug in perf_evsel__run_ioctl where the sense of a branch was
          backward.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210918054440.2350466-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aba5daeb