name: 57-bit Virtual Address Real VM Testing
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
qemu-linux-57bit:
name: QEMU Emulated 57-bit Linux VM
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@main
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Verify 48-bit Detection on Host
run: |
cargo clean
ATOMIC_TAGGED_PTR_TEST_EXPECT_48=1 cargo check
cargo clean
if ATOMIC_TAGGED_PTR_TEST_EXPECT_57=1 cargo check; then exit 1; else true; fi
- name: Setup Qemu and Install Dependencies
run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 qemu-utils busybox-static zstd
- name: Prepare VM Boot Image
run: |
mkdir -p initramfs/bin initramfs/sbin initramfs/etc initramfs/proc initramfs/sys initramfs/dev initramfs/mnt/host
cp /bin/busybox initramfs/bin/busybox
ln -s busybox initramfs/bin/sh
ln -s busybox initramfs/bin/mkdir
ln -s busybox initramfs/bin/mount
ln -s busybox initramfs/bin/chroot
ln -s busybox initramfs/bin/echo
ln -s busybox initramfs/bin/poweroff
ln -s busybox initramfs/bin/mknod
ln -s busybox initramfs/sbin/modprobe
ln -s busybox initramfs/sbin/depmod
for mod in 9p 9pnet_virtio; do
modprobe --show-depends $mod | awk '{print $2}' | while read -r modpath; do
if [ -f "$modpath" ]; then
dest="initramfs$(echo "$modpath")"
mkdir -p "$(dirname "$dest")"
cp "$modpath" "$dest"
fi
done
done
find initramfs/lib/modules/ -name "*.ko.zst" -exec zstd -d --rm {} \; 2>/dev/null || true
find initramfs/lib/modules/ -name "*.ko.gz" -exec gunzip {} \; 2>/dev/null || true
find initramfs/lib/modules/ -name "*.ko.xz" -exec xz -d {} \; 2>/dev/null || true
depmod -b initramfs $(uname -r)
cat << 'EOF' > initramfs/init
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t devtmpfs dev /dev
modprobe 9pnet_virtio
modprobe 9p
mkdir -p /mnt/host
mount -t 9p -o trans=virtio,version=9p2000.L,ro rootfs /mnt/host
mount -t proc proc /mnt/host/proc
mount -t sysfs sys /mnt/host/sys
mount -t devtmpfs dev /mnt/host/dev
mount -t tmpfs tmp /mnt/host/tmp
mount -t 9p -o trans=virtio,version=9p2000.L workspace /mnt/host@WORKSPACE@
mount -t 9p -o trans=virtio,version=9p2000.L home /mnt/host/home/runner
chroot /mnt/host /bin/sh -c "export HOME=/home/runner; export PATH=/home/runner/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; cd @WORKSPACE@; ATOMIC_TAGGED_PTR_TEST_EXPECT_57=1 cargo test --all-targets --verbose > @WORKSPACE@/test_result.log 2>&1; echo \$? > @WORKSPACE@/test_exit_code"
poweroff -f
EOF
sed -i "s|@WORKSPACE@|$GITHUB_WORKSPACE|g" initramfs/init
chmod +x initramfs/init
cd initramfs
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.img
cd ..
sudo cp /boot/vmlinuz-$(uname -r) ./vmlinuz
sudo chmod 644 ./vmlinuz
- name: Run Tests in 57-bit QEMU VM
run: |
qemu-system-x86_64 \
-cpu max \
-m 2G \
-smp 2 \
-nographic \
-kernel ./vmlinuz \
-initrd ./initramfs.img \
-append "console=ttyS0 quiet init=/init" \
-virtfs local,path=/,security_model=none,mount_tag=rootfs,readonly=on,multidevs=remap \
-virtfs local,path=$GITHUB_WORKSPACE,security_model=none,mount_tag=workspace,multidevs=remap \
-virtfs local,path=$HOME,security_model=none,mount_tag=home,multidevs=remap
cat test_result.log
if [ "$(cat test_exit_code)" -ne 0 ]; then exit $(cat test_exit_code); fi
- name: Verify 48-bit Detection Fails in QEMU VM
run: |
cat << 'EOF' > initramfs/init
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t devtmpfs dev /dev
modprobe 9pnet_virtio
modprobe 9p
mkdir -p /mnt/host
mount -t 9p -o trans=virtio,version=9p2000.L,ro rootfs /mnt/host
mount -t proc proc /mnt/host/proc
mount -t sysfs sys /mnt/host/sys
mount -t devtmpfs dev /mnt/host/dev
mount -t tmpfs tmp /mnt/host/tmp
mount -t 9p -o trans=virtio,version=9p2000.L workspace /mnt/host@WORKSPACE@
mount -t 9p -o trans=virtio,version=9p2000.L home /mnt/host/home/runner
chroot /mnt/host /bin/sh -c "export HOME=/home/runner; export PATH=/home/runner/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; cd @WORKSPACE@; cargo clean; if ATOMIC_TAGGED_PTR_TEST_EXPECT_48=1 cargo check; then echo 0 > @WORKSPACE@/test_exit_code; else echo 1 > @WORKSPACE@/test_exit_code; fi"
poweroff -f
EOF
sed -i "s|@WORKSPACE@|$GITHUB_WORKSPACE|g" initramfs/init
chmod +x initramfs/init
cd initramfs
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.img
cd ..
qemu-system-x86_64 \
-cpu max \
-m 2G \
-smp 2 \
-nographic \
-kernel ./vmlinuz \
-initrd ./initramfs.img \
-append "console=ttyS0 quiet init=/init" \
-virtfs local,path=/,security_model=none,mount_tag=rootfs,readonly=on,multidevs=remap \
-virtfs local,path=$GITHUB_WORKSPACE,security_model=none,mount_tag=workspace,multidevs=remap \
-virtfs local,path=$HOME,security_model=none,mount_tag=home,multidevs=remap
if [ "$(cat test_exit_code)" -eq 0 ]; then exit 1; else true; fi
linux-tests:
name: Normal Linux Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@main
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Test Forced 48-bit Virtual Address Layout
run: ATOMIC_TAGGED_PTR_FORCE_VIRT_ADDR=48 ATOMIC_TAGGED_PTR_TEST_EXPECT_48=1 cargo test
- name: Test Forced 57-bit Virtual Address Layout
run: ATOMIC_TAGGED_PTR_FORCE_VIRT_ADDR=57 ATOMIC_TAGGED_PTR_TEST_EXPECT_57=1 cargo test
- name: Test Fallback Mutex Implementation
run: RUSTFLAGS='--cfg atomic_fallback' cargo test
- name: Test Forced 48-bit Virtual Address Layout without std
run: ATOMIC_TAGGED_PTR_FORCE_VIRT_ADDR=48 ATOMIC_TAGGED_PTR_TEST_EXPECT_48=1 cargo test --no-default-features
- name: Test Forced 57-bit Virtual Address Layout without std
run: ATOMIC_TAGGED_PTR_FORCE_VIRT_ADDR=57 ATOMIC_TAGGED_PTR_TEST_EXPECT_57=1 cargo test --no-default-features
- name: Test Fallback Mutex Implementation without std
run: RUSTFLAGS='--cfg atomic_fallback' cargo test --no-default-features