Skip to content

Conversation

@ljrcore
Copy link

@ljrcore ljrcore commented May 27, 2024

Improve the handling of exit reasons for PVM hypercalls by adding more specific exit reasons based on the type of PVM hypercall. This enables a more fine-grained analysis of the performance and behavior of PVM-based virtual machines.

The new exit reasons cover various PVM hypercall types, including IRQ_WIN, IRQ_HALT, LOAD_PGTBL, TLB_FLUSH, TLB_FLUSH_CURRENT, TLB_INVLPG, LOAD_GS, RDMSR, WRMSR, and LOAD_TLS. Providing specific exit reasons for each of these hypercall types allows for better insights into the performance characteristics of PVM-based virtual machines and helps identify potential areas for optimization.

Moreover, this change benefits performance analysis tools, such as perf, by allowing them to provide more detailed information about the execution of PVM hypercalls. This improvement helps users gain a better understanding of the performance bottlenecks in their virtualized environments and make informed decisions about optimizing their systems.

@bysui
Copy link
Collaborator

bysui commented May 28, 2024

Hi, @ljrcore , thanks for your PR!
Actually, I concur that the current exit reason is too simplistic. I have also added more information when I need more debug information during debugging. However, I would prefer to keep the reason as PVM_EXIT_REASONS_HYPERCALL and instead put the hypercall number into info2. The reason for this is that I believe PVM_EXIT_REASONS_HYPERCALL should be in the same level as other reasons (e.g., PVM_SYSCALL_VECTOR). Then, we can put additional information into info2, as it is a u64 and the hypercall number is allowed to be bigger than a u32 (Although it is not now). Since for hypercall, pvm->exit_error_code is invalid information, we can put the hypercall number here. Additionally, for syscall, we can also put the syscall number into info2, allowing us to trace the guest userspace behavior. However, I am not familiar with the Perf tools. Is it easy for you to use the information in info2 to do the same analysis in Perf? And what do you prefer?

@ljrcore
Copy link
Author

ljrcore commented May 28, 2024

Hi, @ljrcore , thanks for your PR! Actually, I concur that the current exit reason is too simplistic. I have also added more information when I need more debug information during debugging. However, I would prefer to keep the reason as PVM_EXIT_REASONS_HYPERCALL and instead put the hypercall number into info2. The reason for this is that I believe PVM_EXIT_REASONS_HYPERCALL should be in the same level as other reasons (e.g., PVM_SYSCALL_VECTOR). Then, we can put additional information into info2, as it is a u64 and the hypercall number is allowed to be bigger than a u32 (Although it is not now). Since for hypercall, pvm->exit_error_code is invalid information, we can put the hypercall number here. Additionally, for syscall, we can also put the syscall number into info2, allowing us to trace the guest userspace behavior. However, I am not familiar with the Perf tools. Is it easy for you to use the information in info2 to do the same analysis in Perf? And what do you prefer?

Hi, @bysui, thanks for your suggestion. I agree that putting the hypercall number into info2 is a good idea. However, I would like to inform you that I am unable to easily use the information in info2 for the same analysis in Perf. Therefore, could we consider this as a new feature request?

Our main goal at the moment is to fix the issue of perf kvm being unavailable on PVM. Would it be possible to prioritize this issue and make perf kvm work on PVM first, as this feature has minimal impact on PVM?

Once we have addressed the current issue, we can then discuss and implement the improvements you suggested, such as putting the hypercall number and the syscall number into info2 for tracing guest userspace behavior.

@ljrcore ljrcore changed the title KVM: x86/PVM: Enhance exit reason handling for PVM hypercalls Add PVM support for perf kvm May 28, 2024
@ljrcore ljrcore changed the title Add PVM support for perf kvm Add perf kvm support for pvm May 28, 2024
@ljrcore ljrcore changed the title Add perf kvm support for pvm Add perf kvm support for PVM May 28, 2024
@ljrcore
Copy link
Author

ljrcore commented May 28, 2024

How to use:

  • Apply these four patches
  • Compile PVM
  • Compile perf
cd $LINUX_DIR
cd tools/perf
# Install perf required dependencies
make
make install

Validation results:

./perf kvm stat live
# Start the virtual machine

There will be output similar to this:


Analyze events for all VMs, all VCPUs:

                                 VM-EXIT    Samples  Samples%     Time%    Min Time    Max Time         Avg time

                                HC_WRMSR        354    33.94%     1.35%      0.28us  32004.80us    124.96us ( +-  77.21% )
                                   ERETS        197    18.89%     1.59%      0.57us  28004.05us    264.67us ( +-  70.56% )
                                 PF excp        185    17.74%     2.16%      0.79us  35560.46us    382.64us ( +-  69.91% )
                             HC_IRQ_HALT        155    14.86%    94.16%     16.66us 511981.18us  19869.99us ( +-  19.94% )
                               INTERRUPT         42     4.03%     0.72%      0.68us  23397.49us    558.96us ( +-  99.66% )
                                   ERETU         38     3.64%     0.00%      0.46us     16.11us      1.04us ( +-  39.38% )
                                HC_RDMSR         22     2.11%     0.00%      0.34us      0.65us      0.40us ( +-   3.43% )
                                 GP excp         18     1.73%     0.00%      0.61us      1.76us      0.82us ( +-   9.58% )
                           HC_TLB_INVLPG         18     1.73%     0.00%      0.76us     14.11us      4.52us ( +-  24.22% )
                           HC_LOAD_PGTBL          6     0.58%     0.00%      3.21us     13.25us      8.42us ( +-  16.76% )
                              HC_IRQ_WIN          5     0.48%     0.00%      0.67us      0.93us      0.75us ( +-   6.29% )
                    HC_TLB_FLUSH_CURRENT          2     0.19%     0.00%      0.46us      5.52us      2.99us ( +-  84.55% )
                                 SYSCALL          1     0.10%     0.00%      0.62us      0.62us      0.62us ( +-   0.00% )

Total Samples:1043, Total events handled time:3270695.00us.

@ljrcore
Copy link
Author

ljrcore commented May 28, 2024

It is worth mentioning that even with these patches applied, there are still unknowns that require additional fixes when using ./perf kvm --host --guest record -a and ./perf kvm --host --guest report.

Samples: 56K of event 'cpu-clock:ppp', Event count (approx.): 14130000000
Overhead  Command          Shared Object     Symbol
  66.64%  swapper          [kernel.vmlinux]  [k] default_idle
   5.24%  :229235          [unknown]         [u] 0x000000000043cffb
   5.11%  :229235          [unknown]         [u] 0xffffd97f81a01d40
   4.80%  :229236          [unknown]         [g] 0xffffd97f81a01d40
   4.60%  :229236          [unknown]         [g] 0x000000000043cffb
   1.41%  :229237          [unknown]         [g] 0xffffd97f81a01d40
   1.25%  :229237          [unknown]         [g] 0x000000000043cffb
   0.35%  :229238          [unknown]         [g] 0xffffd97f81a01d40
   0.30%  :229238          [unknown]         [g] 0x000000000043cffb
   0.29%  :229236          [unknown]         [g] 0x0000000000400af7
   0.29%  :229235          [unknown]         [u] 0x0000000000400af3
   0.29%  :229235          [unknown]         [u] 0x0000000000400af7
   0.24%  :229236          [unknown]         [g] 0x0000000000400af3
...

@laijs
Copy link

laijs commented May 29, 2024

I don't think arch/x86/include/uapi/asm/pvm.h is part of PVM "architecture" ABI.
Those tracing ABI have been also in arch/x86/include/uapi/asm/pvm.h for several years and then moved into arch/x86/kvm/pvm/pvm.h when the code were made public for the same reason.

I think we can put those tracing ABI to arch/x86/include/uapi/asm/pvm_trace.h instead.


#define SWITCH_EXIT_REASONS_SYSCALL 1024
#define SWITCH_EXIT_REASONS_FAILED_VMETNRY 1025
#include <uapi/asm/pvm.h>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't move this code. It is part of switcher API (linux kernel internal API) rather than any ABI.

SWITCH_EXIT_REASONS_SYSCALL is not used for PVM_EXIT_REASONS. (PVM_EXIT_REASONS_SYSCALL and several other code are used for PVM_EXIT_REASONS rather than SWITCH_EXIT_REASONS_SYSCALL nor PVM_SYSCALL_VECTOR)

pvm_get_syscall_exit_reason() should handle SWITCH_EXIT_REASONS_FAILED_VMETNRY explicitly and assign the reason to a code defined in pvm_trace.h. (arch/x86/include/uapi/asm/pvm.h should be renamed to pvm_trace.h). (SWITCH_EXIT_REASONS_FAILED_VMETNRY might be deleted in future)

@ljrcore
Copy link
Author

ljrcore commented May 31, 2024

Hi, @laijs, thanks for your suggestion. I modified the code as you suggested. Explicitly handle PVM_FAILED_VMENTRY_VECTOR in pvm_get_syscall_exit_reason() and assign the reason to the code defined in pvm_trace.h.

@bysui
Copy link
Collaborator

bysui commented May 31, 2024

Hi, @ljrcore , thanks for your PR! Actually, I concur that the current exit reason is too simplistic. I have also added more information when I need more debug information during debugging. However, I would prefer to keep the reason as PVM_EXIT_REASONS_HYPERCALL and instead put the hypercall number into info2. The reason for this is that I believe PVM_EXIT_REASONS_HYPERCALL should be in the same level as other reasons (e.g., PVM_SYSCALL_VECTOR). Then, we can put additional information into info2, as it is a u64 and the hypercall number is allowed to be bigger than a u32 (Although it is not now). Since for hypercall, pvm->exit_error_code is invalid information, we can put the hypercall number here. Additionally, for syscall, we can also put the syscall number into info2, allowing us to trace the guest userspace behavior. However, I am not familiar with the Perf tools. Is it easy for you to use the information in info2 to do the same analysis in Perf? And what do you prefer?

