1. 05 Oct, 2023 3 commits
    • Uros Bizjak's avatar
      x86/percpu: Use C for percpu read/write accessors · ca425634
      Uros Bizjak authored
      The percpu code mostly uses inline assembly. Using segment qualifiers
      allows to use C code instead, which enables the compiler to perform
      various optimizations (e.g. propagation of memory arguments). Convert
      percpu read and write accessors to C code, so the memory argument can
      be propagated to the instruction that uses this argument.
      
      Some examples of propagations:
      
      a) into sign/zero extensions:
      
      the code improves from:
      
          65 8a 05 00 00 00 00    mov    %gs:0x0(%rip),%al
          0f b6 c0                movzbl %al,%eax
      
      to:
      
          65 0f b6 05 00 00 00    movzbl %gs:0x0(%rip),%eax
          00
      
      and in a similar way for:
      
          movzbl %gs:0x0(%rip),%edx
          movzwl %gs:0x0(%rip),%esi
          movzbl %gs:0x78(%rbx),%eax
      
          movslq %gs:0x0(%rip),%rdx
          movslq %gs:(%rdi),%rbx
      
      b) into compares:
      
      the code improves from:
      
          65 8b 05 00 00 00 00    mov    %gs:0x0(%rip),%eax
          a9 00 00 0f 00          test   $0xf0000,%eax
      
      to:
      
          65 f7 05 00 00 00 00    testl  $0xf0000,%gs:0x0(%rip)
          00 00 0f 00
      
      and in a similar way for:
      
          testl  $0xf0000,%gs:0x0(%rip)
          testb  $0x1,%gs:0x0(%rip)
          testl  $0xff00,%gs:0x0(%rip)
      
          cmpb   $0x0,%gs:0x0(%rip)
          cmp    %gs:0x0(%rip),%r14d
          cmpw   $0x8,%gs:0x0(%rip)
          cmpb   $0x0,%gs:(%rax)
      
      c) into other insns:
      
      the code improves from:
      
         1a355:	83 fa ff             	cmp    $0xffffffff,%edx
         1a358:	75 07                	jne    1a361 <...>
         1a35a:	65 8b 15 00 00 00 00 	mov    %gs:0x0(%rip),%edx
         1a361:
      
      to:
      
         1a35a:	83 fa ff             	cmp    $0xffffffff,%edx
         1a35d:	65 0f 44 15 00 00 00 	cmove  %gs:0x0(%rip),%edx
         1a364:	00
      
      The above propagations result in the following code size
      improvements for current mainline kernel (with the default config),
      compiled with:
      
         # gcc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1)
      
         text            data     bss    dec             filename
         25508862        4386540  808388 30703790        vmlinux-vanilla.o
         25500922        4386532  808388 30695842        vmlinux-new.o
      Co-developed-by: default avatarNadav Amit <namit@vmware.com>
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lore.kernel.org/r/20231004192404.31733-1-ubizjak@gmail.com
      ca425634
    • Nadav Amit's avatar
      x86/percpu: Use compiler segment prefix qualifier · 9a462b9e
      Nadav Amit authored
      Using a segment prefix qualifier is cleaner than using a segment prefix
      in the inline assembly, and provides the compiler with more information,
      telling it that __seg_gs:[addr] is different than [addr] when it
      analyzes data dependencies. It also enables various optimizations that
      will be implemented in the next patches.
      
      Use segment prefix qualifiers when they are supported. Unfortunately,
      gcc does not provide a way to remove segment qualifiers, which is needed
      to use typeof() to create local instances of the per-CPU variable. For
      this reason, do not use the segment qualifier for per-CPU variables, and
      do casting using the segment qualifier instead.
      
      Uros: Improve compiler support detection and update the patch
      to the current mainline.
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lore.kernel.org/r/20231004145137.86537-4-ubizjak@gmail.com
      9a462b9e
    • Uros Bizjak's avatar
      x86/percpu: Enable named address spaces with known compiler version · 1ca3683c
      Uros Bizjak authored
      Enable named address spaces with known compiler versions
      (GCC 12.1 and later) in order to avoid possible issues with named
      address spaces with older compilers. Set CC_HAS_NAMED_AS when the
      compiler satisfies version requirements and set USE_X86_SEG_SUPPORT
      to signal when segment qualifiers could be used.
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lore.kernel.org/r/20231004145137.86537-3-ubizjak@gmail.com
      1ca3683c
  2. 03 Oct, 2023 1 commit
    • Zhu Wang's avatar
      x86/lib: Address kernel-doc warnings · 8ae292c6
      Zhu Wang authored
      Fix all kernel-doc warnings in csum-wrappers_64.c:
      
        arch/x86/lib/csum-wrappers_64.c:25: warning: Excess function parameter 'isum' description in 'csum_and_copy_from_user'
        arch/x86/lib/csum-wrappers_64.c:25: warning: Excess function parameter 'errp' description in 'csum_and_copy_from_user'
        arch/x86/lib/csum-wrappers_64.c:49: warning: Excess function parameter 'isum' description in 'csum_and_copy_to_user'
        arch/x86/lib/csum-wrappers_64.c:49: warning: Excess function parameter 'errp' description in 'csum_and_copy_to_user'
        arch/x86/lib/csum-wrappers_64.c:71: warning: Excess function parameter 'sum' description in 'csum_partial_copy_nocheck'
      Signed-off-by: default avatarZhu Wang <wangzhu9@huawei.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: linux-kernel@vger.kernel.org
      8ae292c6
  3. 27 Sep, 2023 2 commits
  4. 22 Sep, 2023 1 commit
    • Ingo Molnar's avatar
      x86/bitops: Remove unused __sw_hweight64() assembly implementation on x86-32 · ad424743
      Ingo Molnar authored
      Header cleanups in the fast-headers tree highlighted that we have an
      unused assembly implementation for __sw_hweight64():
      
          WARNING: modpost: EXPORT symbol "__sw_hweight64" [vmlinux] version ...
      
      __arch_hweight64() on x86-32 is defined in the
      arch/x86/include/asm/arch_hweight.h header as an inline, using
      __arch_hweight32():
      
        #ifdef CONFIG_X86_32
        static inline unsigned long __arch_hweight64(__u64 w)
        {
                return  __arch_hweight32((u32)w) +
                        __arch_hweight32((u32)(w >> 32));
        }
      
      *But* there's also a __sw_hweight64() assembly implementation:
      
        arch/x86/lib/hweight.S
      
        SYM_FUNC_START(__sw_hweight64)
        #ifdef CONFIG_X86_64
        ...
        #else /* CONFIG_X86_32 */
              /* We're getting an u64 arg in (%eax,%edx): unsigned long hweight64(__u64 w) */
              pushl   %ecx
      
              call    __sw_hweight32
              movl    %eax, %ecx                      # stash away result
              movl    %edx, %eax                      # second part of input
              call    __sw_hweight32
              addl    %ecx, %eax                      # result
      
              popl    %ecx
              ret
        #endif
      
      But this __sw_hweight64 assembly implementation is unused - and it's
      essentially doing the same thing that the inline wrapper does.
      
      Remove the assembly version and add a comment about it.
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: linux-kernel@vger.kernel.org
      ad424743
  5. 21 Sep, 2023 1 commit
    • Uros Bizjak's avatar
      x86/percpu: Do not clobber %rsi in percpu_{try_,}cmpxchg{64,128}_op · 7c097ca5
      Uros Bizjak authored
      The fallback alternative uses %rsi register to manually load pointer
      to the percpu variable before the call to the emulation function.
      This is unoptimal, because the load is hidden from the compiler.
      
      Move the load of %rsi outside inline asm, so the compiler can
      reuse the value. The code in slub.o improves from:
      
          55ac:	49 8b 3c 24          	mov    (%r12),%rdi
          55b0:	48 8d 4a 40          	lea    0x40(%rdx),%rcx
          55b4:	49 8b 1c 07          	mov    (%r15,%rax,1),%rbx
          55b8:	4c 89 f8             	mov    %r15,%rax
          55bb:	48 8d 37             	lea    (%rdi),%rsi
          55be:	e8 00 00 00 00       	callq  55c3 <...>
      			55bf: R_X86_64_PLT32	this_cpu_cmpxchg16b_emu-0x4
          55c3:	75 a3                	jne    5568 <...>
          55c5:	...
      
       0000000000000000 <.altinstr_replacement>:
         5:	65 48 0f c7 0f       	cmpxchg16b %gs:(%rdi)
      
      to:
      
          55ac:	49 8b 34 24          	mov    (%r12),%rsi
          55b0:	48 8d 4a 40          	lea    0x40(%rdx),%rcx
          55b4:	49 8b 1c 07          	mov    (%r15,%rax,1),%rbx
          55b8:	4c 89 f8             	mov    %r15,%rax
          55bb:	e8 00 00 00 00       	callq  55c0 <...>
      			55bc: R_X86_64_PLT32	this_cpu_cmpxchg16b_emu-0x4
          55c0:	75 a6                	jne    5568 <...>
          55c2:	...
      
      Where the alternative replacement instruction now uses %rsi:
      
       0000000000000000 <.altinstr_replacement>:
         5:	65 48 0f c7 0e       	cmpxchg16b %gs:(%rsi)
      
      The instruction (effectively a reg-reg move) at 55bb: in the original
      assembly is removed. Also, both the CALL and replacement CMPXCHG16B
      are 5 bytes long, removing the need for NOPs in the asm code.
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230918151452.62344-1-ubizjak@gmail.com
      7c097ca5
  6. 15 Sep, 2023 3 commits
  7. 06 Sep, 2023 1 commit
  8. 04 Sep, 2023 6 commits
    • Linus Torvalds's avatar
      Merge tag 'timers-core-2023-09-04-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 4accdb98
      Linus Torvalds authored
      Pull clocksource/clockevent driver updates from Thomas Gleixner:
      
       - Remove the OXNAS driver instead of adding a new one!
      
       - A set of boring fixes, cleanups and improvements
      
      * tag 'timers-core-2023-09-04-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        clocksource: Explicitly include correct DT includes
        clocksource/drivers/sun5i: Convert to platform device driver
        clocksource/drivers/sun5i: Remove pointless struct
        clocksource/drivers/sun5i: Remove duplication of code and data
        clocksource/drivers/loongson1: Set variable ls1x_timer_lock storage-class-specifier to static
        clocksource/drivers/arm_arch_timer: Disable timer before programming CVAL
        dt-bindings: timer: oxsemi,rps-timer: remove obsolete bindings
        clocksource/drivers/timer-oxnas-rps: Remove obsolete timer driver
      4accdb98
    • Linus Torvalds's avatar
      Merge tag 'm68knommu-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu · 7a1415ee
      Linus Torvalds authored
      Pull m68knommu updates from Greg Ungerer:
       "Two changes, one a trivial white space clean up, the other removes the
        unnecessary local pcibios_setup() code"
      
      * tag 'm68knommu-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
        m68k: coldfire: dma_timer: ERROR: "foo __init bar" should be "foo __init bar"
        m68k/pci: Drop useless pcibios_setup()
      7a1415ee
    • Linus Torvalds's avatar
      Merge tag 'uml-for-linus-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux · 68d76d4e
      Linus Torvalds authored
      Pull UML updates from Richard Weinberger:
      
       - Drop 32-bit checksum implementation and re-use it from arch/x86
      
       - String function cleanup
      
       - Fixes for -Wmissing-variable-declarations and -Wmissing-prototypes
         builds
      
      * tag 'uml-for-linus-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux:
        um: virt-pci: fix missing declaration warning
        um: Refactor deprecated strncpy to memcpy
        um: fix 3 instances of -Wmissing-prototypes
        um: port_kern: fix -Wmissing-variable-declarations
        uml: audio: fix -Wmissing-variable-declarations
        um: vector: refactor deprecated strncpy
        um: use obj-y to descend into arch/um/*/
        um: Hard-code the result of 'uname -s'
        um: Use the x86 checksum implementation on 32-bit
        asm-generic: current: Don't include thread-info.h if building asm
        um: Remove unsued extern declaration ldt_host_info()
        um: Fix hostaudio build errors
        um: Remove strlcpy usage
      68d76d4e
    • Linus Torvalds's avatar
      Merge tag 'hyperv-next-signed-20230902' of... · 0b90c563
      Linus Torvalds authored
      Merge tag 'hyperv-next-signed-20230902' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
      
      Pull hyperv updates from Wei Liu:
      
       - Support for SEV-SNP guests on Hyper-V (Tianyu Lan)
      
       - Support for TDX guests on Hyper-V (Dexuan Cui)
      
       - Use SBRM API in Hyper-V balloon driver (Mitchell Levy)
      
       - Avoid dereferencing ACPI root object handle in VMBus driver (Maciej
         Szmigiero)
      
       - A few misecllaneous fixes (Jiapeng Chong, Nathan Chancellor, Saurabh
         Sengar)
      
      * tag 'hyperv-next-signed-20230902' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: (24 commits)
        x86/hyperv: Remove duplicate include
        x86/hyperv: Move the code in ivm.c around to avoid unnecessary ifdef's
        x86/hyperv: Remove hv_isolation_type_en_snp
        x86/hyperv: Use TDX GHCI to access some MSRs in a TDX VM with the paravisor
        Drivers: hv: vmbus: Bring the post_msg_page back for TDX VMs with the paravisor
        x86/hyperv: Introduce a global variable hyperv_paravisor_present
        Drivers: hv: vmbus: Support >64 VPs for a fully enlightened TDX/SNP VM
        x86/hyperv: Fix serial console interrupts for fully enlightened TDX guests
        Drivers: hv: vmbus: Support fully enlightened TDX guests
        x86/hyperv: Support hypercalls for fully enlightened TDX guests
        x86/hyperv: Add hv_isolation_type_tdx() to detect TDX guests
        x86/hyperv: Fix undefined reference to isolation_type_en_snp without CONFIG_HYPERV
        x86/hyperv: Add missing 'inline' to hv_snp_boot_ap() stub
        hv: hyperv.h: Replace one-element array with flexible-array member
        Drivers: hv: vmbus: Don't dereference ACPI root object handle
        x86/hyperv: Add hyperv-specific handling for VMMCALL under SEV-ES
        x86/hyperv: Add smp support for SEV-SNP guest
        clocksource: hyper-v: Mark hyperv tsc page unencrypted in sev-snp enlightened guest
        x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest
        drivers: hv: Mark percpu hvcall input arg page unencrypted in SEV-SNP enlightened guest
        ...
      0b90c563
    • Linus Torvalds's avatar
      Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost · e4f1b820
      Linus Torvalds authored
      Pull virtio updates from Michael Tsirkin:
       "A small pull request this time around, mostly because the vduse
        network got postponed to next relase so we can be sure we got the
        security store right"
      
      * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
        virtio_ring: fix avail_wrap_counter in virtqueue_add_packed
        virtio_vdpa: build affinity masks conditionally
        virtio_net: merge dma operations when filling mergeable buffers
        virtio_ring: introduce dma sync api for virtqueue
        virtio_ring: introduce dma map api for virtqueue
        virtio_ring: introduce virtqueue_reset()
        virtio_ring: separate the logic of reset/enable from virtqueue_resize
        virtio_ring: correct the expression of the description of virtqueue_resize()
        virtio_ring: skip unmap for premapped
        virtio_ring: introduce virtqueue_dma_dev()
        virtio_ring: support add premapped buf
        virtio_ring: introduce virtqueue_set_dma_premapped()
        virtio_ring: put mapping error check in vring_map_one_sg
        virtio_ring: check use_dma_api before unmap desc for indirect
        vdpa_sim: offer VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK
        vdpa: add get_backend_features vdpa operation
        vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature
        vdpa: add VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK flag
        vdpa/mlx5: Remove unused function declarations
      e4f1b820
    • Linus Torvalds's avatar
      Merge tag 'tomoyo-pr-20230903' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1 · 5c5e0e81
      Linus Torvalds authored
      Pull tomoyo updates from Tetsuo Handa:
       "Three cleanup patches, no behavior changes"
      
      * tag 'tomoyo-pr-20230903' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1:
        tomoyo: remove unused function declaration
        tomoyo: refactor deprecated strncpy
        tomoyo: add format attributes to functions
      5c5e0e81
  9. 03 Sep, 2023 22 commits
    • Yuan Yao's avatar
      virtio_ring: fix avail_wrap_counter in virtqueue_add_packed · 1acfe2c1
      Yuan Yao authored
      In current packed virtqueue implementation, the avail_wrap_counter won't
      flip, in the case when the driver supplies a descriptor chain with a
      length equals to the queue size; total_sg == vq->packed.vring.num.
      
      Let’s assume the following situation:
      vq->packed.vring.num=4
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 0
      
      Then the driver adds a descriptor chain containing 4 descriptors.
      
      We expect the following result with avail_wrap_counter flipped:
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 1
      
      But, the current implementation gives the following result:
      vq->packed.next_avail_idx: 1
      vq->packed.avail_wrap_counter: 0
      
      To reproduce the bug, you can set a packed queue size as small as
      possible, so that the driver is more likely to provide a descriptor
      chain with a length equal to the packed queue size. For example, in
      qemu run following commands:
      sudo qemu-system-x86_64 \
      -enable-kvm \
      -nographic \
      -kernel "path/to/kernel_image" \
      -m 1G \
      -drive file="path/to/rootfs",if=none,id=disk \
      -device virtio-blk,drive=disk \
      -drive file="path/to/disk_image",if=none,id=rwdisk \
      -device virtio-blk,drive=rwdisk,packed=on,queue-size=4,\
      indirect_desc=off \
      -append "console=ttyS0 root=/dev/vda rw init=/bin/bash"
      
      Inside the VM, create a directory and mount the rwdisk device on it. The
      rwdisk will hang and mount operation will not complete.
      
      This commit fixes the wrap counter error by flipping the
      packed.avail_wrap_counter, when start of descriptor chain equals to the
      end of descriptor chain (head == i).
      
      Fixes: 1ce9e605 ("virtio_ring: introduce packed ring support")
      Signed-off-by: default avatarYuan Yao <yuanyaogoog@chromium.org>
      Message-Id: <20230808051110.3492693-1-yuanyaogoog@chromium.org>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      1acfe2c1
    • Jason Wang's avatar
      virtio_vdpa: build affinity masks conditionally · ae15acea
      Jason Wang authored
      We try to build affinity mask via create_affinity_masks()
      unconditionally which may lead several issues:
      
      - the affinity mask is not used for parent without affinity support
        (only VDUSE support the affinity now)
      - the logic of create_affinity_masks() might not work for devices
        other than block. For example it's not rare in the networking device
        where the number of queues could exceed the number of CPUs. Such
        case breaks the current affinity logic which is based on
        group_cpus_evenly() who assumes the number of CPUs are not less than
        the number of groups. This can trigger a warning[1]:
      
      	if (ret >= 0)
      		WARN_ON(nr_present + nr_others < numgrps);
      
      Fixing this by only build the affinity masks only when
      
      - Driver passes affinity descriptor, driver like virtio-blk can make
        sure to limit the number of queues when it exceeds the number of CPUs
      - Parent support affinity setting config ops
      
      This help to avoid the warning. More optimizations could be done on
      top.
      
      [1]
      [  682.146655] WARNING: CPU: 6 PID: 1550 at lib/group_cpus.c:400 group_cpus_evenly+0x1aa/0x1c0
      [  682.146668] CPU: 6 PID: 1550 Comm: vdpa Not tainted 6.5.0-rc5jason+ #79
      [  682.146671] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
      [  682.146673] RIP: 0010:group_cpus_evenly+0x1aa/0x1c0
      [  682.146676] Code: 4c 89 e0 5b 5d 41 5c 41 5d 41 5e c3 cc cc cc cc e8 1b c4 74 ff 48 89 ef e8 13 ac 98 ff 4c 89 e7 45 31 e4 e8 08 ac 98 ff eb c2 <0f> 0b eb b6 e8 fd 05 c3 00 45 31 e4 eb e5 cc cc cc cc cc cc cc cc
      [  682.146679] RSP: 0018:ffffc9000215f498 EFLAGS: 00010293
      [  682.146682] RAX: 000000000001f1e0 RBX: 0000000000000041 RCX: 0000000000000000
      [  682.146684] RDX: ffff888109922058 RSI: 0000000000000041 RDI: 0000000000000030
      [  682.146686] RBP: ffff888109922058 R08: ffffc9000215f498 R09: ffffc9000215f4a0
      [  682.146687] R10: 00000000000198d0 R11: 0000000000000030 R12: ffff888107e02800
      [  682.146689] R13: 0000000000000030 R14: 0000000000000030 R15: 0000000000000041
      [  682.146692] FS:  00007fef52315740(0000) GS:ffff888237380000(0000) knlGS:0000000000000000
      [  682.146695] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  682.146696] CR2: 00007fef52509000 CR3: 0000000110dbc004 CR4: 0000000000370ee0
      [  682.146698] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  682.146700] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  682.146701] Call Trace:
      [  682.146703]  <TASK>
      [  682.146705]  ? __warn+0x7b/0x130
      [  682.146709]  ? group_cpus_evenly+0x1aa/0x1c0
      [  682.146712]  ? report_bug+0x1c8/0x1e0
      [  682.146717]  ? handle_bug+0x3c/0x70
      [  682.146721]  ? exc_invalid_op+0x14/0x70
      [  682.146723]  ? asm_exc_invalid_op+0x16/0x20
      [  682.146727]  ? group_cpus_evenly+0x1aa/0x1c0
      [  682.146729]  ? group_cpus_evenly+0x15c/0x1c0
      [  682.146731]  create_affinity_masks+0xaf/0x1a0
      [  682.146735]  virtio_vdpa_find_vqs+0x83/0x1d0
      [  682.146738]  ? __pfx_default_calc_sets+0x10/0x10
      [  682.146742]  virtnet_find_vqs+0x1f0/0x370
      [  682.146747]  virtnet_probe+0x501/0xcd0
      [  682.146749]  ? vp_modern_get_status+0x12/0x20
      [  682.146751]  ? get_cap_addr.isra.0+0x10/0xc0
      [  682.146754]  virtio_dev_probe+0x1af/0x260
      [  682.146759]  really_probe+0x1a5/0x410
      
      Fixes: 3dad5682 ("virtio-vdpa: Support interrupt affinity spreading mechanism")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230811091539.1359865-1-jasowang@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      ae15acea
    • Xuan Zhuo's avatar
      virtio_net: merge dma operations when filling mergeable buffers · 295525e2
      Xuan Zhuo authored
      Currently, the virtio core will perform a dma operation for each
      buffer. Although, the same page may be operated multiple times.
      
      This patch, the driver does the dma operation and manages the dma
      address based the feature premapped of virtio core.
      
      This way, we can perform only one dma operation for the pages of the
      alloc frag. This is beneficial for the iommu device.
      
      kernel command line: intel_iommu=on iommu.passthrough=0
      
             |  strict=0  | strict=1
      Before |  775496pps | 428614pps
      After  | 1109316pps | 742853pps
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-13-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      295525e2
    • Xuan Zhuo's avatar
      virtio_ring: introduce dma sync api for virtqueue · 8bd2f710
      Xuan Zhuo authored
      These API has been introduced:
      
      * virtqueue_dma_need_sync
      * virtqueue_dma_sync_single_range_for_cpu
      * virtqueue_dma_sync_single_range_for_device
      
      These APIs can be used together with the premapped mechanism to sync the
      DMA address.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-12-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      8bd2f710
    • Xuan Zhuo's avatar
      virtio_ring: introduce dma map api for virtqueue · b6253b4e
      Xuan Zhuo authored
      Added virtqueue_dma_map_api* to map DMA addresses for virtual memory in
      advance. The purpose is to keep memory mapped across multiple add/get
      buf operations.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-11-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b6253b4e
    • Xuan Zhuo's avatar
      virtio_ring: introduce virtqueue_reset() · ba3e0c47
      Xuan Zhuo authored
      Introduce virtqueue_reset() to release all buffer inside vq.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-10-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      ba3e0c47
    • Xuan Zhuo's avatar
      virtio_ring: separate the logic of reset/enable from virtqueue_resize · ad48d53b
      Xuan Zhuo authored
      The subsequent reset function will reuse these logic.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-9-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      ad48d53b
    • Xuan Zhuo's avatar
      virtio_ring: correct the expression of the description of virtqueue_resize() · 4d09f240
      Xuan Zhuo authored
      Modify the "useless" to a more accurate "unused".
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-8-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      4d09f240
    • Xuan Zhuo's avatar
      virtio_ring: skip unmap for premapped · b319940f
      Xuan Zhuo authored
      Now we add a case where we skip dma unmap, the vq->premapped is true.
      
      We can't just rely on use_dma_api to determine whether to skip the dma
      operation. For convenience, I introduced the "do_unmap". By default, it
      is the same as use_dma_api. If the driver is configured with premapped,
      then do_unmap is false.
      
      So as long as do_unmap is false, for addr of desc, we should skip dma
      unmap operation.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-7-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b319940f
    • Xuan Zhuo's avatar
      virtio_ring: introduce virtqueue_dma_dev() · 2df64759
      Xuan Zhuo authored
      Added virtqueue_dma_dev() to get DMA device for virtio. Then the
      caller can do dma operation in advance. The purpose is to keep memory
      mapped across multiple add/get buf operations.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-6-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      2df64759
    • Xuan Zhuo's avatar
      virtio_ring: support add premapped buf · d7344a2f
      Xuan Zhuo authored
      If the vq is the premapped mode, use the sg_dma_address() directly.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-5-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      d7344a2f
    • Xuan Zhuo's avatar
      virtio_ring: introduce virtqueue_set_dma_premapped() · 8daafe9e
      Xuan Zhuo authored
      This helper allows the driver change the dma mode to premapped mode.
      Under the premapped mode, the virtio core do not do dma mapping
      internally.
      
      This just work when the use_dma_api is true. If the use_dma_api is false,
      the dma options is not through the DMA APIs, that is not the standard
      way of the linux kernel.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Message-Id: <20230810123057.43407-4-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      8daafe9e
    • Xuan Zhuo's avatar
      virtio_ring: put mapping error check in vring_map_one_sg · 0e27fa6d
      Xuan Zhuo authored
      This patch put the dma addr error check in vring_map_one_sg().
      
      The benefits of doing this:
      
      1. reduce one judgment of vq->use_dma_api.
      2. make vring_map_one_sg more simple, without calling
         vring_mapping_error to check the return value. simplifies subsequent
         code
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-3-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      0e27fa6d
    • Xuan Zhuo's avatar
      virtio_ring: check use_dma_api before unmap desc for indirect · 610c708b
      Xuan Zhuo authored
      Inside detach_buf_split(), if use_dma_api is false,
      vring_unmap_one_split_indirect will be called many times, but actually
      nothing is done. So this patch check use_dma_api firstly.
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230810123057.43407-2-xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      610c708b
    • Eugenio Pérez's avatar
      vdpa_sim: offer VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK · 2c9c6371
      Eugenio Pérez authored
      Start offering the feature in the simulator.  Other parent drivers can
      follow this code to offer it too.
      Signed-off-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Acked-by: default avatarShannon Nelson <shannon.nelson@amd.com>
      Message-Id: <20230609092127.170673-5-eperezma@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      2c9c6371
    • Eugenio Pérez's avatar
      vdpa: add get_backend_features vdpa operation · b63e5c70
      Eugenio Pérez authored
      This operation allow vdpa parent to expose its own backend feature bits.
      
      Next patches introduce a feature not compatible with all parent drivers:
      the ability to enable vq after driver_ok.  Each parent must declare if
      it allows it or not.
      Signed-off-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Acked-by: default avatarShannon Nelson <shannon.nelson@amd.com>
      Message-Id: <20230609092127.170673-4-eperezma@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b63e5c70
    • Eugenio Pérez's avatar
      vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature · 9f09fd61
      Eugenio Pérez authored
      Accepting VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature if
      userland sets it.
      Signed-off-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Acked-by: default avatarShannon Nelson <shannon.nelson@amd.com>
      Message-Id: <20230609092127.170673-3-eperezma@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      9f09fd61
    • Eugenio Pérez's avatar
      vdpa: add VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK flag · 8b59b4da
      Eugenio Pérez authored
      This feature flag allows the driver enabling virtqueues both before and
      after DRIVER_OK.
      
      This is needed for software assisted live migration, so userland can
      restore the device status in devices with control virtqueue before the
      dataplane is enabled.
      Signed-off-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Acked-by: default avatarShannon Nelson <shannon.nelson@amd.com>
      Message-Id: <20230609092127.170673-2-eperezma@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      8b59b4da
    • Yue Haibing's avatar
      vdpa/mlx5: Remove unused function declarations · c1081002
      Yue Haibing authored
      Commit 29064bfd ("vdpa/mlx5: Add support library for mlx5 VDPA implementation")
      declared but never implemented these.
      Signed-off-by: default avatarYue Haibing <yuehaibing@huawei.com>
      Message-Id: <20230803143041.23388-1-yuehaibing@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      c1081002
    • Linus Torvalds's avatar
      Merge tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine · 708283ab
      Linus Torvalds authored
      Pull dmaengine updates from Vinod Koul:
       "New controller support and updates to drivers.
      
        New support:
         - Qualcomm SM6115 and QCM2290 dmaengine support
         - at_xdma support for microchip,sam9x7 controller
      
        Updates:
         - idxd updates for wq simplification and ats knob updates
         - fsl edma updates for v3 support
         - Xilinx AXI4-Stream control support
         - Yaml conversion for bcm dma binding"
      
      * tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (53 commits)
        dmaengine: fsl-edma: integrate v3 support
        dt-bindings: fsl-dma: fsl-edma: add edma3 compatible string
        dmaengine: fsl-edma: move tcd into struct fsl_dma_chan
        dmaengine: fsl-edma: refactor chan_name setup and safety
        dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function
        dmaengine: fsl-edma: refactor using devm_clk_get_enabled
        dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()
        dmaengine: fsl-edma: move common IRQ handler to common.c
        dmaengine: fsl-edma: Remove enum edma_version
        dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata
        dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c
        dmaengine: fsl-edma: fix build error when arch is s390
        dmaengine: idxd: Fix issues with PRS disable sysfs knob
        dmaengine: idxd: Allow ATS disable update only for configurable devices
        dmaengine: xilinx_dma: Program interrupt delay timeout
        dmaengine: xilinx_dma: Use tasklet_hi_schedule for timing critical usecase
        dmaengine: xilinx_dma: Freeup active list based on descriptor completion bit
        dmaengine: xilinx_dma: Increase AXI DMA transaction segment count
        dmaengine: xilinx_dma: Pass AXI4-Stream control words to dma client
        dt-bindings: dmaengine: xilinx_dma: Add xlnx,irq-delay property
        ...
      708283ab
    • Linus Torvalds's avatar
      Merge tag 'phy-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy · db906f0c
      Linus Torvalds authored
      Pull phy updates from Vinod Koul:
       "As usual a couple of new drivers, a bunch of new device support and
        few updates to existing drivers
      
        New Support:
         - Starfive dphy rx, JH7110 usb and pcie support
         - Rockchip rv1126 inno-dsi phy, rk3588 usb and pcie support
         - Qualcomm sa8775p PCIe support, M31 USB PHY driver
         - Samsung Exynos850 usb support
      
        Updates:
         - Mediatek dsi driver clock updates
         - Qualcomm sm8150 combo phy with reworking of qmp pcie driver
         - Xilinx zynqmp runtime PM support"
      
      * tag 'phy-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: (83 commits)
        phy: exynos5-usbdrd: Add Exynos850 support
        phy: exynos5-usbdrd: Add 26MHz ref clk support
        phy: exynos5-usbdrd: Make it possible to pass custom phy ops
        dt-bindings: phy: samsung,usb3-drd-phy: Add Exynos850 support
        phy: qcom-qmp-combo: fix clock probing
        phy: qcom-qmp-pcie: support SM8150 PCIe QMP PHYs
        phy: qcom-qmp-pcie: populate offsets configuration
        phy: qcom-qmp-pcie: simplify clock handling
        phy: qcom-qmp-pcie: keep offset tables sorted
        phy: qcom-qmp-pcie: drop ln_shrd from v5_20 config
        dt-bindings: phy: qcom,qmp-pcie: describe SM8150 PCIe PHYs
        dt-bindings: phy: migrate QMP PCIe PHY bindings to qcom,sc8280xp-qmp-pcie-phy.yaml
        phy: fsl-imx8mq-usb: add dev_err_probe if getting vbus failed
        phy: qcom: Introduce M31 USB PHY driver
        dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
        phy: rockchip: inno-dsidphy: Add rv1126 support
        dt-bindings: phy: rockchip-inno-dsidphy: Document rv1126
        dt-bindings: phy: mediatek,tphy: allow simple nodename pattern
        phy: amlogic: meson-g12a-usb2: fix Wvoid-pointer-to-enum-cast warning
        phy: marvell pxa-usb: fix Wvoid-pointer-to-enum-cast warning
        ...
      db906f0c
    • Linus Torvalds's avatar
      Merge tag 'soundwire-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire · 6e32dfcc
      Linus Torvalds authored
      Pull soundwire updates from Vinod Koul:
       "Device numbering and intel driver changes are main features:
      
         - Core support for soundwire device number allocation
      
         - intel driver updates for adding hw_params for DAI ops, hybrid
           number allocation and power managemnt callback updates
      
         - DT header include changes for subsystem"
      
      * tag 'soundwire-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
        soundwire: intel_ace2x: add DAI hw_params/prepare/hw_free callbacks
        soundwire: intel_auxdevice: add hybrid IDA-based device_number allocation
        soundwire: bus: add callbacks for device_number allocation
        soundwire: extend parameters of new_peripheral_assigned() callback
        soundWire: intel_auxdevice: resume 'sdw-master' on startup and system resume
        soundwire: intel_auxdevice: enable pm_runtime earlier on startup
        soundwire: Explicitly include correct DT includes
      6e32dfcc