Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f3150d4
chore(repo): document and start spin migration
shilei-massclouds May 21, 2026
51d48bd
chore(repo): vendor spin crate
shilei-massclouds May 21, 2026
ba40627
chore(repo): replace lazy_static spin backend
shilei-massclouds May 21, 2026
cda3180
feat(axfs-ng-vfs): track VFS locks with ax-kspin
shilei-massclouds May 21, 2026
480ed72
fix(axfs-ng): use irq-safe spin lock for fs registry
shilei-massclouds May 21, 2026
64e3802
fix(axfs-ng-vfs): prefer irq-safe spin locks
shilei-massclouds May 21, 2026
d37b145
fix(ax-net-ng): use ax-kspin for raw socket lock
shilei-massclouds May 21, 2026
849a8c5
fix(starry-kernel): use ax-kspin for timer locks
shilei-massclouds May 21, 2026
f0cb579
fix(starry-kernel): use ax-kspin for netlink locks
shilei-massclouds May 21, 2026
fda85d8
fix(starry-kernel): use ax-kspin for usbfs locks
shilei-massclouds May 21, 2026
782036c
fix(starry-kernel): use ax-kspin for camera locks
shilei-massclouds May 21, 2026
ea04ef2
fix(axvisor): use ax-kspin for global locks
shilei-massclouds May 21, 2026
54eb316
fix(ax-fs): use ax-kspin for filesystem locks
shilei-massclouds May 21, 2026
bb302d2
fix(axplat-dyn): use ax-kspin for driver locks
shilei-massclouds May 21, 2026
8d9c86a
fix(rdrive): use ax-kspin for manager locks
shilei-massclouds May 21, 2026
c62847c
fix(arm-scmi-rs): use ax-kspin for protocol locks
shilei-massclouds May 21, 2026
af3bc5c
fix(ramdisk): use ax-kspin for device state
shilei-massclouds May 21, 2026
69de160
fix(nvme-driver): use ax-kspin for block state
shilei-massclouds May 21, 2026
0430761
fix(rdif-serial): use ax-kspin for shared handles
shilei-massclouds May 21, 2026
20bf558
fix(realtek-rtl8125): use ax-kspin for queue start state
shilei-massclouds May 21, 2026
12cdace
fix(sg2002-tpu): use ax-kspin for shared state
shilei-massclouds May 21, 2026
6bdf963
fix(dma-api): use ax-kspin for buffer pool
shilei-massclouds May 21, 2026
611aa34
fix(ax-driver-net): use ax-kspin for buffer pool
shilei-massclouds May 21, 2026
a119798
fix(axdevice): use ax-kspin for ivc allocator
shilei-massclouds May 21, 2026
5bb446f
fix(axvm): use ax-kspin for vm state
shilei-massclouds May 21, 2026
15c37cd
fix(riscv_vplic): use ax-kspin for irq state
shilei-massclouds May 21, 2026
53054f0
fix(loongarch_vcpu): use ax-kspin for interrupt injection
shilei-massclouds May 21, 2026
f0beabb
fix(arm_vgic): use ax-kspin for interrupt state
shilei-massclouds May 21, 2026
efc489a
fix(crab-usb): use ax-kspin for xhci mutexes
shilei-massclouds May 21, 2026
d1a9666
chore(spin): finish mutex migration notes
shilei-massclouds May 21, 2026
a93a4fb
chore(spin): stop exposing mutex by default
shilei-massclouds May 21, 2026
88f9c67
fix(starry-kernel): make epoll ready queue irq-safe
shilei-massclouds May 22, 2026
af8a9cc
docs(starry-kernel): note epoll ready queue allocation risk
shilei-massclouds May 22, 2026
c41fb54
fix(starry-kernel): use irq-safe locks for epoll state
shilei-massclouds May 22, 2026
0bc4ba9
fix(starry-kernel): use irq-safe locks for tty state
shilei-massclouds May 22, 2026
006372a
fix(ax-fs-ng): use blocking mutexes for filesystem state
shilei-massclouds May 22, 2026
81e7d93
fix(starry-kernel): avoid spin lock in loop cache
shilei-massclouds May 22, 2026
7186a42
fix(axaddrspace): serialize std tests with host mutex
shilei-massclouds May 22, 2026
924feed
fix(starry): avoid atomic-context lock hazards
shilei-massclouds May 22, 2026
8ee9e25
docs(starry): note spin lock follow-up principles
shilei-massclouds May 22, 2026
8f9a5b1
fix(axbuild): map std test lockdep features
shilei-massclouds May 22, 2026
d14e327
fix(starry-kernel): avoid usbfs sleep under spin locks
shilei-massclouds May 22, 2026
1bc07f2
fix(spin): enable mutex feature for external crates
shilei-massclouds May 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 55 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ members = [
"components/scope-local",
"components/someboot",
"components/somehal-macros",
"components/spin",
"components/starry-process",
"components/starry-signal",
"components/starry-vm",
Expand Down Expand Up @@ -371,10 +372,9 @@ schemars = "1.2.1"
toml = "1"
dma-api = { version = "0.7.3", path = "components/dma-api" }
mmio-api = { version = "0.2.2", path = "components/mmio-api" }
lazy_static = { version = "1.5", features = ["spin_no_std"] }
lock_api = { version = "0.4", default-features = false }
log = "0.4"
spin = "0.10"
spin = { version = "0.10", path = "components/spin" }
ostool = { version = "0.18" }
uefi = "0.36"
fdt-edit = "0.2.3"
Expand All @@ -383,3 +383,6 @@ thiserror = { version = "2", default-features = false }
tock-registers = "0.10"
sg200x-bsp = "0.6"
x86 = "0.52"

[patch.crates-io]
spin = { path = "components/spin" }
1 change: 1 addition & 0 deletions components/arm_vgic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ default = []
vgicv3 = []

[dependencies]
ax-kspin.workspace = true
axaddrspace = { workspace = true }
axdevice_base = { workspace = true }
axvisor_api = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion components/arm_vgic/src/v3/gits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

use core::{cell::UnsafeCell, ptr};

use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::PhysAddr;
use axaddrspace::{GuestPhysAddr, GuestPhysAddrRange, HostPhysAddr};
use axdevice_base::BaseDeviceOps;
use axvisor_api::memory::phys_to_virt;
use log::{debug, trace};
use spin::{Mutex, Once};
use spin::Once;

use super::{
registers::*,
Expand Down
2 changes: 1 addition & 1 deletion components/arm_vgic/src/v3/vgicd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,4 @@ impl VGicD {
}

// Todo: move this lock to arceos or axvisor
static GICD_LOCK: spin::Mutex<()> = spin::Mutex::new(());
static GICD_LOCK: ax_kspin::SpinNoIrq<()> = ax_kspin::SpinNoIrq::new(());
3 changes: 2 additions & 1 deletion components/arm_vgic/src/v3/vgicr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

use core::{cell::UnsafeCell, ptr};

use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::PhysAddr;
use axaddrspace::{GuestPhysAddr, GuestPhysAddrRange, HostPhysAddr};
use axdevice_base::BaseDeviceOps;
use axvisor_api::memory::phys_to_virt;
use log::{debug, trace};
use spin::{Mutex, Once};
use spin::Once;

use super::{
registers::*,
Expand Down
2 changes: 1 addition & 1 deletion components/arm_vgic/src/vgic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

use ax_errno::AxResult;
use ax_kspin::SpinNoIrq as Mutex;
use axvisor_api::vmm::current_vcpu_id;
use spin::Mutex;

use crate::{interrupt::VgicInt, registers::GicRegister, vgicd::Vgicd};

Expand Down
2 changes: 1 addition & 1 deletion components/axaddrspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ x86 = "0.52"

[dev-dependencies]
lazy_static = "1.5"
spin = "0.10"
ax-kspin.workspace = true
assert_matches = "1.5.0"
axin = "0.1.0"
10 changes: 5 additions & 5 deletions components/axaddrspace/tests/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// limitations under the License.

use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Mutex;

use ax_memory_addr::{PAGE_SIZE_4K as PAGE_SIZE, PhysAddr, VirtAddr};
use ax_page_table_multiarch::PagingHandler;
use axaddrspace::{AxMmHal, HostPhysAddr, HostVirtAddr};
use lazy_static::lazy_static;
use spin::Mutex;

/// The starting physical address for the simulated memory region in tests.
/// This offset is used to map simulated physical addresses to the `MEMORY` array's virtual address space.
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn mock_hal_test<F, R>(test_fn: F) -> R
where
F: FnOnce() -> R,
{
let _guard = TEST_MUTEX.lock();
let _guard = TEST_MUTEX.lock().unwrap();
MockHal::reset_state();
test_fn()
}
Expand Down Expand Up @@ -170,12 +170,12 @@ impl MockHal {
paddr_usize
);
let offset = paddr_usize - BASE_PADDR;
VirtAddr::from_usize(MEMORY.lock().0.as_ptr() as usize + offset)
VirtAddr::from_usize(MEMORY.lock().unwrap().0.as_ptr() as usize + offset)
}

/// Maps a virtual address (within the test process) back to a simulated physical address.
pub fn mock_virt_to_phys(vaddr: VirtAddr) -> PhysAddr {
let base_virt = MEMORY.lock().0.as_ptr() as usize;
let base_virt = MEMORY.lock().unwrap().0.as_ptr() as usize;
let vaddr_usize = vaddr.as_usize();
assert!(
vaddr_usize >= base_virt && vaddr_usize < base_virt + MEMORY_LEN,
Expand All @@ -199,6 +199,6 @@ impl MockHal {
ALLOC_COUNT.store(0, Ordering::SeqCst);
DEALLOC_COUNT.store(0, Ordering::SeqCst);
// Lock and clear the simulated memory.
MEMORY.lock().0.fill(0); // Fill with zeros to clear any previous test data.
MEMORY.lock().unwrap().0.fill(0); // Fill with zeros to clear any previous test data.
}
}
2 changes: 1 addition & 1 deletion components/axdevice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "Apache-2.0"
[dependencies]
log = "0.4"
cfg-if = "1.0"
spin = "0.10"
ax-kspin.workspace = true

# System independent crates provided by ArceOS.
ax-errno = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion components/axdevice/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use core::ops::Range;
#[cfg(target_arch = "aarch64")]
use arm_vgic::Vgic;
use ax_errno::{AxResult, ax_err};
use ax_kspin::SpinNoIrq as Mutex;
#[cfg(target_arch = "aarch64")]
use ax_memory_addr::PhysAddr;
use ax_memory_addr::is_aligned_4k;
Expand All @@ -30,7 +31,6 @@ use axvmconfig::{EmulatedDeviceConfig, EmulatedDeviceType};
use range_alloc_arceos::RangeAllocator;
#[cfg(target_arch = "riscv64")]
use riscv_vplic::VPlicGlobal;
use spin::Mutex;

use crate::AxVmDeviceConfig;

Expand Down
2 changes: 1 addition & 1 deletion components/axdriver_crates/axdriver_net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ixgbe = ["dep:ixgbe-driver"]

[dependencies]
ax-driver-base = { workspace = true }
ax-kspin.workspace = true
bitflags = "2.9"
fxmac_rs = { workspace = true, optional = true }
ixgbe-driver = { version = "0.1.1-preview.1", optional = true }
log = { workspace = true }
spin = "0.9"
2 changes: 1 addition & 1 deletion components/axdriver_crates/axdriver_net/src/net_buf.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::{boxed::Box, sync::Arc, vec, vec::Vec};
use core::ptr::NonNull;

use spin::Mutex;
use ax_kspin::SpinNoIrq as Mutex;

use crate::{DevError, DevResult};

Expand Down
2 changes: 1 addition & 1 deletion components/axfs-ng-vfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ license = "Apache-2.0"

[dependencies]
ax-errno = { workspace = true }
ax-kspin = { workspace = true }
axpoll = { workspace = true }
bitflags = "2.10"
cfg-if = "1"
hashbrown = "0.16"
inherit-methods-macro = "0.1"
log = "0.4"
smallvec = "1.15"
spin = { version = "0.10", default-features = false, features = ["mutex"] }
2 changes: 1 addition & 1 deletion components/axfs-ng-vfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ pub use types::*;
pub type VfsError = ax_errno::AxError;
pub type VfsResult<T> = Result<T, VfsError>;

use spin::{Mutex, MutexGuard};
use ax_kspin::{SpinNoIrq as Mutex, SpinNoIrqGuard as MutexGuard};
2 changes: 1 addition & 1 deletion components/axfs-ng-vfs/src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Mountpoint {
Arc::new(Self {
root,
location: Mutex::new(location_in_parent),
children: Mutex::default(),
children: Mutex::new(HashMap::default()),
device: DEVICE_COUNTER.fetch_add(1, Ordering::Relaxed),
})
}
Expand Down
4 changes: 2 additions & 2 deletions components/axfs-ng-vfs/src/node/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ impl DirNode {
pub fn new(ops: Arc<dyn DirNodeOps>) -> Self {
Self {
ops,
cache: Mutex::default(),
mountpoint: Mutex::default(),
cache: Mutex::new(DirChildren::default()),
mountpoint: Mutex::new(None),
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/axfs-ng-vfs/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl DirEntry {
node: Node::File(node),
node_type,
reference,
user_data: Mutex::default(),
user_data: Mutex::new(TypeMap::default()),
}))
}

Expand All @@ -253,7 +253,7 @@ impl DirEntry {
node: Node::Dir(node_fn(WeakDirEntry(this.clone()))),
node_type: NodeType::Directory,
reference,
user_data: Mutex::default(),
user_data: Mutex::new(TypeMap::default()),
}))
}

