microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.47k stars 822 forks source link

mt7921u driver crashing in WSL2 #12288

Open straightblast opened 2 hours ago

straightblast commented 2 hours ago

WslLogs-2024-11-17_23-00-12.zip

Windows Version

Microsoft Windows [Version 10.0.22631.4460]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

Kernel Version

6.1.21.2

Distro Version

kali

Other Software

No response

Repro Steps

On WSL2/Kali Side:

wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/mediatek/WIFI_RAM_CODE_MT7961_1.bin

wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin

cp *.bin /firmware/lab/mediatek

git clone -b linux-msft-wsl-6.6.y --single-branch https://github.com/microsoft/WSL2-Linux-Kernel.git cd WSL2-Linux-Kernel-6.1 cp Microsoft/config-wsl .config make menuconfig

the main changes / enablement are: CONFIG_EXTRA_FIRMWARE="mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin mediatek/WIFI_RAM_CODE_MT7961_1.bin" CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware" CONFIG_WIRELESS=y CONFIG_CFG80211=m CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y CONFIG_CFG80211_DEFAULT_PS=y CONFIG_CFG80211_CRDA_SUPPORT=y CONFIG_MAC80211=m CONFIG_MAC80211_HAS_RC=y CONFIG_MAC80211_RC_MINSTREL=y CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y CONFIG_MAC80211_RC_DEFAULT="minstrel_ht" CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 CONFIG_WLAN_VENDOR_MEDIATEK=y CONFIG_MT76_CORE=m CONFIG_MT76_USB=m CONFIG_MT76_CONNAC_LIB=m CONFIG_MT7921_COMMON=m CONFIG_MT7921U=m

make modules sudo make modules_install make cp arch/x86/boot/bzImage /mnt/c/Users/user/bzImage

Windows Side:

Created C:\Users\user.wslconfig:

[wsl2] kernel=C:\Users\user\bzImage

Setup usbipd:

PS C:\Users\user> usbipd list Connected: BUSID VID:PID DEVICE STATE 2-3 258a:000c USB Input Device Not shared 2-7 8087:0032 Intel(R) Wireless Bluetooth(R) Not shared 2-10 058f:5608 USB 2.0 Camera Not shared 2-16 0e8d:7961 MediaTek Bluetooth Adapter, MediaTek Wi-Fi 6/6E Wireless ... Not shared

PS C:\Users\user> usbipd bind --busid 2-16

PS C:\Users\user> usbipd attach --wsl --busid 2-16 usbipd: info: Using WSL distribution 'kali-linux' to attach; the device will be available in all WSL 2 distributions. usbipd: info: Using IP address 127.0.0.1 to reach the host.

Back on WSL2/Kali Side:

wsl --shutdown wsl

$sudo modprobe mt7921u

$ lsmod Module Size Used by mt7921u 16384 0 mt7921_common 86016 1 mt7921u mt76_connac_lib 53248 2 mt7921_common,mt7921u mt76_usb 32768 1 mt7921u mt76 81920 4 mt76_usb,mt7921_common,mt76_connac_lib,mt7921u mac80211 962560 3 mt76,mt7921_common,mt76_connac_lib cfg80211 909312 4 mt76,mac80211,mt7921_common,mt76_connac_lib

sudo dmesg:

[ 84.850228] usbcore: registered new interface driver mt7921u [ 140.201697] IPv6: ADDRCONF(NETDEV_CHANGE): eth2: link becomes ready [ 151.344730] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3) [ 151.345970] vhci_hcd vhci_hcd.0: devid(131088) speed(5) speed_str(super-speed) [ 151.347158] vhci_hcd vhci_hcd.0: Device attached [ 151.705296] usb 2-1: SetAddress Request (2) to port 0 [ 151.707330] usb 2-1: new SuperSpeed USB device number 2 using vhci_hcd [ 151.747234] usb 2-1: New USB device found, idVendor=0e8d, idProduct=7961, bcdDevice= 1.00 [ 151.747946] usb 2-1: New USB device strings: Mfr=6, Product=7, SerialNumber=8 [ 151.748408] usb 2-1: Product: Wireless_Device [ 151.748697] usb 2-1: Manufacturer: MediaTek Inc. [ 151.749121] usb 2-1: SerialNumber: 000000000 [ 151.905234] usb 2-1: SetAddress Request (2) to port 0 [ 151.906526] usb 2-1: reset SuperSpeed USB device number 2 using vhci_hcd [ 152.031227] mt7921u 2-1:1.3: WM Firmware Version: id=cgit -, Build Time: -> </ht

afterwards, kali gets kicked out, and goes back to powershell. it appears a crash happened, but I am unable to collect logs. I think the compilation of the kernel is pretty standard with enabling WIFI and Mediatek driver and baking the Mediatek firmware into the kernel. I am not sure why this is happening. This also happens on the WSL2 Kernel v6.6 as well.

Any suggestion or ideas what I am doing wrong?

Expected Behavior

i expect to have wlan0 enabled, but instead the WSL2 kernel appeared to have crash, and kicks me back to powershell

Actual Behavior

appears a crash happened, and kicks me out to powershell

Diagnostic Logs

No response

github-actions[bot] commented 2 hours ago

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: ``` Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 Set-ExecutionPolicy Bypass -Scope Process -Force .\collect-wsl-logs.ps1 ``` The script will output the path of the log file once done. If this is a networking issue, please use [collect-networking-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1), following the instructions [here](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues) Once completed please upload the output files to this Github issue. [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] commented 1 hour ago
Diagnostic information ``` Issue was edited and new log file was found: https://github.com/user-attachments/files/17796104/WslLogs-2024-11-17_23-00-12.zip .wslconfig found Custom kernel found: 'C:\Users\zerocool\bzImage' Detected appx version: 2.3.26.0 Found evidence of kernel panic: [ 58.619039] Kernel panic - not syncing: Fatal exception ```