Hi, @bysui, thanks for your suggestion. I agree that putting the hypercall number into info2 is a good idea. However, I would like to inform you that I am unable to easily use the information in info2 for the same analysis in Perf. Therefore, could we consider this as a new feature request?

Our main goal at the moment is to fix the issue of perf kvm being unavailable on PVM. Would it be possible to prioritize this issue and make perf kvm work on PVM first, as this feature has minimal impact on PVM?

If the current goal is to enable "perf kvm stat" for PVM, then I understand that exporting the exit reason information to userspace and allowing perf to parse it would be sufficient. My concern is that the hypercall number and exit reason number are not the same thing, mainly in terms of number allocation, so we cannot directly use the hypercall number as the exit reason number. If we need to differentiate the hypercall, then we may need to convert each hypercall number into a new exit reason number. This may become part of the PVM ABI. Additionally, in VMX, the hypercall (VMCALL) also does not differentiate specific hypercall numbers. Therefore, if we want to differentiate, we should use a uniform method to achieve this.

Once we have addressed the current issue, we can then discuss and implement the improvements you suggested, such as putting the hypercall number and the syscall number into info2 for tracing guest userspace behavior.

Actually, I believe perf kvm isn't fully utilizing the information provided by the kvm_exit() tracepoint. I can see that there are other tools, such as kvmon; maybe we can extend perf kvm tools like it. Additionally, I have noticed that the community is more likely to use eBPF for statistics rather than tracepoints.

analyzing-kvm-hypercalls-with-ebpf-tracing
PATCH v2 0/4 KVM: x86: tracepoint updates

@ljrcore
Copy link
Author

ljrcore commented Jun 3, 2024

Hi, @ljrcore , thanks for your PR! Actually, I concur that the current exit reason is too simplistic. I have also added more information when I need more debug information during debugging. However, I would prefer to keep the reason as PVM_EXIT_REASONS_HYPERCALL and instead put the hypercall number into info2. The reason for this is that I believe PVM_EXIT_REASONS_HYPERCALL should be in the same level as other reasons (e.g., PVM_SYSCALL_VECTOR). Then, we can put additional information into info2, as it is a u64 and the hypercall number is allowed to be bigger than a u32 (Although it is not now). Since for hypercall, pvm->exit_error_code is invalid information, we can put the hypercall number here. Additionally, for syscall, we can also put the syscall number into info2, allowing us to trace the guest userspace behavior. However, I am not familiar with the Perf tools. Is it easy for you to use the information in info2 to do the same analysis in Perf? And what do you prefer?

Hi, @bysui, thanks for your suggestion. I agree that putting the hypercall number into info2 is a good idea. However, I would like to inform you that I am unable to easily use the information in info2 for the same analysis in Perf. Therefore, could we consider this as a new feature request?
Our main goal at the moment is to fix the issue of perf kvm being unavailable on PVM. Would it be possible to prioritize this issue and make perf kvm work on PVM first, as this feature has minimal impact on PVM?

If the current goal is to enable "perf kvm stat" for PVM, then I understand that exporting the exit reason information to userspace and allowing perf to parse it would be sufficient. My concern is that the hypercall number and exit reason number are not the same thing, mainly in terms of number allocation, so we cannot directly use the hypercall number as the exit reason number. If we need to differentiate the hypercall, then we may need to convert each hypercall number into a new exit reason number. This may become part of the PVM ABI. Additionally, in VMX, the hypercall (VMCALL) also does not differentiate specific hypercall numbers. Therefore, if we want to differentiate, we should use a uniform method to achieve this.

Is it possible to assign the exit reason number of HYPERCALL split like this?

#define PVM_EXIT_REASONS_HC_IRQ_WIN		(PVM_EXIT_REASONS_HYPERCALL + 1)
#define PVM_EXIT_REASONS_HC_IRQ_HALT		(PVM_EXIT_REASONS_HYPERCALL + 2)
#define PVM_EXIT_REASONS_HC_LOAD_PGTBL		(PVM_EXIT_REASONS_HYPERCALL + 3)
#define PVM_EXIT_REASONS_HC_TLB_FLUSH		(PVM_EXIT_REASONS_HYPERCALL + 4)
#define PVM_EXIT_REASONS_HC_TLB_FLUSH_CURRENT	(PVM_EXIT_REASONS_HYPERCALL + 5)
#define PVM_EXIT_REASONS_HC_TLB_INVLPG		(PVM_EXIT_REASONS_HYPERCALL + 6)
#define PVM_EXIT_REASONS_HC_LOAD_GS		(PVM_EXIT_REASONS_HYPERCALL + 7)
#define PVM_EXIT_REASONS_HC_RDMSR		(PVM_EXIT_REASONS_HYPERCALL + 8)
#define PVM_EXIT_REASONS_HC_WRMSR		(PVM_EXIT_REASONS_HYPERCALL + 9)
#define PVM_EXIT_REASONS_HC_LOAD_TLS		(PVM_EXIT_REASONS_HYPERCALL + 10)

Do you have any suggestions?

Once we have addressed the current issue, we can then discuss and implement the improvements you suggested, such as putting the hypercall number and the syscall number into info2 for tracing guest userspace behavior.

Actually, I believe perf kvm isn't fully utilizing the information provided by the kvm_exit() tracepoint. I can see that there are other tools, such as kvmon; maybe we can extend perf kvm tools like it. Additionally, I have noticed that the community is more likely to use eBPF for statistics rather than tracepoints.

analyzing-kvm-hypercalls-with-ebpf-tracing PATCH v2 0/4 KVM: x86: tracepoint updates

Thanks for your knowledge. I'll try perf kvm to take advantage of the information provided by the kvm_exit() tracepoint.

Jinrong Liang added 5 commits June 5, 2024 18:58
Add PVM exit reasons for various hypercall scenarios. The
new exit reasons cover various PVM hypercall types, including IRQ_WIN,
IRQ_HALT, LOAD_PGTBL, TLB_FLUSH, TLB_FLUSH_CURRENT, TLB_INVLPG,
LOAD_GS, RDMSR, WRMSR, and LOAD_TLS.

Improve the handling of exit reasons for PVM by adding PVM hypercall
exit reasons. This change benefits performance analysis tools, such as
perf, by allowing them to provide more detailed information about the
execution of PVM hypercalls.

Suggested-by: Like Xu <likexu@tencent.com>
Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Extend pvm_get_exit_info() to provide the exit reason when PVM VM entry
fails. This change improves handling of failed VM entry scenarios, thus
increasing overall robustness and reliability of virtual machines.

Suggested-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Create a new uapi header file, uapi/asm/pvm_trace.h, containing the
PVM_EXIT_REASONS table and associated macros for PVM exit reasons.

This change allows performance analysis tools, such as perf, to utilize
the PVM exit reason macros directly from the uapi header, rather than
redefining them locally.

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Add the pvm_trace.h header files to the tools to provide the necessary
header files for tools that require PVM support, such as perf.

The change should not have any negative impact on the existing tools or
the kernel itself, as it simply makes the header files available for use
by the tools that need them.

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Integrate PVM support into the perf kvm tool to enable performance
analysis for PVM-based workloads.

This change allows users to better understand the behavior and
performance characteristics of their PVM-based workloads, thus
extending the usefulness of the perf tool for a wider range of
virtualization scenarios.

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
@ljrcore
Copy link
Author

ljrcore commented Jun 5, 2024

Thanks for your valuable feedback on my previous patch submission. I've revised the patches accordingly and tested these changes thoroughly.

If you have any further suggestions or need more clarification, please let me know. I look forward to your response and hope these patches can be merged soon.

Thank you for your time and attention.

Best regards

@laijs
Copy link

laijs commented Jun 6, 2024

@ljrcore Thank you for your contribution. We will merge your code into next pvm iteration sending upstream. And since PVM is not yet in the linux tree, the commits might be subjected to be modified/split/squashed and we are trying our best to mark your contribution in the new commits.

@laijs
Copy link

laijs commented Jun 17, 2024

@ljrcore The reason we change commits (modified/split/squashed/rewritted) for next iteration is that PVM is not included in the upstream tree yet. PVM is still being developed and improved, mainly on the switcher code and PIE support and PV mmu. After the code is more mature, we will send V2. There is not time table for it, it might be sent soon for earlier review or procrastinated or bit.

@ljrcore
Copy link
Author

ljrcore commented Jun 17, 2024

@ljrcore The reason we change commits (modified/split/squashed/rewritted) for next iteration is that PVM is not included in the upstream tree yet. PVM is still being developed and improved, mainly on the switcher code and PIE support and PV mmu. After the code is more mature, we will send V2. There is not time table for it, it might be sent soon for earlier review or procrastinated or bit.

Got it.

Thanks

pojntfx pushed a commit to loopholelabs/linux-pvm that referenced this pull request Oct 18, 2024
Validate @smb->WordCount to avoid reading off the end of @smb and thus
causing the following KASAN splat:

  BUG: KASAN: slab-out-of-bounds in smbCalcSize+0x32/0x40 [cifs]
  Read of size 2 at addr ffff88801c024ec5 by task cifsd/1328

  CPU: 1 PID: 1328 Comm: cifsd Not tainted 6.7.0-rc5 virt-pvm#9
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
  rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
  Call Trace:
   <TASK>
   dump_stack_lvl+0x4a/0x80
   print_report+0xcf/0x650
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? __phys_addr+0x46/0x90
   kasan_report+0xd8/0x110
   ? smbCalcSize+0x32/0x40 [cifs]
   ? smbCalcSize+0x32/0x40 [cifs]
   kasan_check_range+0x105/0x1b0
   smbCalcSize+0x32/0x40 [cifs]
   checkSMB+0x162/0x370 [cifs]
   ? __pfx_checkSMB+0x10/0x10 [cifs]
   cifs_handle_standard+0xbc/0x2f0 [cifs]
   ? srso_alias_return_thunk+0x5/0xfbef5
   cifs_demultiplex_thread+0xed1/0x1360 [cifs]
   ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? lockdep_hardirqs_on_prepare+0x136/0x210
   ? __pfx_lock_release+0x10/0x10
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? mark_held_locks+0x1a/0x90
   ? lockdep_hardirqs_on_prepare+0x136/0x210
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? __kthread_parkme+0xce/0xf0
   ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
   kthread+0x18d/0x1d0
   ? kthread+0xdb/0x1d0
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x34/0x60
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x1b/0x30
   </TASK>

This fixes CVE-2023-6606.

Reported-by: j51569436@gmail.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218218
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
bboymimi pushed a commit to bboymimi/linux that referenced this pull request Jul 25, 2025
[ Upstream commit eedf3e3 ]

ACPICA commit 1c28da2242783579d59767617121035dafba18c3

This was originally done in NetBSD:
NetBSD/src@b69d1ac
and is the correct alternative to the smattering of `memcpy`s I
previously contributed to this repository.

This also sidesteps the newly strict checks added in UBSAN:
llvm/llvm-project@7926744

Before this change we see the following UBSAN stack trace in Fuchsia:

  #0    0x000021afcfdeca5e in acpi_rs_get_address_common(struct acpi_resource*, union aml_resource*) ../../third_party/acpica/source/components/resources/rsaddr.c:329 <platform-bus-x86.so>+0x6aca5e
  virt-pvm#1.2  0x000021982bc4af3c in ubsan_get_stack_trace() compiler-rt/lib/ubsan/ubsan_diag.cpp:41 <libclang_rt.asan.so>+0x41f3c
  virt-pvm#1.1  0x000021982bc4af3c in maybe_print_stack_trace() compiler-rt/lib/ubsan/ubsan_diag.cpp:51 <libclang_rt.asan.so>+0x41f3c
  virt-pvm#1    0x000021982bc4af3c in ~scoped_report() compiler-rt/lib/ubsan/ubsan_diag.cpp:395 <libclang_rt.asan.so>+0x41f3c
  virt-pvm#2    0x000021982bc4bb6f in handletype_mismatch_impl() compiler-rt/lib/ubsan/ubsan_handlers.cpp:137 <libclang_rt.asan.so>+0x42b6f
  virt-pvm#3    0x000021982bc4b723 in __ubsan_handle_type_mismatch_v1 compiler-rt/lib/ubsan/ubsan_handlers.cpp:142 <libclang_rt.asan.so>+0x42723
  virt-pvm#4    0x000021afcfdeca5e in acpi_rs_get_address_common(struct acpi_resource*, union aml_resource*) ../../third_party/acpica/source/components/resources/rsaddr.c:329 <platform-bus-x86.so>+0x6aca5e
  virt-pvm#5    0x000021afcfdf2089 in acpi_rs_convert_aml_to_resource(struct acpi_resource*, union aml_resource*, struct acpi_rsconvert_info*) ../../third_party/acpica/source/components/resources/rsmisc.c:355 <platform-bus-x86.so>+0x6b2089
  virt-pvm#6    0x000021afcfded169 in acpi_rs_convert_aml_to_resources(u8*, u32, u32, u8, void**) ../../third_party/acpica/source/components/resources/rslist.c:137 <platform-bus-x86.so>+0x6ad169
  virt-pvm#7    0x000021afcfe2d24a in acpi_ut_walk_aml_resources(struct acpi_walk_state*, u8*, acpi_size, acpi_walk_aml_callback, void**) ../../third_party/acpica/source/components/utilities/utresrc.c:237 <platform-bus-x86.so>+0x6ed24a
  virt-pvm#8    0x000021afcfde66b7 in acpi_rs_create_resource_list(union acpi_operand_object*, struct acpi_buffer*) ../../third_party/acpica/source/components/resources/rscreate.c:199 <platform-bus-x86.so>+0x6a66b7
  virt-pvm#9    0x000021afcfdf6979 in acpi_rs_get_method_data(acpi_handle, const char*, struct acpi_buffer*) ../../third_party/acpica/source/components/resources/rsutils.c:770 <platform-bus-x86.so>+0x6b6979
  virt-pvm#10   0x000021afcfdf708f in acpi_walk_resources(acpi_handle, char*, acpi_walk_resource_callback, void*) ../../third_party/acpica/source/components/resources/rsxface.c:731 <platform-bus-x86.so>+0x6b708f
  virt-pvm#11   0x000021afcfa95dcf in acpi::acpi_impl::walk_resources(acpi::acpi_impl*, acpi_handle, const char*, acpi::Acpi::resources_callable) ../../src/devices/board/lib/acpi/acpi-impl.cc:41 <platform-bus-x86.so>+0x355dcf
  virt-pvm#12   0x000021afcfaa8278 in acpi::device_builder::gather_resources(acpi::device_builder*, acpi::Acpi*, fidl::any_arena&, acpi::Manager*, acpi::device_builder::gather_resources_callback) ../../src/devices/board/lib/acpi/device-builder.cc:84 <platform-bus-x86.so>+0x368278
  virt-pvm#13   0x000021afcfbddb87 in acpi::Manager::configure_discovered_devices(acpi::Manager*) ../../src/devices/board/lib/acpi/manager.cc:75 <platform-bus-x86.so>+0x49db87
  virt-pvm#14   0x000021afcf99091d in publish_acpi_devices(acpi::Manager*, zx_device_t*, zx_device_t*) ../../src/devices/board/drivers/x86/acpi-nswalk.cc:95 <platform-bus-x86.so>+0x25091d
  virt-pvm#15   0x000021afcf9c1d4e in x86::X86::do_init(x86::X86*) ../../src/devices/board/drivers/x86/x86.cc:60 <platform-bus-x86.so>+0x281d4e
  virt-pvm#16   0x000021afcf9e33ad in λ(x86::X86::ddk_init::(anon class)*) ../../src/devices/board/drivers/x86/x86.cc:77 <platform-bus-x86.so>+0x2a33ad
  virt-pvm#17   0x000021afcf9e313e in fit::internal::target<(lambda at../../src/devices/board/drivers/x86/x86.cc:76:19), false, false, std::__2::allocator<std::byte>, void>::invoke(void*) ../../sdk/lib/fit/include/lib/fit/internal/function.h:183 <platform-bus-x86.so>+0x2a313e
  virt-pvm#18   0x000021afcfbab4c7 in fit::internal::function_base<16UL, false, void(), std::__2::allocator<std::byte>>::invoke(const fit::internal::function_base<16UL, false, void (), std::__2::allocator<std::byte> >*) ../../sdk/lib/fit/include/lib/fit/internal/function.h:522 <platform-bus-x86.so>+0x46b4c7
  virt-pvm#19   0x000021afcfbab342 in fit::function_impl<16UL, false, void(), std::__2::allocator<std::byte>>::operator()(const fit::function_impl<16UL, false, void (), std::__2::allocator<std::byte> >*) ../../sdk/lib/fit/include/lib/fit/function.h:315 <platform-bus-x86.so>+0x46b342
  virt-pvm#20   0x000021afcfcd98c3 in async::internal::retained_task::Handler(async_dispatcher_t*, async_task_t*, zx_status_t) ../../sdk/lib/async/task.cc:24 <platform-bus-x86.so>+0x5998c3
  virt-pvm#21   0x00002290f9924616 in λ(const driver_runtime::Dispatcher::post_task::(anon class)*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, zx_status_t) ../../src/devices/bin/driver_runtime/dispatcher.cc:789 <libdriver_runtime.so>+0x10a616
  torvalds#22   0x00002290f9924323 in fit::internal::target<(lambda at../../src/devices/bin/driver_runtime/dispatcher.cc:788:7), true, false, std::__2::allocator<std::byte>, void, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request>>, int>::invoke(void*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, int) ../../sdk/lib/fit/include/lib/fit/internal/function.h:128 <libdriver_runtime.so>+0x10a323
  torvalds#23   0x00002290f9904b76 in fit::internal::function_base<24UL, true, void(std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request>>, int), std::__2::allocator<std::byte>>::invoke(const fit::internal::function_base<24UL, true, void (std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, int), std::__2::allocator<std::byte> >*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, int) ../../sdk/lib/fit/include/lib/fit/internal/function.h:522 <libdriver_runtime.so>+0xeab76
  torvalds#24   0x00002290f9904831 in fit::callback_impl<24UL, true, void(std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request>>, int), std::__2::allocator<std::byte>>::operator()(fit::callback_impl<24UL, true, void (std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, int), std::__2::allocator<std::byte> >*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, int) ../../sdk/lib/fit/include/lib/fit/function.h:471 <libdriver_runtime.so>+0xea831
  torvalds#25   0x00002290f98d5adc in driver_runtime::callback_request::Call(driver_runtime::callback_request*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >, zx_status_t) ../../src/devices/bin/driver_runtime/callback_request.h:74 <libdriver_runtime.so>+0xbbadc
  torvalds#26   0x00002290f98e1e58 in driver_runtime::Dispatcher::dispatch_callback(driver_runtime::Dispatcher*, std::__2::unique_ptr<driver_runtime::callback_request, std::__2::default_delete<driver_runtime::callback_request> >) ../../src/devices/bin/driver_runtime/dispatcher.cc:1248 <libdriver_runtime.so>+0xc7e58
  torvalds#27   0x00002290f98e4159 in driver_runtime::Dispatcher::dispatch_callbacks(driver_runtime::Dispatcher*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../src/devices/bin/driver_runtime/dispatcher.cc:1308 <libdriver_runtime.so>+0xca159
  torvalds#28   0x00002290f9918414 in λ(const driver_runtime::Dispatcher::create_with_adder::(anon class)*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../src/devices/bin/driver_runtime/dispatcher.cc:353 <libdriver_runtime.so>+0xfe414
  torvalds#29   0x00002290f991812d in fit::internal::target<(lambda at../../src/devices/bin/driver_runtime/dispatcher.cc:351:7), true, false, std::__2::allocator<std::byte>, void, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter>>, fbl::ref_ptr<driver_runtime::Dispatcher>>::invoke(void*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../sdk/lib/fit/include/lib/fit/internal/function.h:128 <libdriver_runtime.so>+0xfe12d
  torvalds#30   0x00002290f9906fc7 in fit::internal::function_base<8UL, true, void(std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter>>, fbl::ref_ptr<driver_runtime::Dispatcher>), std::__2::allocator<std::byte>>::invoke(const fit::internal::function_base<8UL, true, void (std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>), std::__2::allocator<std::byte> >*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../sdk/lib/fit/include/lib/fit/internal/function.h:522 <libdriver_runtime.so>+0xecfc7
  torvalds#31   0x00002290f9906c66 in fit::function_impl<8UL, true, void(std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter>>, fbl::ref_ptr<driver_runtime::Dispatcher>), std::__2::allocator<std::byte>>::operator()(const fit::function_impl<8UL, true, void (std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>), std::__2::allocator<std::byte> >*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../sdk/lib/fit/include/lib/fit/function.h:315 <libdriver_runtime.so>+0xecc66
  torvalds#32   0x00002290f98e73d9 in driver_runtime::Dispatcher::event_waiter::invoke_callback(driver_runtime::Dispatcher::event_waiter*, std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, fbl::ref_ptr<driver_runtime::Dispatcher>) ../../src/devices/bin/driver_runtime/dispatcher.h:543 <libdriver_runtime.so>+0xcd3d9
  torvalds#33   0x00002290f98e700d in driver_runtime::Dispatcher::event_waiter::handle_event(std::__2::unique_ptr<driver_runtime::Dispatcher::event_waiter, std::__2::default_delete<driver_runtime::Dispatcher::event_waiter> >, async_dispatcher_t*, async::wait_base*, zx_status_t, zx_packet_signal_t const*) ../../src/devices/bin/driver_runtime/dispatcher.cc:1442 <libdriver_runtime.so>+0xcd00d
  torvalds#34   0x00002290f9918983 in async_loop_owned_event_handler<driver_runtime::Dispatcher::event_waiter>::handle_event(async_loop_owned_event_handler<driver_runtime::Dispatcher::event_waiter>*, async_dispatcher_t*, async::wait_base*, zx_status_t, zx_packet_signal_t const*) ../../src/devices/bin/driver_runtime/async_loop_owned_event_handler.h:59 <libdriver_runtime.so>+0xfe983
  torvalds#35   0x00002290f9918b9e in async::wait_method<async_loop_owned_event_handler<driver_runtime::Dispatcher::event_waiter>, &async_loop_owned_event_handler<driver_runtime::Dispatcher::event_waiter>::handle_event>::call_handler(async_dispatcher_t*, async_wait_t*, zx_status_t, zx_packet_signal_t const*) ../../sdk/lib/async/include/lib/async/cpp/wait.h:201 <libdriver_runtime.so>+0xfeb9e
  torvalds#36   0x00002290f99bf509 in async_loop_dispatch_wait(async_loop_t*, async_wait_t*, zx_status_t, zx_packet_signal_t const*) ../../sdk/lib/async-loop/loop.c:394 <libdriver_runtime.so>+0x1a5509
  torvalds#37   0x00002290f99b9958 in async_loop_run_once(async_loop_t*, zx_time_t) ../../sdk/lib/async-loop/loop.c:343 <libdriver_runtime.so>+0x19f958
  torvalds#38   0x00002290f99b9247 in async_loop_run(async_loop_t*, zx_time_t, _Bool) ../../sdk/lib/async-loop/loop.c:301 <libdriver_runtime.so>+0x19f247
  torvalds#39   0x00002290f99ba962 in async_loop_run_thread(void*) ../../sdk/lib/async-loop/loop.c:860 <libdriver_runtime.so>+0x1a0962
  torvalds#40   0x000041afd176ef30 in start_c11(void*) ../../zircon/third_party/ulib/musl/pthread/pthread_create.c:63 <libc.so>+0x84f30
  torvalds#41   0x000041afd18a448d in thread_trampoline(uintptr_t, uintptr_t) ../../zircon/system/ulib/runtime/thread.cc:100 <libc.so>+0x1ba48d