Expand Down
2 changes: 1 addition & 1 deletion components/axfs_crates/axfs_devfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ license = "Apache-2.0"

[dependencies]
ax-fs-vfs.workspace = true
spin = "0.9"
spin = { workspace = true }
log = "0.4"
2 changes: 1 addition & 1 deletion components/axfs_crates/axfs_ramfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ license = "Apache-2.0"

[dependencies]
ax-fs-vfs.workspace = true
spin = "0.9"
spin = { workspace = true }
log = "0.4"
2 changes: 1 addition & 1 deletion components/axvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spin = "0.10"
# System independent crates provided by ArceOS.
ax-errno = { workspace = true }
ax-cpumask = { workspace = true }
# ax-kspin = "0.1.0"
ax-kspin.workspace = true
ax-memory-addr = { workspace = true }
ax-page-table-entry = { workspace = true, features = ["arm-el2"] }
ax-page-table-multiarch = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion components/axvm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ use core::{alloc::Layout, fmt};

use ax_cpumask::CpuMask;
use ax_errno::{AxError, AxResult, ax_err, ax_err_type};
use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::{align_down_4k, align_up_4k};
use axaddrspace::{
AddrSpace, GuestPhysAddr, HostPhysAddr, HostVirtAddr, MappingFlags, device::AccessWidth,
};
use axdevice::{AxVmDeviceConfig, AxVmDevices};
use axvcpu::{AxVCpu, AxVCpuExitReason};
use axvisor_api::vmm::InterruptVector;
use spin::{Mutex, Once};
use spin::Once;

#[cfg(not(target_arch = "x86_64"))]
use crate::vcpu::AxVCpuCreateConfig;
Expand Down
2 changes: 1 addition & 1 deletion components/dma-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ version = "0.7.3"
[features]

[dependencies]
ax-kspin.workspace = true
cfg-if.workspace = true
derive_more.workspace = true
log.workspace = true
mbarrier = "0.1"
spin.workspace = true
thiserror.workspace = true

[target.'cfg(target_arch = "aarch64")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion components/dma-api/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::{
};
use core::ops::{Deref, DerefMut};

use spin::Mutex;
use ax_kspin::SpinNoIrq as Mutex;

use crate::{DArray, DeviceDma, DmaDirection, DmaError};

Expand Down
2 changes: 1 addition & 1 deletion components/loongarch_vcpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ license = "Apache-2.0"
targets = ["loongarch64-unknown-none-softfloat"]

[dependencies]
ax-kspin.workspace = true
log = "0.4"
spin = "0.10"

ax-errno = { workspace = true }
ax-percpu = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion components/loongarch_vcpu/src/registers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use spin::Mutex;
use ax_kspin::SpinNoIrq as Mutex;

pub const CSR_GSTAT: u16 = 0x50;
pub const CSR_EENTRY: u16 = 0x0c;
Expand Down
2 changes: 1 addition & 1 deletion components/riscv_vplic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ license = "Apache-2.0"
default = []

