Re: pci passthrough Mediatek MT7922 doesn't work

2024-04-20 Thread Peter Miller
doas sh -x /usr/share/examples/bhyve/vmrun.sh -p 1/0/0 -d
FreeBSD-14.0-STABLE-amd64.raw vm0

Loading kernel...
/boot/kernel/kernel text=0x17be70 text=0xd75798 text=0x4254ec
data=0x180 data=0x1866b0+0x478950 0x8+0x1894e0+0x8+0x1acde2\
Loading configured modules...
/etc/hostid size=0x25
/boot/entropy size=0x1000
+ bhyve_exit=0
+ [ 0 -ne 0 ]
+ nextslot=2
+ devargs=''
+ i=0
+ [ 0 -lt 1 ]
+ eval 'tapname=$tap_dev0'
+ tapname=tap0
+ devargs=' -s 2:0,virtio-net,tap0 '
+ nextslot=3
+ i=1
+ [ 1 -lt 1 ]
+ i=0
+ [ 0 -lt 1 ]
+ eval 'disk=$disk_dev0'
+ disk=FreeBSD-14.0-STABLE-amd64.raw
+ eval 'opts=$disk_opts0'
+ opts=''
+ make_and_check_diskdev FreeBSD-14.0-STABLE-amd64.raw
+ local 'virtio_diskdev=FreeBSD-14.0-STABLE-amd64.raw'
+ [ ! -e FreeBSD-14.0-STABLE-amd64.raw ]
+ [ ! -r FreeBSD-14.0-STABLE-amd64.raw ]
+ [ ! -w FreeBSD-14.0-STABLE-amd64.raw ]
+ devargs=' -s 2:0,virtio-net,tap0  -s
3:0,virtio-blk,FreeBSD-14.0-STABLE-amd64.raw '
+ nextslot=4
+ i=1
+ [ 1 -lt 1 ]
+ i=0
+ [ 0 -lt 1 ]
+ eval 'pass=$pass_dev0'
+ pass=1/0/0
+ echo 1/0/0
+ grep '^[0-9]\+/[0-9]\+/[0-9]\+$'
+ bsfform=1/0/0
+ [ -z 1/0/0 ]
+ bsf=1/0/0
+ devargs=' -s 2:0,virtio-net,tap0  -s
3:0,virtio-blk,FreeBSD-14.0-STABLE-amd64.raw  -s 4:0,passthru,1/0/0 '
+ nextslot=5
+ i=1
+ [ 1 -lt 1 ]
+ efiargs=''
+ [ 0 -gt 0 ]
+ /usr/sbin/bhyve -c 2 -m 512M -H -A -P -S -s 0:0,hostbridge -s
1:0,lpc -s 2:0,virtio-net,tap0 -s
3:0,virtio-blk,FreeBSD-14.0-STABLE-amd64.raw -s 4:0,passthru,1/0/0 -l
com1,stdio vm0
---<>---
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-STABLE #0 stable/14-n267376-ca8e2e4c91cc: Thu Apr 18
05:55:35 UTC 2024
r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git
llvmorg-17.0.6-0-g6009708b4367)
VT: init without driver.
CPU: AMD Ryzen 5 7540U w/ Radeon(TM) 740M Graphics   (3194.09-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0xa70f41  Family=0x19  Model=0x74  Stepping=1
  
Features=0x1783fbff
  
Features2=0xfed83203
  AMD Features=0x26500800
  AMD 
Features2=0x444231fb
  Structured Extended
Features=0xf01703a9
  Structured Extended Features2=0x600
  XSAVE Features=0x1
  AMD Extended Feature Extensions ID EBX=0x7
  TSC: P-state invariant
Hypervisor: Origin = "bhyve bhyve "
real memory  = 536870912 (512 MB)
avail memory = 482742272 (460 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: 
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 2 package(s) x 1 core(s)
random: registering fast source Intel Secure Key RNG
random: fast provider: "Intel Secure Key RNG"
random: unblocking device.
ioapic0  irqs 0-31
Launching APs: 1
random: entropy device external interface
kbd1 at kbdmux0
smbios0:  at iomem 0xf1000-0xf101e
smbios0: Version: 2.6, BCD Revision: 2.6
aesni0: 
acpi0: 
acpi0: Power Button (fixed)
atrtc0:  port 0x70-0x71 irq 8 on acpi0
atrtc0: registered as a time-of-day clock, resolution 1.00s
Event timer "RTC" frequency 32768 Hz quality 0
attimer0:  port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
hpet0:  iomem 0xfed0-0xfed003ff on acpi0
Timecounter "HPET" frequency 16777216 Hz quality 950
Event timer "HPET" frequency 16777216 Hz quality 550
Event timer "HPET1" frequency 16777216 Hz quality 450
Event timer "HPET2" frequency 16777216 Hz quality 450
Event timer "HPET3" frequency 16777216 Hz quality 450
Event timer "HPET4" frequency 16777216 Hz quality 450
Event timer "HPET5" frequency 16777216 Hz quality 450
Event timer "HPET6" frequency 16777216 Hz quality 450
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
pcib0:  port 0xcf8-0xcff on acpi0
pci0:  on pcib0
isab0:  at device 1.0 on pci0
isa0:  on isab0
virtio_pci0:  port 0x2080-0x20bf
mem 0xc0108000-0xc0109fff irq 16 at device 2.0 on pci0
vtnet0:  on virtio_pci0
vtnet0: Ethernet address: 00:a0:98:f0:55:05
vtnet0: netmap queues/slots: TX 1/1024, RX 1/512
000.000148 [ 452] vtnet_netmap_attach   vtnet attached txq=1,
txd=1024 rxq=1, rxd=512
virtio_pci1:  port 0x2000-0x207f
mem 0xc010a000-0xc010bfff irq 17 at device 3.0 on pci0
vtblk0:  on virtio_pci1
vtblk0: 6176MB (12649685 512 byte sectors)
vmgenc0:  on acpi0
atkbdc0:  port 0x60,0x64 irq 1 on acpi0
atkbd0:  irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
driver bug: Unable to set devclass (class: atkbdc devname: (unknown))
Unhandled ps2 mouse command 0xe1
psm0:  irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
WARNING: Device "psm" is Giant locked and may be deleted before FreeBSD 15.0.
psm0: model Generic PS/2 mouse, device ID 0
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (115200,n,8,1)
uart1: <16550 or compatible> 

Re: pci passthrough Mediatek MT7922 doesn't work

2024-04-20 Thread Bakul Shah
Invoke the vmrun.sh script as "sh -x /usr/misc/examples/bhyve/vmrun.sh" to show 
use the bhyve command line executed. As well as any error messages.

> On Apr 20, 2024, at 12:32 PM, Peter Miller  wrote:
> 
> Hello,
> 
> I'm trying to use wifibox and the wifi device is not being passed through.
> There is a bug report, which I added to, but they told me it was
> probably a bhyve problem.
> https://github.com/pgj/freebsd-wifibox/issues/73
> 
> I followed these instructions to test, and added -p 1/0/0 to pass the
> wifi device.
> https://wiki.freebsd.org/bhyve#Q:_What_is_the_easiest_way_to_try_bhyve.3F
> 
> fetch 
> https://download.freebsd.org/snapshots/VM-IMAGES/14.0-STABLE/amd64/Latest/FreeBSD-14.0-STABLE-amd64.raw.xz
> unxz FreeBSD-14.0-STABLE-amd64.raw.xz
> doas sh /usr/share/examples/bhyve/vmrun.sh -p 1/0/0 -d
> FreeBSD-14.0-STABLE-amd64.raw vm0
> 
> within the bhyve vm, I do not see the wifi device
> root@freebsd:~ # pciconf -lv
> hostb0@pci0:0:0:0:  class=0x06 rev=0x00 hdr=0x00 vendor=0x1275
> device=0x1275 subvendor=0x subdevice=0x
>vendor = 'Network Appliance Corporation'
>class  = bridge
>subclass   = HOST-PCI
> isab0@pci0:0:1:0:   class=0x060100 rev=0x00 hdr=0x00 vendor=0x8086
> device=0x7000 subvendor=0x subdevice=0x
>vendor = 'Intel Corporation'
>device = '82371SB PIIX3 ISA [Natoma/Triton II]'
>class  = bridge
>subclass   = PCI-ISA
> virtio_pci0@pci0:0:2:0: class=0x02 rev=0x00 hdr=0x00 vendor=0x1af4
> device=0x1000 subvendor=0x1af4 subdevice=0x0001
>vendor = 'Red Hat, Inc.'
>device = 'Virtio network device'
>class  = network
>subclass   = ethernet
> virtio_pci1@pci0:0:3:0: class=0x01 rev=0x00 hdr=0x00 vendor=0x1af4
> device=0x1001 subvendor=0x1af4 subdevice=0x0002
>vendor = 'Red Hat, Inc.'
>device = 'Virtio block device'
>class  = mass storage
>subclass   = SCSI
> 
> 
> 
> bhyve dmesg
> root@freebsd:~ # cat /var/run/dmesg.boot
> ---<>---
> Copyright (c) 1992-2023 The FreeBSD Project.
> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
>The Regents of the University of California. All rights reserved.
> FreeBSD is a registered trademark of The FreeBSD Foundation.
> FreeBSD 14.0-STABLE #0 stable/14-n267376-ca8e2e4c91cc: Thu Apr 18
> 05:55:35 UTC 2024
>r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
> FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git
> llvmorg-17.0.6-0-g6009708b4367)
> VT: init without driver.
> CPU: AMD Ryzen 5 7540U w/ Radeon(TM) 740M Graphics   (3194.13-MHz K8-class 
> CPU)
>  Origin="AuthenticAMD"  Id=0xa70f41  Family=0x19  Model=0x74  Stepping=1
>  
> Features=0x1783fbff
>  
> Features2=0xfed83203
>  AMD Features=0x26500800
>  AMD 
> Features2=0x444231fb
>  Structured Extended
> Features=0xf01703a9
>  Structured Extended Features2=0x600
>  XSAVE Features=0x1
>  AMD Extended Feature Extensions ID EBX=0x7
>  TSC: P-state invariant
> Hypervisor: Origin = "bhyve bhyve "
> real memory  = 536870912 (512 MB)
> avail memory = 482742272 (460 MB)
> Event timer "LAPIC" quality 600
> ACPI APIC Table: 
> FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
> FreeBSD/SMP: 2 package(s) x 1 core(s)
> random: registering fast source Intel Secure Key RNG
> random: fast provider: "Intel Secure Key RNG"
> random: unblocking device.
> ioapic0  irqs 0-31
> Launching APs: 1
> random: entropy device external interface
> kbd1 at kbdmux0
> smbios0:  at iomem 0xf1000-0xf101e
> smbios0: Version: 2.6, BCD Revision: 2.6
> aesni0: 
> acpi0: 
> acpi0: Power Button (fixed)
> atrtc0:  port 0x70-0x71 irq 8 on acpi0
> atrtc0: registered as a time-of-day clock, resolution 1.00s
> Event timer "RTC" frequency 32768 Hz quality 0
> attimer0:  port 0x40-0x43 irq 0 on acpi0
> Timecounter "i8254" frequency 1193182 Hz quality 0
> Event timer "i8254" frequency 1193182 Hz quality 100
> hpet0:  iomem 0xfed0-0xfed003ff on acpi0
> Timecounter "HPET" frequency 16777216 Hz quality 950
> Event timer "HPET" frequency 16777216 Hz quality 550
> Event timer "HPET1" frequency 16777216 Hz quality 450
> Event timer "HPET2" frequency 16777216 Hz quality 450
> Event timer "HPET3" frequency 16777216 Hz quality 450
> Event timer "HPET4" frequency 16777216 Hz quality 450
> Event timer "HPET5" frequency 16777216 Hz quality 450
> Event timer "HPET6" frequency 16777216 Hz quality 450
> Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
> acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
> pcib0:  port 0xcf8-0xcff on acpi0
> pci0:  on pcib0
> isab0:  at device 1.0 on pci0
> isa0:  on isab0
> virtio_pci0:  port 0x2080-0x20bf
> mem 0xc0108000-0xc0109fff irq 16 at device 2.0 on pci0
> vtnet0:  on virtio_pci0
> vtnet0: Ethernet address: 00:a0:98:f0:55:05
> vtnet0: netmap queues/slots: TX 1/1024, RX 1/512
> 000.000148 [ 452] vtnet_netmap_attach   vtnet attached txq=1,
> txd=1024 rxq=1, rxd=512

pci passthrough Mediatek MT7922 doesn't work

2024-04-20 Thread Peter Miller
Hello,

I'm trying to use wifibox and the wifi device is not being passed through.
There is a bug report, which I added to, but they told me it was
probably a bhyve problem.
https://github.com/pgj/freebsd-wifibox/issues/73

I followed these instructions to test, and added -p 1/0/0 to pass the
wifi device.
https://wiki.freebsd.org/bhyve#Q:_What_is_the_easiest_way_to_try_bhyve.3F

fetch 
https://download.freebsd.org/snapshots/VM-IMAGES/14.0-STABLE/amd64/Latest/FreeBSD-14.0-STABLE-amd64.raw.xz
unxz FreeBSD-14.0-STABLE-amd64.raw.xz
doas sh /usr/share/examples/bhyve/vmrun.sh -p 1/0/0 -d
FreeBSD-14.0-STABLE-amd64.raw vm0

within the bhyve vm, I do not see the wifi device
root@freebsd:~ # pciconf -lv
hostb0@pci0:0:0:0:  class=0x06 rev=0x00 hdr=0x00 vendor=0x1275
device=0x1275 subvendor=0x subdevice=0x
vendor = 'Network Appliance Corporation'
class  = bridge
subclass   = HOST-PCI
isab0@pci0:0:1:0:   class=0x060100 rev=0x00 hdr=0x00 vendor=0x8086
device=0x7000 subvendor=0x subdevice=0x
vendor = 'Intel Corporation'
device = '82371SB PIIX3 ISA [Natoma/Triton II]'
class  = bridge
subclass   = PCI-ISA
virtio_pci0@pci0:0:2:0: class=0x02 rev=0x00 hdr=0x00 vendor=0x1af4
device=0x1000 subvendor=0x1af4 subdevice=0x0001
vendor = 'Red Hat, Inc.'
device = 'Virtio network device'
class  = network
subclass   = ethernet
virtio_pci1@pci0:0:3:0: class=0x01 rev=0x00 hdr=0x00 vendor=0x1af4
device=0x1001 subvendor=0x1af4 subdevice=0x0002
vendor = 'Red Hat, Inc.'
device = 'Virtio block device'
class  = mass storage
subclass   = SCSI



bhyve dmesg
root@freebsd:~ # cat /var/run/dmesg.boot
---<>---
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-STABLE #0 stable/14-n267376-ca8e2e4c91cc: Thu Apr 18
05:55:35 UTC 2024
r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git
llvmorg-17.0.6-0-g6009708b4367)
VT: init without driver.
CPU: AMD Ryzen 5 7540U w/ Radeon(TM) 740M Graphics   (3194.13-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0xa70f41  Family=0x19  Model=0x74  Stepping=1
  
Features=0x1783fbff
  
Features2=0xfed83203
  AMD Features=0x26500800
  AMD 
Features2=0x444231fb
  Structured Extended
Features=0xf01703a9
  Structured Extended Features2=0x600
  XSAVE Features=0x1
  AMD Extended Feature Extensions ID EBX=0x7
  TSC: P-state invariant
Hypervisor: Origin = "bhyve bhyve "
real memory  = 536870912 (512 MB)
avail memory = 482742272 (460 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: 
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 2 package(s) x 1 core(s)
random: registering fast source Intel Secure Key RNG
random: fast provider: "Intel Secure Key RNG"
random: unblocking device.
ioapic0  irqs 0-31
Launching APs: 1
random: entropy device external interface
kbd1 at kbdmux0
smbios0:  at iomem 0xf1000-0xf101e
smbios0: Version: 2.6, BCD Revision: 2.6
aesni0: 
acpi0: 
acpi0: Power Button (fixed)
atrtc0:  port 0x70-0x71 irq 8 on acpi0
atrtc0: registered as a time-of-day clock, resolution 1.00s
Event timer "RTC" frequency 32768 Hz quality 0
attimer0:  port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
hpet0:  iomem 0xfed0-0xfed003ff on acpi0
Timecounter "HPET" frequency 16777216 Hz quality 950
Event timer "HPET" frequency 16777216 Hz quality 550
Event timer "HPET1" frequency 16777216 Hz quality 450
Event timer "HPET2" frequency 16777216 Hz quality 450
Event timer "HPET3" frequency 16777216 Hz quality 450
Event timer "HPET4" frequency 16777216 Hz quality 450
Event timer "HPET5" frequency 16777216 Hz quality 450
Event timer "HPET6" frequency 16777216 Hz quality 450
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
pcib0:  port 0xcf8-0xcff on acpi0
pci0:  on pcib0
isab0:  at device 1.0 on pci0
isa0:  on isab0
virtio_pci0:  port 0x2080-0x20bf
mem 0xc0108000-0xc0109fff irq 16 at device 2.0 on pci0
vtnet0:  on virtio_pci0
vtnet0: Ethernet address: 00:a0:98:f0:55:05
vtnet0: netmap queues/slots: TX 1/1024, RX 1/512
000.000148 [ 452] vtnet_netmap_attach   vtnet attached txq=1,
txd=1024 rxq=1, rxd=512
virtio_pci1:  port 0x2000-0x207f
mem 0xc010a000-0xc010bfff irq 17 at device 3.0 on pci0
vtblk0:  on virtio_pci1
vtblk0: 6176MB (12649685 512 byte sectors)
vmgenc0:  on acpi0
atkbdc0:  port 0x60,0x64 irq 1 on acpi0
atkbd0:  irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
driver bug: Unable to set devclass (class: atkbdc devname: (unknown))
psm0:  irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
WARNING: Device "psm" is 

Re: Trying to virtualize ReactOS with bhyve : I don't see a viable way to do it...

2024-04-20 Thread Mario Marietto
UPDATE :

I've been able to unfreeze ReactOS on the boot stage. I've just removed the
bhyve "-A" offending parameter that can't be used because ReactOS probably
does not support ACPI. Now I'm at this stage :

https://ibb.co/Dtw8Hj1

Now the problem is that I can't move the mouse inside the vm and the
keyboard does not work...so I need to find some workaround to supply the
absence of the arbiter...

I've thought about using virtio-input and I've added this parameter to
bhyve :

-s 12,virtio-input,/dev/input/event7 \

I've chosen event7,because I've got it here :

[root@marietto /bhyve]==> ls /dev/input/
event0 event1 event2 event3 event4 event5 event6 event7

Anyway I also tried event6,event5...it didn't work.

Can someone quickly explain how it works ? Is it supposed to work even if
ReactOS does not have the arbiter ?
More precisely the ReactOS developer said : "Hardware initialization
doesn’t occur on UEFI due to missing arbiter support : It means that the
hardware (even essential such as input devices) will not work and you may
not be able to interact with the system in any way"

My idea is to use Barrier to be able to use the mouse and keyboard inside
the vm...I will install the server on freebsd and the client inside the
reactos vm...

Could it work  as long as reactOS has a network connection ?

Let me know.

On Fri, Apr 19, 2024 at 3:52 PM Mario Marietto 
wrote:

> Hello.
>
> I'm trying to boot the 32 bit ISO image of ReactOS using bhyve or qemu and
> seabios as bootloader.
>
> As first experiment I tried to boot the x86 version of ReactOS with qemu
> (8.2.2) and seabios (version 1.16.1_1),like this :
>
> qemu-system-x86_64 -machine q35 -m 1G -cdrom
> /home/marietto/Desktop/Downloads/OS/ReactOS/reactos-livecd-0.4.15-dev-7921-g6d853be-x86-msvc-win-dbg.iso
> -boot order=d
>
> Unfortunately,I get the error below :
>
> https://ibb.co/tZmFh2x
>
> but my real goal is to boot ReactOS by using seabios. Even here I'm
> unlucky. Infact on this web page :
>
> https://eradman.com/posts/bhyve-ipxe.html
>
> we can read :
>
> *Bhyve is somewhat similar to QEMU-KVM without the emulation required to
> boot SeaBIOS.*
>
> Is really true that I can't use seabios to boot ReactOS with bhyve ?
> Anyway,ok. I've continued my searching and I found this thread :
>
> https://forums.freebsd.org/threads/bhyve-with-bios-boot.79794/
>
> where we can read :
>
> *bhyveload has nothing to do with BIOS. As detailed in the man page you
> linked to, it is for loading a FreeBSD guest.*
>
> So,it seems that I can't even use bhyveload. So,what can I use ? What can
> I do ?
>
> I've gone on the ReactOS forum and I've created a thread where
> I 've asked how to boot the 64 bit + UEFI version of ReactOS using bhyve.
> The developers helped me,but in the end we have done nothing. Because after
> some progress,I found this error :
>
> https://ibb.co/N9QHdnp
>
> Unfortunately it is frozen when it tries to load the mountmgr.sys driver.
> Actually unfixed and no one knows how to fix it.
>
> Now I'm here,asking for some further ideas and suggestions.
>
> --
> Mario.
>


-- 
Mario.