Link: acpica/acpica@1c28da22
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/4664267.LvFx2qVVIh@rjwysocki.net
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
[ rjw: Pick up the tag from Tamir ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
bboymimi pushed a commit to bboymimi/linux that referenced this pull request Jul 25, 2025
[ Upstream commit 6c7ffc9 ]

Remove redundant netif_napi_del() call from disconnect path.

A WARN may be triggered in __netif_napi_del_locked() during USB device
disconnect:

  WARNING: CPU: 0 PID: 11 at net/core/dev.c:7417 __netif_napi_del_locked+0x2b4/0x350

This happens because netif_napi_del() is called in the disconnect path while
NAPI is still enabled. However, it is not necessary to call netif_napi_del()
explicitly, since unregister_netdev() will handle NAPI teardown automatically
and safely. Removing the redundant call avoids triggering the warning.

Full trace:
 lan78xx 1-1:1.0 enu1: Failed to read register index 0x000000c4. ret = -ENODEV
 lan78xx 1-1:1.0 enu1: Failed to set MAC down with error -ENODEV
 lan78xx 1-1:1.0 enu1: Link is Down
 lan78xx 1-1:1.0 enu1: Failed to read register index 0x00000120. ret = -ENODEV
 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 11 at net/core/dev.c:7417 __netif_napi_del_locked+0x2b4/0x350
 Modules linked in: flexcan can_dev fuse
 CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted 6.16.0-rc2-00624-ge926949dab03 virt-pvm#9 PREEMPT
 Hardware name: SKOV IMX8MP CPU revC - bd500 (DT)
 Workqueue: usb_hub_wq hub_event
 pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : __netif_napi_del_locked+0x2b4/0x350
 lr : __netif_napi_del_locked+0x7c/0x350
 sp : ffffffc085b673c0
 x29: ffffffc085b673c0 x28: ffffff800b7f2000 x27: ffffff800b7f20d8
 x26: ffffff80110bcf58 x25: ffffff80110bd978 x24: 1ffffff0022179eb
 x23: ffffff80110bc000 x22: ffffff800b7f5000 x21: ffffff80110bc000
 x20: ffffff80110bcf38 x19: ffffff80110bcf28 x18: dfffffc000000000
 x17: ffffffc081578940 x16: ffffffc08284cee0 x15: 0000000000000028
 x14: 0000000000000006 x13: 0000000000040000 x12: ffffffb0022179e8
 x11: 1ffffff0022179e7 x10: ffffffb0022179e7 x9 : dfffffc000000000
 x8 : 0000004ffdde8619 x7 : ffffff80110bcf3f x6 : 0000000000000001
 x5 : ffffff80110bcf38 x4 : ffffff80110bcf38 x3 : 0000000000000000
 x2 : 0000000000000000 x1 : 1ffffff0022179e7 x0 : 0000000000000000
 Call trace:
  __netif_napi_del_locked+0x2b4/0x350 (P)
  lan78xx_disconnect+0xf4/0x360
  usb_unbind_interface+0x158/0x718
  device_remove+0x100/0x150
  device_release_driver_internal+0x308/0x478
  device_release_driver+0x1c/0x30
  bus_remove_device+0x1a8/0x368
  device_del+0x2e0/0x7b0
  usb_disable_device+0x244/0x540
  usb_disconnect+0x220/0x758
  hub_event+0x105c/0x35e0
  process_one_work+0x760/0x17b0
  worker_thread+0x768/0xce8
  kthread+0x3bc/0x690
  ret_from_fork+0x10/0x20
 irq event stamp: 211604
 hardirqs last  enabled at (211603): [<ffffffc0828cc9ec>] _raw_spin_unlock_irqrestore+0x84/0x98
 hardirqs last disabled at (211604): [<ffffffc0828a9a84>] el1_dbg+0x24/0x80
 softirqs last  enabled at (211296): [<ffffffc080095f10>] handle_softirqs+0x820/0xbc8
 softirqs last disabled at (210993): [<ffffffc080010288>] __do_softirq+0x18/0x20
 ---[ end trace 0000000000000000 ]---
 lan78xx 1-1:1.0 enu1: failed to kill vid 0081/0

Fixes: ec4c7e1 ("lan78xx: Introduce NAPI polling support")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20250627051346.276029-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants