Skip to content

rust: workqueue: fix safety comments in WorkItemPointer for Pin<KBox>#1235

Open
zanni098 wants to merge 1 commit into
Rust-for-Linux:rust-nextfrom
zanni098:fix-workqueue-safety-comments
Open

rust: workqueue: fix safety comments in WorkItemPointer for Pin<KBox>#1235
zanni098 wants to merge 1 commit into
Rust-for-Linux:rust-nextfrom
zanni098:fix-workqueue-safety-comments

Conversation

@zanni098
Copy link
Copy Markdown

@zanni098 zanni098 commented May 8, 2026

The safety comments in the impl WorkItemPointer for Pin incorrectly
refer to Arc when they should refer to KBox, since this implementation uses
KBox instead of Arc.

Fix the safety comments to properly reference KBox.

Suggested-by: onur-ozkan onur-ozkan@users.noreply.github.com
Link: #1233

This patch follows the kernel contribution guidelines and is signed off
under the Developer's Certificate of Origin.

Darksonn pushed a commit to Darksonn/linux that referenced this pull request May 30, 2026
…Rust-for-Linux#1235)

Hygon Family 18h CPUs are derived from AMD Family 17h (Zen1) silicon and
share the same erratum Rust-for-Linux#1235: hardware may read a stale IsRunning=1 bit
during ICR write emulation and silently fail to generate an
AVIC_IPI_FAILURE_TARGET_NOT_RUNNING VM-Exit on the sending vCPU.

The absence of the VM-Exit causes KVM to miss the required wakeup of
blocking target vCPUs, leading to hung vCPUs and unbounded delays in
guest execution.

Extend the existing AMD Family 17h erratum Rust-for-Linux#1235 workaround to also cover
Hygon Family 18h.  With IPI virtualization disabled, KVM never sets
IsRunning=1 in the Physical ID table, so every non-self IPI generates a
VM-Exit and is correctly emulated.

Fixes: 8de4a1c ("KVM: SVM: Disable (x2)AVIC IPI virtualization if CPU has erratum Rust-for-Linux#1235")
Cc: <stable@vger.kernel.org>
Signed-off-by: Tina Zhang <zhang_wei@open-hieco.net>
Message-ID: <20260522040014.3380201-1-zhang_wei@open-hieco.net>
Darksonn pushed a commit to Darksonn/linux that referenced this pull request May 30, 2026
Pull kvm fixes from Paolo Bonzini:
 "arm64:

   - Fix ITS EventID sanitisation when restoring an interrupt
     translation table.

   - Fix PPI memory leak when failing to initialise a vcpu.

   - Correctly return an error when the validation of a hypervisor trace
     descriptor fails, and limit this validation to protected mode only.

  RISC-V:

   - Fix invalid HVA warning in steal-time recording

   - Return SBI_ERR_FAILURE to guest upon OOM in pmu_event_info() and
     pmu_snapshot_set_shmem()

   - Fix NULL pointer dereference in SBI v0.1 SEND_IPI handler

   - Fix sign extension of value for MMIO loads

  s390:

   - Fix bugs in vSIE (nested virtualization) and UCONTROL, caused by
     the page table rewrite.

  x86:

   - Apply erratum Rust-for-Linux#1235 workaround (disable AVIC IPI virtualization) on
     Hygon Family 18h, just like on AMD Family 17h.

   - When KVM_CAP_X86_APIC_BUS_CYCLES_NS is queried on a specific VM,
     return the VM's configured APIC bus frequency instead of the
     default. This is less confusing (read: not wrong) and makes it
     easier to fill in CPUID information that communicates the APIC bus
     frequency to the guest.

  Selftests:

   - Do not include glibc-internal <bits/endian.h>; it worked by chance
     and broke building KVM selftests with musl"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: SVM: Disable AVIC IPI virtualization on Hygon Family 18h (erratum Rust-for-Linux#1235)
  KVM: selftests: Verify that KVM returns the configured APIC cycle length
  KVM: x86: Return the VM's configured APIC bus frequency when queried
  KVM: selftests: elf: Include <endian.h> instead of <bits/endian.h>
  KVM: s390: Properly reset zero bit in PGSTE
  KVM: s390: vsie: Fix redundant rmap entries
  KVM: s390: vsie: Fix unshadowing logic
  KVM: s390: Fix leaking kvm_s390_mmu_cache in case of errors
  KVM: s390: vsie: Fix memory leak when unshadowing
  KVM: arm64: Fix nVHE/pKVM hyp tracing error on invalid desc
  KVM: arm64: vgic: Free private_irqs when init fails after allocation
  KVM: arm64: vgic-its: Reject restored DTE with out-of-range num_eventid_bits
  RISC-V: KVM: Fix sign extension for MMIO loads
  RISC-V: KVM: Fix NULL pointer dereference in SBI v0.1 SEND_IPI handler
  riscv: kvm: return SBI_ERR_FAILURE for pmu_event_info() when OOM
  riscv: kvm: return SBI_ERR_FAILURE for pmu_snapshot_set_shmem() when OOM
  RISC-V: KVM: Fix invalid HVA warning in steal-time recording
The safety comments in the `WorkItemPointer` implementation for
`Pin<KBox<T>>` incorrectly refer to `Arc::into_raw`. This implementation
uses `KBox`, not `Arc`; the comments were copied from the `Arc`
implementation. The pointer recovered in `run()` originates from
`KBox::into_raw` in the corresponding `__enqueue`, so correct the
comments to refer to `KBox`.

Suggested-by: onur-ozkan <onur-ozkan@users.noreply.github.com>
Link: Rust-for-Linux#1233
Signed-off-by: zanni098 <zuhaibkhann098@gmail.com>
@zanni098 zanni098 force-pushed the fix-workqueue-safety-comments branch from 75ef998 to 4d3b7a6 Compare June 3, 2026 18:57
@zanni098 zanni098 changed the base branch from rust to rust-next June 3, 2026 18:57
@zanni098
Copy link
Copy Markdown
Author

zanni098 commented Jun 3, 2026

Cleaned up this PR. It previously had a broken branch: it was based on a divergent point and the diff against the base contained 300+ unrelated files (including foreign ksmbd commits), so it showed an empty/conflicting change.

What changed:

  • Re-cut as a single clean commit containing only the intended fix to rust/kernel/workqueue.rs (+2/-2).
  • Retargeted the base to rust-next, where the impl WorkItemPointer for Pin<KBox<T>> actually lives. The old rust base branch carries a much older workqueue.rs that has no Pin<KBox> impl at all, so the patch could never have applied there.
  • The two SAFETY comments in run() that referred to Arc::into_raw now correctly refer to KBox::into_raw, matching the KBox::into_raw call in the corresponding __enqueue.
  • Commit carries Suggested-by:, Link: to safety comments refer to incorrect type in impl WorkItemPointer for Pin<KBox<T>> #1233, and a DCO Signed-off-by:.

The PR now shows MERGEABLE with a clean one-file diff.

Note for maintainers: per #1233 this still needs to be submitted as a proper patch to the LKML / rust-for-linux mailing list; this GitHub PR is just the reviewable form of the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant