From 6d2069230e6d679e846816e03f7de8d242ad0079 Mon Sep 17 00:00:00 2001 From: Afonso Oliveira Date: Tue, 1 Sep 2026 22:23:00 +0100 Subject: [PATCH] Replace YT6801 DKMS driver --- .../hardware/fix-yt6801-ethernet-adapter.sh | 6 +- install/omarchy-other.packages | 1 - migrations/1788279117.sh | 41 +++++++++++ test/shell.d/yt6801-driver-test.sh | 72 +++++++++++++++++++ 4 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 migrations/1788279117.sh create mode 100644 test/shell.d/yt6801-driver-test.sh diff --git a/install/hardware/fix-yt6801-ethernet-adapter.sh b/install/hardware/fix-yt6801-ethernet-adapter.sh index f88a9cec..8dac5db0 100644 --- a/install/hardware/fix-yt6801-ethernet-adapter.sh +++ b/install/hardware/fix-yt6801-ethernet-adapter.sh @@ -1,4 +1,4 @@ -# Install drivers for Motorcomm YT6801 ethernet adapter used by the Slimbook Executive -if lspci | grep -i "YT6801\|Motorcomm.*Ethernet"; then - omarchy-pkg-add yt6801-dkms +# Use the upstream driver for the Motorcomm YT6801 adapter used by the Slimbook Executive. +if [[ -n $(lspci -Dn -d 1f0a:6801) ]]; then + omarchy-pkg-drop yt6801-dkms fi diff --git a/install/omarchy-other.packages b/install/omarchy-other.packages index 4a8b128f..ee7607a7 100644 --- a/install/omarchy-other.packages +++ b/install/omarchy-other.packages @@ -42,7 +42,6 @@ thermald webp-pixbuf-loader yay-debug tuxedo-drivers-nocompatcheck-dkms -yt6801-dkms zram-generator # Intel encoding processing diff --git a/migrations/1788279117.sh b/migrations/1788279117.sh new file mode 100644 index 00000000..e7022ce7 --- /dev/null +++ b/migrations/1788279117.sh @@ -0,0 +1,41 @@ +echo "Replace the YT6801 vendor DKMS driver with the upstream kernel driver" + +mapfile -t yt6801_devices < <(lspci -Dn -d 1f0a:6801 | awk '{ print $1 }') + +if (( ${#yt6801_devices[@]} == 0 )); then + omarchy-pkg-drop yt6801-dkms + exit 0 +fi + +for device in "${yt6801_devices[@]}"; do + if [[ ! $device =~ ^[[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]]$ ]]; then + echo "Invalid YT6801 PCI address: $device" >&2 + exit 1 + fi +done + +if ! modinfo -F alias dwmac-motorcomm | grep -Fqx 'pci:v00001F0Ad00006801sv*sd*bc*sc*i*'; then + echo "The running kernel does not provide YT6801 support in dwmac-motorcomm." >&2 + echo "Reboot into the latest Omarchy kernel and rerun omarchy-migrate." >&2 + exit 1 +fi + +# Load and validate the replacement before removing the installed fallback. +sudo modprobe dwmac-motorcomm +omarchy-pkg-drop yt6801-dkms + +if lsmod | awk '$1 == "yt6801" { found = 1 } END { exit !found }'; then + sudo modprobe -r yt6801 + + for device in "${yt6801_devices[@]}"; do + printf '%s\n' "$device" | sudo tee /sys/bus/pci/drivers_probe >/dev/null + done +fi + +for device in "${yt6801_devices[@]}"; do + if ! lspci -Dks "$device" | grep -Eq 'Kernel driver in use: dwmac[-_]motorcomm'; then + echo "YT6801 device $device did not bind to dwmac-motorcomm." >&2 + echo "Reboot and rerun omarchy-migrate." >&2 + exit 1 + fi +done diff --git a/test/shell.d/yt6801-driver-test.sh b/test/shell.d/yt6801-driver-test.sh new file mode 100644 index 00000000..4f771ed0 --- /dev/null +++ b/test/shell.d/yt6801-driver-test.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +source "$(dirname "$0")/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +stub_bin="$test_tmp/bin" +calls="$test_tmp/calls" +mkdir -p "$stub_bin" + +cat >"$stub_bin/lspci" <<'SH' +#!/bin/bash +if [[ $* == "-Dn -d 1f0a:6801" ]]; then + printf '%s\n' '0000:01:00.0 0200: 1f0a:6801' +elif [[ $* == "-Dks 0000:01:00.0" ]]; then + printf '%s\n' 'Kernel driver in use: dwmac-motorcomm' +fi +SH + +cat >"$stub_bin/modinfo" <<'SH' +#!/bin/bash +printf '%s\n' 'pci:v00001F0Ad00006801sv*sd*bc*sc*i*' +SH + +cat >"$stub_bin/lsmod" <<'SH' +#!/bin/bash +printf '%s\n' 'yt6801 65536 0' +SH + +for command in modprobe omarchy-pkg-drop tee; do + cat >"$stub_bin/$command" <<'SH' +#!/bin/bash +printf '%s\t%s\n' "${0##*/}" "$*" >>"$TEST_CALLS" +if [[ ${0##*/} == "tee" ]]; then + cat >/dev/null +fi +SH +done + +cat >"$stub_bin/sudo" <<'SH' +#!/bin/bash +printf 'sudo\t%s\n' "$*" >>"$TEST_CALLS" +"$@" +SH + +chmod +x "$stub_bin"/* +export TEST_CALLS="$calls" + +PATH="$stub_bin:$PATH" bash "$ROOT/install/hardware/fix-yt6801-ethernet-adapter.sh" +grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" || + fail "hardware setup did not remove the vendor DKMS package" +if grep -Fq $'modprobe\t' "$calls"; then + fail "hardware setup tried to load a module against the installer kernel" +fi + +: >"$calls" +PATH="$stub_bin:$PATH" bash -euo pipefail "$ROOT/migrations/1788279117.sh" +grep -Fqx $'sudo\tmodprobe dwmac-motorcomm' "$calls" || + fail "migration did not validate-load the upstream driver" +grep -Fqx $'omarchy-pkg-drop\tyt6801-dkms' "$calls" || + fail "migration did not remove the vendor DKMS package" +grep -Fqx $'sudo\tmodprobe -r yt6801' "$calls" || + fail "migration did not unload the vulnerable driver" +grep -Fqx $'sudo\ttee /sys/bus/pci/drivers_probe' "$calls" || + fail "migration did not reprobe the YT6801 device" + +if grep -Fxq 'yt6801-dkms' "$ROOT/install/omarchy-other.packages"; then + fail "default package list still installs yt6801-dkms" +fi + +pass "YT6801 installs and migrations use the upstream kernel driver"