From nobody Wed Oct 09 12:18:42 2024 X-Original-To: freebsd-virtualization@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XNsPY5MMvz5YSVs for ; Wed, 09 Oct 2024 12:18:57 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XNsPY12nPz4X50; Wed, 9 Oct 2024 12:18:57 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5398cc2fcb7so7749165e87.1; Wed, 09 Oct 2024 05:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728476334; x=1729081134; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PWpOdIZaM5a0jnC4dowOPP2AZ2HtGqeeLzeGJV8AgAs=; b=cI5RfuPHc9Oi4WslYA5UBYZ7r5bgh6sTS03TBo3mmHgVmQ4ZJIrZI9n9Lh4H/rAZys 8iXUK9a6OMdaJjkzmC7xIKnD8QGxKOljppJ8862IG+9pwB3SWoxJqlw1tlWbJffy/j1E PcKd9ENuM0RfMh4cvkTTBa2zi3Dp6q+RKtEralSeqUn6TnxjBv76VqCMWx6/vvHWAl+X rv9cBn3q1hIJtlckA+HmI68p8P0QsfnVUWzd3obBlvqtuhhe1hgllD31fwUM0BoLwor5 1s252VbDZWk+BUGD82WoCpQDX4wpP+oYmBvONfdpGfG42PvrE3VOtAR8eCJSvVR+9vok ndrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728476334; x=1729081134; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PWpOdIZaM5a0jnC4dowOPP2AZ2HtGqeeLzeGJV8AgAs=; b=CRe5TmD3vpzJh36tICyJtQM5og+TF0Hgi/alq0DjiPcksDBs87wXQHXsZi/rtxeimr /6DhKw6dO7vKa5KhkzftQaXeIXaP6LA/nbEWRaMOpNVVH0AnaKo2fwPSkwqCpvzIdPVW osXqZVVqnzZJjdIUWAmLAs/i72JdJOiMhIQgfLg75col54c/ZaInwJ+alFy5r0qvDr69 5PpKDfzAuBKEEAvIgAGzMXZKOospL2azI2vtf9LioFkAnW0ElwO4M13SiXZMkgRkjFPj rRWKA1Dpcv2jCo8WFIGv+5MuYbNRPY/ppfJbAsYo5v6O1T4EtHOMNUFHwh6ZhQJF3w7o oR1Q== X-Gm-Message-State: AOJu0YzsVPalHvp7kX67arleCMClrztdG0sV4k4Pb8vsi79eUp8bqc8c Iz2DA1xS8FeRiJTKc7lTJd5Do3TnHztMSAAMnHtuOzZviuRBN+ZazM9wsrU6zj+4SixmJhpbHtd s5FnkH3qTORSqGwuwLG3vr6sS3UTcP/koacc= X-Google-Smtp-Source: AGHT+IHFejBCVBbhg1pio6x+VqWvAWnDTAUAq/gaf/VKHzPU+gCjqHans89gl2ffA/iAPWsbSfMu12rQZsHmUjDyx/A= X-Received: by 2002:a05:6512:a8f:b0:535:d4e9:28c1 with SMTP id 2adb3069b0e04-539c48c47a2mr1236137e87.20.1728476333930; Wed, 09 Oct 2024 05:18:53 -0700 (PDT) List-Id: Discussion List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-virtualization@freebsd.org Sender: owner-freebsd-virtualization@FreeBSD.org MIME-Version: 1.0 References: <17f4077d-647d-4848-9d6f-97f9886ef636@freebsd.org> In-Reply-To: <17f4077d-647d-4848-9d6f-97f9886ef636@freebsd.org> From: Vasily Postnicov Date: Wed, 9 Oct 2024 12:18:42 +0000 Message-ID: Subject: Re: Running Mezzano in bhyve To: Peter Grehan Cc: freebsd-virtualization@freebsd.org Content-Type: multipart/alternative; boundary="000000000000e3012f06240a41fd" X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4XNsPY12nPz4X50 X-Spamd-Bar: ---- --000000000000e3012f06240a41fd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks! It worked, but Mezanno crashes after a short period of time: Begin PCI scan. PCI:0:1F:0 8086:7000 Intel Corporation - 82371SB PIIX3 ISA [Natoma/Triton II] 6:1:0 rid: 0 hdr: 0 intr: FF PCI:0:1D:0 FB5D:40FB NIL - NIL 3:0:0 rid: 0 hdr: 0 intr: FF 40: MSI 84 PCI:0:5:0 1AF4:1000 Red Hat, Inc - Virtio network device 2:0:0 rid: 0 hdr: 0 intr: A 40: Unknown capability 11 4C: MSI 80 PCI:0:3:0 8086:2821 Intel Corporation - 82801HR/HO/HH (ICH8R/DO/DH) 6 port SATA Controller [AHCI mode] 1:6:1 rid: 0 hdr: 0 intr: B 40: MSI 88 Detected AHCI ABAR at C1002000 AHCI IRQ is B Host Capabilities FF30FF3F Global Host Control 80000000 Interrupt Status 0 Ports Implemented 1 Version 10300 Command Completion Coalescing Control 0 Command Completion Coalescing Ports 0 Enclosure Management Location 0 Enclosure Management Control 0 Host Capabilities Extended 4 BIOS/OS Handoff Control and Status 0 AHCI HBA version 1.300 Handler: 0 Config register: 17 ----- PANIC ----- Early page fault on address 80000035B0 Local CPU is #<7A4AF9> Run queues: Thread #<1468079 Thread Initial thread> holds the world Run queue #<1498139>/SUPERVISOR: Run queue #<1498159>/HIGH: Run queue #<1498179>/NORMAL: Run queue #<1498199>/LOW: IRQ state: IRQ #<1497DF9 Irq :Number 0> - 0 (86 delivered) #<1499119> PIT [exclusive] IRQ #<1497E29 Irq :Number 1> - 1 (1 delivered) #<1499699> INTEL-8042-KEYBOARD [exclusive] IRQ #<1498009 Irq :Number B> - B (0 delivered) #<149C959> #<149C909> IRQ #<1498039 Irq :Number C> - C (0 delivered) #<14993D9> INTEL-8042-AUXILIARY [exclusive] Active timers: (current time is 147260) Thread #<1468079 Thread Initial thread> ACTIVE #<1498669 Wait-Queue Heartbeat wait queue> TIFH: 1 TPFH: NIL 20000121FB90 7FFF892B07 DEBUG-DUMP 20000121FD20 7FFF800FAE (LAMBDA IN PANIC-1) 20000121FE30 7FFF80073F PANIC-1 20000121FE50 7FFF800633 PANIC 20000121FEC0 7FFF8820B1 FATAL-PAGE-FAULT 20000121FEF0 7FFF88114B %PAGE-FAULT-HANDLER 20000121FF40 7FFF87F3BB %%INTERRUPT-SERVICE-ROUTINES 20000121FFD0 80000035B0 # 200000A1FFF0 7FFF800841 %CALL-ON-WIRED-STACK-WITHOUT-INTERRUPTS 20000221FE60 7FFF958E90 (SETF PCI-CONFIG/16) 20000221FE90 7FFF9B5670 AHCI-PCI-REGISTER 20000221FEF0 7FFF95B9C9 (FLET DX-LAMBDA IN PCI-DETECT) 20000221FF50 7FFF95B22E MAP-PCI-DEVICES 20000221FF90 7FFF955671 PCI-DETECT 20000221FFA0 7FFF93C8F4 INITIALIZE-PLATFORM 20000221FFC0 7FFF8D7F03 BOOTLOADER-ENTRY-POINT Looks like it executes an interrupt handler with calling something "on a wired stack without interrupts". Postmortem rflags: root@vonbraun:~ # bhyvectl --vm=3Dubuntu --get-rflags rflags[0] 0x0000000000000046 I do not know what to think, that %cal-on-wired-stack-without-interrupts seems to be legit to me: https://github.com/froggey/Mezzano/blob/master/supervisor/x86-64/interrupts= .lisp Anyway, thanks again for the help! =D1=81=D1=80, 9 =D0=BE=D0=BA=D1=82. 2024=E2=80=AF=D0=B3. =D0=B2 11:20, Pete= r Grehan : > > Hi! Mezzano is an operating system written in Common lisp. I would like > > to test it in bhyve. When I launch it, it spins infinitely in a loop > > measuring how many CPU cycles it makes in a unit of time (I understood > > it by adding various debug messages). > > > > The timer it uses is something called a PIT: > > https://wiki.osdev.org/Programmable_Interval_Timer > > > > > > The problem is, once the timer is configured it fires an interrupt only > > once, while it obviously must fire interrupts constantly at some > > frequency (100 Hz, as I understand from the code). > > > > Is the PIT supported by bhyve? Does FreeBSD use it anywhere in its > kernel? > > Yes, though mode 3 of the timer isn't supported by the device > emulation. It appears that Mezzano uses that mode > > > https://github.com/froggey/Mezzano/blob/master/supervisor/x86-64/time.lis= p#L20 > > Try this patch to the PIT code to see if it helps > https://people.freebsd.org/~grehan/bhyve_vatpit.diff > > later, > > Peter. > > --000000000000e3012f06240a41fd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks! It worked, but Mezanno crashes af= ter a short=C2=A0period of time:

