1. 09 Nov, 2022 15 commits
    • Like Xu's avatar
      KVM: x86/pmu: Do not speculatively query Intel GP PMCs that don't exist yet · 8631ef59
      Like Xu authored
      The SDM lists an architectural MSR IA32_CORE_CAPABILITIES (0xCF)
      that limits the theoretical maximum value of the Intel GP PMC MSRs
      allocated at 0xC1 to 14; likewise the Intel April 2022 SDM adds
      IA32_OVERCLOCKING_STATUS at 0x195 which limits the number of event
      selection MSRs to 15 (0x186-0x194).
      
      Limiting the maximum number of counters to 14 or 18 based on the currently
      allocated MSRs is clearly fragile, and it seems likely that Intel will
      even place PMCs 8-15 at a completely different range of MSR indices.
      So stop at the maximum number of GP PMCs supported today on Intel
      processors.
      
      There are some machines, like Intel P4 with non Architectural PMU, that
      may indeed have 18 counters, but those counters are in a completely
      different MSR address range and are not supported by KVM.
      
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: cf05a67b ("KVM: x86: omit "impossible" pmu MSRs from MSR list")
      Suggested-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarLike Xu <likexu@tencent.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Message-Id: <20220919091008.60695-1-likexu@tencent.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8631ef59
    • Peter Gonda's avatar
      KVM: SVM: Only dump VMSA to klog at KERN_DEBUG level · 0bd8bd2f
      Peter Gonda authored
      Explicitly print the VMSA dump at KERN_DEBUG log level, KERN_CONT uses
      KERNEL_DEFAULT if the previous log line has a newline, i.e. if there's
      nothing to continuing, and as a result the VMSA gets dumped when it
      shouldn't.
      
      The KERN_CONT documentation says it defaults back to KERNL_DEFAULT if the
      previous log line has a newline. So switch from KERN_CONT to
      print_hex_dump_debug().
      
      Jarkko pointed this out in reference to the original patch. See:
      https://lore.kernel.org/all/YuPMeWX4uuR1Tz3M@kernel.org/
      print_hex_dump(KERN_DEBUG, ...) was pointed out there, but
      print_hex_dump_debug() should similar.
      
      Fixes: 6fac42f1 ("KVM: SVM: Dump Virtual Machine Save Area (VMSA) to klog")
      Signed-off-by: default avatarPeter Gonda <pgonda@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Cc: Jarkko Sakkinen <jarkko@kernel.org>
      Cc: Harald Hoyer <harald@profian.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: x86@kernel.org
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org
      Message-Id: <20221104142220.469452-1-pgonda@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0bd8bd2f
    • Rong Tao's avatar
      tools/kvm_stat: update exit reasons for vmx/svm/aarch64/userspace · 2c1b5434
      Rong Tao authored
      Update EXIT_REASONS from source, including VMX_EXIT_REASONS,
      SVM_EXIT_REASONS, AARCH64_EXIT_REASONS, USERSPACE_EXIT_REASONS.
      Signed-off-by: default avatarRong Tao <rongtao@cestc.cn>
      Message-Id: <tencent_00082C8BFA925A65E11570F417F1CD404505@qq.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2c1b5434
    • Matthias Gerstner's avatar
      tools/kvm_stat: fix incorrect detection of debugfs · 8e1071d0
      Matthias Gerstner authored
      The first field in /proc/mounts can be influenced by unprivileged users
      through the widespread `fusermount` setuid-root program. Example:
      
      ```
      user$ mkdir ~/mydebugfs
      user$ export _FUSE_COMMFD=0
      user$ fusermount ~/mydebugfs -ononempty,fsname=debugfs
      user$ grep debugfs /proc/mounts
      debugfs /home/user/mydebugfs fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0
      ```
      
      If there is no debugfs already mounted in the system then this can be
      used by unprivileged users to trick kvm_stat into using a user
      controlled file system location for obtaining KVM statistics.
      Even though the root user is not allowed to access non-root FUSE mounts
      for security reasons, the unprivileged user can unmount the FUSE mount
      before kvm_stat uses the mounted path.  If it wins the race, kvm_stat
      will read from the location where the FUSE mount resided.
      
      Note that the files in debugfs are only opened for reading, so the
      attacker can cause very large data to be read in by kvm_stat, or fake
      data to be processed, but there should be no viable way to turn this
      into a privilege escalation.
      
      The fix is simply to use the file system type field instead. Whitespace
      in the mount path is escaped in /proc/mounts thus no further safety
      measures in the parsing should be necessary to make this correct.
      
      Message-Id: <20221103135927.13656-1-matthias.gerstner@suse.de>
      Signed-off-by: default avatarMatthias Gerstner <matthias.gerstner@suse.de>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8e1071d0
    • Paolo Bonzini's avatar
      x86, KVM: remove unnecessary argument to x86_virt_spec_ctrl and callers · bd3d394e
      Paolo Bonzini authored
      x86_virt_spec_ctrl only deals with the paravirtualized
      MSR_IA32_VIRT_SPEC_CTRL now and does not handle MSR_IA32_SPEC_CTRL
      anymore; remove the corresponding, unused argument.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      bd3d394e
    • Paolo Bonzini's avatar
      KVM: SVM: move MSR_IA32_SPEC_CTRL save/restore to assembly · 9f2febf3
      Paolo Bonzini authored
      Restoration of the host IA32_SPEC_CTRL value is probably too late
      with respect to the return thunk training sequence.
      
      With respect to the user/kernel boundary, AMD says, "If software chooses
      to toggle STIBP (e.g., set STIBP on kernel entry, and clear it on kernel
      exit), software should set STIBP to 1 before executing the return thunk
      training sequence." I assume the same requirements apply to the guest/host
      boundary. The return thunk training sequence is in vmenter.S, quite close
      to the VM-exit. On hosts without V_SPEC_CTRL, however, the host's
      IA32_SPEC_CTRL value is not restored until much later.
      
      To avoid this, move the restoration of host SPEC_CTRL to assembly and,
      for consistency, move the restoration of the guest SPEC_CTRL as well.
      This is not particularly difficult, apart from some care to cover both
      32- and 64-bit, and to share code between SEV-ES and normal vmentry.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Suggested-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9f2febf3
    • Paolo Bonzini's avatar
      KVM: SVM: restore host save area from assembly · e287bd00
      Paolo Bonzini authored
      Allow access to the percpu area via the GS segment base, which is
      needed in order to access the saved host spec_ctrl value.  In linux-next
      FILL_RETURN_BUFFER also needs to access percpu data.
      
      For simplicity, the physical address of the save area is added to struct
      svm_cpu_data.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Analyzed-by: default avatarAndrew Cooper <andrew.cooper3@citrix.com>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e287bd00
    • Paolo Bonzini's avatar
      KVM: SVM: move guest vmsave/vmload back to assembly · e61ab42d
      Paolo Bonzini authored
      It is error-prone that code after vmexit cannot access percpu data
      because GSBASE has not been restored yet.  It forces MSR_IA32_SPEC_CTRL
      save/restore to happen very late, after the predictor untraining
      sequence, and it gets in the way of return stack depth tracking
      (a retbleed mitigation that is in linux-next as of 2022-11-09).
      
      As a first step towards fixing that, move the VMCB VMSAVE/VMLOAD to
      assembly, essentially undoing commit fb0c4a4f ("KVM: SVM: move
      VMLOAD/VMSAVE to C code", 2021-03-15).  The reason for that commit was
      that it made it simpler to use a different VMCB for VMLOAD/VMSAVE versus
      VMRUN; but that is not a big hassle anymore thanks to the kvm-asm-offsets
      machinery and other related cleanups.
      
      The idea on how to number the exception tables is stolen from
      a prototype patch by Peter Zijlstra.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Link: <https://lore.kernel.org/all/f571e404-e625-bae1-10e9-449b2eb4cbd8@citrix.com/>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e61ab42d
    • Paolo Bonzini's avatar
      KVM: SVM: do not allocate struct svm_cpu_data dynamically · 73412dfe
      Paolo Bonzini authored
      The svm_data percpu variable is a pointer, but it is allocated via
      svm_hardware_setup() when KVM is loaded.  Unlike hardware_enable()
      this means that it is never NULL for the whole lifetime of KVM, and
      static allocation does not waste any memory compared to the status quo.
      It is also more efficient and more easily handled from assembly code,
      so do it and don't look back.
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      73412dfe
    • Paolo Bonzini's avatar
      KVM: SVM: remove dead field from struct svm_cpu_data · 181d0fb0
      Paolo Bonzini authored
      The "cpu" field of struct svm_cpu_data has been write-only since commit
      4b656b12 ("KVM: SVM: force new asid on vcpu migration", 2009-08-05).
      Remove it.
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      181d0fb0
    • Paolo Bonzini's avatar
      KVM: SVM: remove unused field from struct vcpu_svm · 00145978
      Paolo Bonzini authored
      The pointer to svm_cpu_data in struct vcpu_svm looks interesting from
      the point of view of accessing it after vmexit, when the GSBASE is still
      containing the guest value.  However, despite existing since the very
      first commit of drivers/kvm/svm.c (commit 6aa8b732, "[PATCH] kvm:
      userspace interface", 2006-12-10), it was never set to anything.
      
      Ignore the opportunity to fix a 16 year old "bug" and delete it; doing
      things the "harder" way makes it possible to remove more old cruft.
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      00145978
    • Paolo Bonzini's avatar
      KVM: SVM: retrieve VMCB from assembly · f6d58266
      Paolo Bonzini authored
      Continue moving accesses to struct vcpu_svm to vmenter.S.  Reducing the
      number of arguments limits the chance of mistakes due to different
      registers used for argument passing in 32- and 64-bit ABIs; pushing the
      VMCB argument and almost immediately popping it into a different
      register looks pretty weird.
      
      32-bit ABI is not a concern for __svm_sev_es_vcpu_run() which is 64-bit
      only; however, it will soon need @svm to save/restore SPEC_CTRL so stay
      consistent with __svm_vcpu_run() and let them share the same prototype.
      
      No functional change intended.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f6d58266
    • Paolo Bonzini's avatar
      KVM: SVM: adjust register allocation for __svm_vcpu_run() · f7ef2801
      Paolo Bonzini authored
      32-bit ABI uses RAX/RCX/RDX as its argument registers, so they are in
      the way of instructions that hardcode their operands such as RDMSR/WRMSR
      or VMLOAD/VMRUN/VMSAVE.
      
      In preparation for moving vmload/vmsave to __svm_vcpu_run(), keep
      the pointer to the struct vcpu_svm in %rdi.  In particular, it is now
      possible to load svm->vmcb01.pa in %rax without clobbering the struct
      vcpu_svm pointer.
      
      No functional change intended.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f7ef2801
    • Paolo Bonzini's avatar
      KVM: SVM: replace regs argument of __svm_vcpu_run() with vcpu_svm · 16fdc1de
      Paolo Bonzini authored
      Since registers are reachable through vcpu_svm, and we will
      need to access more fields of that struct, pass it instead
      of the regs[] array.
      
      No functional change intended.
      
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      16fdc1de
    • Paolo Bonzini's avatar
      KVM: x86: use a separate asm-offsets.c file · debc5a1e
      Paolo Bonzini authored
      This already removes an ugly #include "" from asm-offsets.c, but
      especially it avoids a future error when trying to define asm-offsets
      for KVM's svm/svm.h header.
      
      This would not work for kernel/asm-offsets.c, because svm/svm.h
      includes kvm_cache_regs.h which is not in the include path when
      compiling asm-offsets.c.  The problem is not there if the .c file is
      in arch/x86/kvm.
      Suggested-by: default avatarSean Christopherson <seanjc@google.com>
      Cc: stable@vger.kernel.org
      Fixes: a149180f ("x86: Add magic AMD return-thunk")
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      debc5a1e
  2. 06 Nov, 2022 2 commits
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-fixes-6.1-3' of... · f4298cac
      Paolo Bonzini authored
      Merge tag 'kvmarm-fixes-6.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      * Fix the pKVM stage-1 walker erronously using the stage-2 accessor
      
      * Correctly convert vcpu->kvm to a hyp pointer when generating
        an exception in a nVHE+MTE configuration
      
      * Check that KVM_CAP_DIRTY_LOG_* are valid before enabling them
      
      * Fix SMPRI_EL1/TPIDR2_EL0 trapping on VHE
      
      * Document the boot requirements for FGT when entering the kernel
        at EL1
      f4298cac
    • Paolo Bonzini's avatar
      Merge branch 'kvm-master' into HEAD · 14620149
      Paolo Bonzini authored
      x86:
      * Use SRCU to protect zap in __kvm_set_or_clear_apicv_inhibit()
      
      * Make argument order consistent for kvcalloc()
      
      * Userspace API fixes for DEBUGCTL and LBRs
      14620149
  3. 03 Nov, 2022 2 commits
    • Liao Chang's avatar
      KVM: x86: Fix a typo about the usage of kvcalloc() · 8670866b
      Liao Chang authored
      Swap the 1st and 2nd arguments to be consistent with the usage of
      kvcalloc().
      
      Fixes: c9b8fecd ("KVM: use kvcalloc for array allocations")
      Signed-off-by: default avatarLiao Chang <liaochang1@huawei.com>
      Message-Id: <20221103011749.139262-1-liaochang1@huawei.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8670866b
    • Ben Gardon's avatar
      KVM: x86: Use SRCU to protect zap in __kvm_set_or_clear_apicv_inhibit() · 074c0080
      Ben Gardon authored
      kvm_zap_gfn_range() must be called in an SRCU read-critical section, but
      there is no SRCU annotation in __kvm_set_or_clear_apicv_inhibit(). This
      can lead to the following warning via
      kvm_arch_vcpu_ioctl_set_guest_debug() if a Shadow MMU is in use (TDP
      MMU disabled or nesting):
      
      [ 1416.659809] =============================
      [ 1416.659810] WARNING: suspicious RCU usage
      [ 1416.659839] 6.1.0-dbg-DEV #1 Tainted: G S        I
      [ 1416.659853] -----------------------------
      [ 1416.659854] include/linux/kvm_host.h:954 suspicious rcu_dereference_check() usage!
      [ 1416.659856]
      ...
      [ 1416.659904]  dump_stack_lvl+0x84/0xaa
      [ 1416.659910]  dump_stack+0x10/0x15
      [ 1416.659913]  lockdep_rcu_suspicious+0x11e/0x130
      [ 1416.659919]  kvm_zap_gfn_range+0x226/0x5e0
      [ 1416.659926]  ? kvm_make_all_cpus_request_except+0x18b/0x1e0
      [ 1416.659935]  __kvm_set_or_clear_apicv_inhibit+0xcc/0x100
      [ 1416.659940]  kvm_arch_vcpu_ioctl_set_guest_debug+0x350/0x390
      [ 1416.659946]  kvm_vcpu_ioctl+0x2fc/0x620
      [ 1416.659955]  __se_sys_ioctl+0x77/0xc0
      [ 1416.659962]  __x64_sys_ioctl+0x1d/0x20
      [ 1416.659965]  do_syscall_64+0x3d/0x80
      [ 1416.659969]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Always take the KVM SRCU read lock in __kvm_set_or_clear_apicv_inhibit()
      to protect the GFN to memslot translation. The SRCU read lock is not
      technically required when no Shadow MMUs are in use, since the TDP MMU
      walks the paging structures from the roots and does not need to look up
      GFN translations in the memslots, but make the SRCU locking
      unconditional for simplicty.
      
      In most cases, the SRCU locking is taken care of in the vCPU run loop,
      but when called through other ioctls (such as KVM_SET_GUEST_DEBUG)
      there is no srcu_read_lock.
      
      Tested: ran tools/testing/selftests/kvm/x86_64/debug_regs on a DBG
      	build. This patch causes the suspicious RCU warning to disappear.
      	Note that the warning is hit in __kvm_zap_rmaps(), so
      	kvm_memslots_have_rmaps() must return true in order for this to
      	repro (i.e. the TDP MMU must be off or nesting in use.)
      Reported-by: default avatarGreg Thelen <gthelen@google.com>
      Fixes: 36222b11 ("KVM: x86: don't disable APICv memslot when inhibited")
      Signed-off-by: default avatarBen Gardon <bgardon@google.com>
      Message-Id: <20221102205359.1260980-1-bgardon@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      074c0080
  4. 02 Nov, 2022 6 commits
    • Linus Torvalds's avatar
      Merge tag 'parisc-for-6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 8e5423e9
      Linus Torvalds authored
      Pull parisc architecture fixes from Helge Deller:
       "This mostly handles oddities with the serial port 8250_gsc.c driver.
      
        Although the name suggests it's just for serial ports on the GSC bus
        (e.g. in older PA-RISC machines), it handles serial ports on PA-RISC
        PCI devices (e.g. on the SuperIO chip) as well.
      
        Thus this renames the driver to 8250_parisc and fixes the config
        dependencies.
      
        The other change is a cleanup on how the device IDs of devices in a
        PA-RISC machine are shown at startup"
      
      * tag 'parisc-for-6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: Avoid printing the hardware path twice
        parisc: Export iosapic_serial_irq() symbol for serial port driver
        MAINTAINERS: adjust entry after renaming parisc serial driver
        parisc: Use signed char for hardware path in pdc.h
        parisc/serial: Rename 8250_gsc.c to 8250_parisc.c
        parisc: Make 8250_gsc driver dependend on CONFIG_PARISC
      8e5423e9
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-6.1-2' of git://git.linux-nfs.org/projects/anna/linux-nfs · 31fc92fc
      Linus Torvalds authored
      Pull NFS client bugfixes from Anna Schumaker:
      
       - Fix some coccicheck warnings
      
       - Avoid memcpy() run-time warning
      
       - Fix up various state reclaim / RECLAIM_COMPLETE errors
      
       - Fix a null pointer dereference in sysfs
      
       - Fix LOCK races
      
       - Fix gss_unwrap_resp_integ() crasher
      
       - Fix zero length clones
      
       - Fix memleak when allocate slot fails
      
      * tag 'nfs-for-6.1-2' of git://git.linux-nfs.org/projects/anna/linux-nfs:
        nfs4: Fix kmemleak when allocate slot failed
        NFSv4.2: Fixup CLONE dest file size for zero-length count
        SUNRPC: Fix crasher in gss_unwrap_resp_integ()
        NFSv4: Retry LOCK on OLD_STATEID during delegation return
        SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed
        NFSv4.1: We must always send RECLAIM_COMPLETE after a reboot
        NFSv4.1: Handle RECLAIM_COMPLETE trunking errors
        NFSv4: Fix a potential state reclaim deadlock
        NFS: Avoid memcpy() run-time warning for struct sockaddr overflows
        nfs: Remove redundant null checks before kfree
      31fc92fc
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · ae13366b
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Fix a few more of the usual sorts of bugs:
      
         - Another regression with source route validation in CMA, introduced
           this merge window
      
         - Crash in hfi1 due to faulty list operations
      
         - PCI ID updates for EFA
      
         - Disable LOCAL_INV in hns because it causes a HW hang
      
         - Crash in hns due to missing initialization
      
         - Memory leak in rxe
      
         - Missing error unwind during ib_core module loading
      
         - Missing error handling in qedr around work queue creation during
           startup"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/qedr: clean up work queue on failure in qedr_alloc_resources()
        RDMA/core: Fix null-ptr-deref in ib_core_cleanup()
        RDMA/rxe: Fix mr leak in RESPST_ERR_RNR
        RDMA/hns: Fix NULL pointer problem in free_mr_init()
        RDMA/hns: Disable local invalidate operation
        RDMA/efa: Add EFA 0xefa2 PCI ID
        IB/hfi1: Correctly move list in sc_disable()
        RDMA/cma: Use output interface for net_dev check
      ae13366b
    • Sean Christopherson's avatar
      KVM: VMX: Ignore guest CPUID for host userspace writes to DEBUGCTL · b333b8eb
      Sean Christopherson authored
      Ignore guest CPUID for host userspace writes to the DEBUGCTL MSR, KVM's
      ABI is that setting CPUID vs. state can be done in any order, i.e. KVM
      allows userspace to stuff MSRs prior to setting the guest's CPUID that
      makes the new MSR "legal".
      
      Keep the vmx_get_perf_capabilities() check for guest writes, even though
      it's technically unnecessary since the vCPU's PERF_CAPABILITIES is
      consulted when refreshing LBR support.  A future patch will clean up
      vmx_get_perf_capabilities() to avoid the RDMSR on every call, at which
      point the paranoia will incur no meaningful overhead.
      
      Note, prior to vmx_get_perf_capabilities() checking that the host fully
      supports LBRs via x86_perf_get_lbr(), KVM effectively relied on
      intel_pmu_lbr_is_enabled() to guard against host userspace enabling LBRs
      on platforms without full support.
      
      Fixes: c6462363 ("KVM: vmx/pmu: Add PMU_CAP_LBR_FMT check when guest LBR is enabled")
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221006000314.73240-5-seanjc@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b333b8eb
    • Sean Christopherson's avatar
      KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl() · 18e897d2
      Sean Christopherson authored
      Fold vmx_supported_debugctl() into vcpu_supported_debugctl(), its only
      caller.  Setting bits only to clear them a few instructions later is
      rather silly, and splitting the logic makes things seem more complicated
      than they actually are.
      
      Opportunistically drop DEBUGCTLMSR_LBR_MASK now that there's a single
      reference to the pair of bits.  The extra layer of indirection provides
      no meaningful value and makes it unnecessarily tedious to understand
      what KVM is doing.
      
      No functional change.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221006000314.73240-4-seanjc@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      18e897d2
    • Sean Christopherson's avatar
      KVM: VMX: Advertise PMU LBRs if and only if perf supports LBRs · 145dfad9
      Sean Christopherson authored
      Advertise LBR support to userspace via MSR_IA32_PERF_CAPABILITIES if and
      only if perf fully supports LBRs.  Perf may disable LBRs (by zeroing the
      number of LBRs) even on platforms the allegedly support LBRs, e.g. if
      probing any LBR MSRs during setup fails.
      
      Fixes: be635e34 ("KVM: vmx/pmu: Expose LBR_FMT in the MSR_IA32_PERF_CAPABILITIES")
      Reported-by: default avatarLike Xu <like.xu.linux@gmail.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221006000314.73240-3-seanjc@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      145dfad9
  5. 01 Nov, 2022 8 commits
  6. 31 Oct, 2022 4 commits
  7. 30 Oct, 2022 3 commits
    • Linus Torvalds's avatar
      Linux 6.1-rc3 · 30a0b95b
      Linus Torvalds authored
      30a0b95b
    • Linus Torvalds's avatar
      Merge tag 'fbdev-for-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev · b72018ab
      Linus Torvalds authored
      Pull fbdev fixes from Helge Deller:
       "A use-after-free bugfix in the smscufx driver and various minor error
        path fixes, smaller build fixes, sysfs fixes and typos in comments in
        the stifb, sisfb, da8xxfb, xilinxfb, sm501fb, gbefb and cyber2000fb
        drivers"
      
      * tag 'fbdev-for-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev:
        fbdev: cyber2000fb: fix missing pci_disable_device()
        fbdev: sisfb: use explicitly signed char
        fbdev: smscufx: Fix several use-after-free bugs
        fbdev: xilinxfb: Make xilinxfb_release() return void
        fbdev: sisfb: fix repeated word in comment
        fbdev: gbefb: Convert sysfs snprintf to sysfs_emit
        fbdev: sm501fb: Convert sysfs snprintf to sysfs_emit
        fbdev: stifb: Fall back to cfb_fillrect() on 32-bit HCRX cards
        fbdev: da8xx-fb: Fix error handling in .remove()
        fbdev: MIPS supports iomem addresses
      b72018ab
    • Linus Torvalds's avatar
      Merge tag 'char-misc-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · 9f127546
      Linus Torvalds authored
      Pull char/misc fixes from Greg KH:
       "Some small driver fixes for 6.1-rc3.  They include:
      
         - iio driver bugfixes
      
         - counter driver bugfixes
      
         - coresight bugfixes, including a revert and then a second fix to get
           it right.
      
        All of these have been in linux-next with no reported problems"
      
      * tag 'char-misc-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits)
        misc: sgi-gru: use explicitly signed char
        coresight: cti: Fix hang in cti_disable_hw()
        Revert "coresight: cti: Fix hang in cti_disable_hw()"
        counter: 104-quad-8: Fix race getting function mode and direction
        counter: microchip-tcb-capture: Handle Signal1 read and Synapse
        coresight: cti: Fix hang in cti_disable_hw()
        coresight: Fix possible deadlock with lock dependency
        counter: ti-ecap-capture: fix IS_ERR() vs NULL check
        counter: Reduce DEFINE_COUNTER_ARRAY_POLARITY() to defining counter_array
        iio: bmc150-accel-core: Fix unsafe buffer attributes
        iio: adxl367: Fix unsafe buffer attributes
        iio: adxl372: Fix unsafe buffer attributes
        iio: at91-sama5d2_adc: Fix unsafe buffer attributes
        iio: temperature: ltc2983: allocate iio channels once
        tools: iio: iio_utils: fix digit calculation
        iio: adc: stm32-adc: fix channel sampling time init
        iio: adc: mcp3911: mask out device ID in debug prints
        iio: adc: mcp3911: use correct id bits
        iio: adc: mcp3911: return proper error code on failure to allocate trigger
        iio: adc: mcp3911: fix sizeof() vs ARRAY_SIZE() bug
        ...
      9f127546