[dependencies]
ax-kspin.workspace = true
axaddrspace = { workspace = true }
axdevice_base = { workspace = true }
axvisor_api = { workspace = true }
ax-errno = { workspace = true }
bitmaps = { version = "3.2", default-features = false }
log = "0.4"
spin = "0.10"

riscv-h = { workspace = true }
[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion components/riscv_vplic/src/vplic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use core::option::Option;

use ax_kspin::SpinNoIrq as Mutex;
use axaddrspace::{GuestPhysAddr, HostPhysAddr};
use bitmaps::Bitmap;
use spin::Mutex;

use crate::consts::*;

Expand Down
3 changes: 1 addition & 2 deletions components/rsext4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ license = "Apache-2.0"

[dependencies]
bitflags = "2.10"
lazy_static = { version = "1.5", features = ["spin_no_std"] }
log = "0.4"
spin = { workspace = true }

[features]
default = ["USE_MULTILEVEL_CACHE"]
USE_MULTILEVEL_CACHE = [] #启用多级缓存

6 changes: 2 additions & 4 deletions components/rsext4/src/crc32c/arm64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
use core::arch::asm;

#[cfg(target_arch = "aarch64")]
lazy_static::lazy_static! {
#[allow(dead_code)]
pub static ref HARDWARE_SUPPORT_CRC32: bool = has_hardware_crc32();
}
#[allow(dead_code)]
pub static HARDWARE_SUPPORT_CRC32: spin::Lazy<bool> = spin::Lazy::new(has_hardware_crc32);

// In `core::arch::aarch64`, the intrinsics with the `c` suffix implement the
// Castagnoli polynomial used by CRC32C.
Expand Down
Loading