Begin PCI scan.
PCI:= 0:1F:0 8086:7000 Intel Corporation - 82371SB PIIX3 ISA [Natoma/Triton II] 6= :1:0 rid: 0 hdr: 0 intr: FF
PCI:0:1D:0 FB5D:40FB NIL - NIL 3:0:0 rid: 0 = hdr: 0 intr: FF
=C2=A0 =C2=A0 40: MSI 84
PCI:0:5:0 1AF4:1000 Red Hat,= Inc - Virtio network device 2:0:0 rid: 0 hdr: 0 intr: A
=C2=A0 =C2=A0 4= 0: Unknown capability 11
=C2=A0 =C2=A0 4C: MSI 80
PCI:0:3:0 8086:2821= Intel Corporation - 82801HR/HO/HH (ICH8R/DO/DH) 6 port SATA Controller [AH= CI mode] 1:6:1 rid: 0 hdr: 0 intr: B
=C2=A0 =C2=A0 40: MSI 88
Detecte= d AHCI ABAR at C1002000
AHCI IRQ is B
Host Capabilities FF30FF3F
G= lobal Host Control 80000000
Interrupt Status 0
Ports Implemented 1Version 10300
Command Completion Coalescing Control 0
Command Comple= tion Coalescing Ports 0
Enclosure Management Location 0
Enclosure Man= agement Control 0
Host Capabilities Extended 4
BIOS/OS Handoff Contro= l and Status 0
AHCI HBA version 1.300
Handler: 0
Config register: = 17
----- PANIC -----
Early page fault on address 80000035B0
Local = CPU is #<7A4AF9>
Run queues:
Thread #<1468079 Thread Initial= thread> holds the world
Run queue #<1498139>/SUPERVISOR:
Ru= n queue #<1498159>/HIGH:
Run queue #<1498179>/NORMAL:
Run= queue #<1498199>/LOW:
IRQ state:
IRQ #<1497DF9 Irq :Number = 0> - 0 (86 delivered)
=C2=A0 #<1499119> PIT [exclusive]
IRQ = #<1497E29 Irq :Number 1> - 1 (1 delivered)
=C2=A0 #<1499699>= INTEL-8042-KEYBOARD [exclusive]
IRQ #<1498009 Irq :Number B> - B = (0 delivered)
=C2=A0 #<149C959> #<149C909>
IRQ #<14980= 39 Irq :Number C> - C (0 delivered)
=C2=A0 #<14993D9> INTEL-804= 2-AUXILIARY [exclusive]
Active timers: (current time is 147260)
Threa= d #<1468079 Thread Initial thread> ACTIVE #<1498669 Wait-Queue Hea= rtbeat wait queue>
TIFH: 1 TPFH: NIL
20000121FB90 7FFF892B07 DEBUG= -DUMP
20000121FD20 7FFF800FAE (LAMBDA IN PANIC-1)
20000121FE30 7FFF80= 073F PANIC-1
20000121FE50 7FFF800633 PANIC
20000121FEC0 7FFF8820B1 FA= TAL-PAGE-FAULT
20000121FEF0 7FFF88114B %PAGE-FAULT-HANDLER
20000121FF= 40 7FFF87F3BB %%INTERRUPT-SERVICE-ROUTINES
20000121FFD0 80000035B0 #<= unknown>
200000A1FFF0 7FFF800841 %CALL-ON-WIRED-STACK-WITHOUT-INTERRU= PTS
20000221FE60 7FFF958E90 (SETF PCI-CONFIG/16)
20000221FE90 7FFF9B5= 670 AHCI-PCI-REGISTER
20000221FEF0 7FFF95B9C9 (FLET DX-LAMBDA IN PCI-DET= ECT)
20000221FF50 7FFF95B22E MAP-PCI-DEVICES
20000221FF90 7FFF955671 = PCI-DETECT
20000221FFA0 7FFF93C8F4 INITIALIZE-PLATFORM
20000221FFC0 7= FFF8D7F03 BOOTLOADER-ENTRY-POINT

Looks like it= executes an interrupt handler with calling something "on a wired stac= k without interrupts". Postmortem rflags:
root@vonbraun:~ # = bhyvectl --vm=3Dubuntu --get-rflags
rflags[0] 0x0000000000000046

I do not know what to think, that %cal-on-wired-stack= -without-interrupts seems to be legit to me:=C2=A0https:/= /github.com/froggey/Mezzano/blob/master/supervisor/x86-64/interrupts.lisp

> Hi! Mezzano is an operating system written in Common lisp. = I would like
> to test it in bhyve. When I launch it, it spins infinitely in a loop <= br> > measuring how many CPU cycles it makes in a unit of time (I understood=
> it by adding various debug messages).
>
> The timer it uses is something called a PIT:
> https://wiki.osdev.org/Programmable_Interval_= Timer
> <https://wiki.osdev.org/Programmable_Inter= val_Timer>
>
> The problem is, once the timer is configured it fires an interrupt onl= y
> once, while it obviously must fire interrupts constantly at some
> frequency (100 Hz, as I understand from the code).
>
> Is the PIT supported by bhyve? Does FreeBSD use it anywhere in its ker= nel?

=C2=A0 Yes, though mode 3 of the timer isn't supported by the device emulation. It appears that Mezzano uses that mode

https://github.com/fro= ggey/Mezzano/blob/master/supervisor/x86-64/time.lisp#L20

=C2=A0 Try this patch to the PIT code to see if it helps
=C2=A0 =C2=A0 =C2=A0https://people.freebsd.org/~= grehan/bhyve_vatpit.diff

later,

Peter.

--000000000000e3012f06240a41fd--