From nobody Tue Feb 14 09:24:02 2023 X-Original-To: freebsd-arm@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 4PGG4C3fCvz3rSXl for ; Tue, 14 Feb 2023 09:24:11 +0000 (UTC) (envelope-from SRS0=upKc=6K=klop.ws=ronald-lists@realworks.nl) Received: from smtp-relay-int.realworks.nl (smtp-relay-int.realworks.nl [194.109.157.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4PGG4C14gSz3NZP for ; Tue, 14 Feb 2023 09:24:11 +0000 (UTC) (envelope-from SRS0=upKc=6K=klop.ws=ronald-lists@realworks.nl) Authentication-Results: mx1.freebsd.org; none Date: Tue, 14 Feb 2023 10:24:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=klop.ws; s=rw2; t=1676366643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6I48occBtTHPy/7UDs2CbrCZ65b34ADu+/OOPGAu/kw=; b=RwUV/7A3ETMQN6So85XGhdc4pSedccp6VvYvZUz1RvACtNju5Mbx3vMDRiRbBv6M+P05cK /Q4HNFIiZ6p7tiGOBe7ED42t426g791AheF0VzCi9hnuRL2OrHfJBDW9EHM4jy6Bb5mE3H D9KcREG7eB8HYNdcXjK7Ijq7b7LGID0Py/t4QHf1z6XLhC343AxcjgTdBF+mOAueZQWU8N OJWoNUCg4gr6aO/W30pfOuyMTv6xf86/W1JYRAIbj6AnRVMgZ2Men6q1JWQ2Do4cCA2HAI CfseLQc00BU/wH73U7R36NNgVUvHKUx4x2/x8LcIURZPz5H1hPs1cGYDAIqnxA== From: Ronald Klop To: John-Mark Gurney Cc: freebsd-arm@FreeBSD.org Message-ID: <306917284.1.1676366642956@mailrelay> In-Reply-To: <20230214080530.GE95670@funkthat.com> References: <20230214080530.GE95670@funkthat.com> Subject: Re: detecting qemu/HVF on Apple M1 silicon List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_0_1079485241.1676366641320" X-Mailer: Realworks (644.1101) Importance: Normal X-Priority: 3 (Normal) X-Rspamd-Queue-Id: 4PGG4C14gSz3NZP X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:3265, ipnet:194.109.0.0/16, country:NL] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N ------=_Part_0_1079485241.1676366641320 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Van: John-Mark Gurney Datum: dinsdag, 14 februari 2023 09:05 Aan: freebsd-arm@FreeBSD.org Onderwerp: detecting qemu/HVF on Apple M1 silicon >=20 > I managed to get FreeBSD running via qemu on Apple M1 silicon, but out > of the box vm detection isn't working causing hz to be set to 1000, and > causing lots of cpu usage to happen. >=20 > What are the recommended ways to detect this, so we can get vm_guest set? >=20 > A little poking around, shows that there's an ACPI device that is > promising: > Device (FWCF) > { > Name (_HID, "QEMU0002") // _HID: Hardware ID > Name (_STA, 0x0B) // _STA: Status > Name (_CCA, One) // _CCA: Cache Coherency Attribute > Name (_CRS, ResourceTemplate () // _CRS: Current Resource Se= ttings > { > Memory32Fixed (ReadWrite, > 0x09020000, // Address Base > 0x00000018, // Address Length > ) > }) > } >=20 > Here's a complete list of _HID's: > # acpidump -d | grep _HID | sort -u > Name (_HID, "PNP0C02" /* PNP Motherboard Resources */) /= / _HID: Hardware ID > Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) /= / _HID: Hardware ID > Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hard= ware ID > Name (_HID, "ACPI0013" /* Generic Event Device */) // _HID: = Hardware ID > Name (_HID, "ARMH0011") // _HID: Hardware ID > Name (_HID, "LNRO0005") // _HID: Hardware ID > Name (_HID, "PNP0A08" /* PCI Express Bus */) // _HID: Hardwa= re ID > Name (_HID, "PNP0C0C" /* Power Button Device */) // _HID: Ha= rdware ID > Name (_HID, "QEMU0002") // _HID: Hardware ID >=20 > There's also the usual virtio devices as well. > # pciconf -l > hostb0@pci0:0:0:0: class=3D0x060000 rev=3D0x00 hdr=3D0x00 vendor=3D0x1b3= 6 device=3D0x0008 subvendor=3D0x1af4 subdevice=3D0x1100 > virtio_pci0@pci0:0:1:0: class=3D0x020000 rev=3D0x00 hdr=3D0x00 vendor=3D0= x1af4 device=3D0x1000 subvendor=3D0x1af4 subdevice=3D0x0001 > virtio_pci1@pci0:0:2:0: class=3D0x038000 rev=3D0x01 hdr=3D0x00 vendor=3D0= x1af4 device=3D0x1050 subvendor=3D0x1af4 subdevice=3D0x1100 > xhci0@pci0:0:3:0: class=3D0x0c0330 rev=3D0x01 hdr=3D0x00 vendor=3D0x1b3= 6 device=3D0x000d subvendor=3D0x1af4 subdevice=3D0x1100 > none0@pci0:0:4:0: class=3D0x040300 rev=3D0x01 hdr=3D0x00 vendor=3D0x808= 6 device=3D0x2668 subvendor=3D0x1af4 subdevice=3D0x1100 > virtio_pci2@pci0:0:5:0: class=3D0x010000 rev=3D0x00 hdr=3D0x00 vendor=3D0= x1af4 device=3D0x1001 subvendor=3D0x1af4 subdevice=3D0x0002 >=20 > --=20 > John-Mark Gurney Voice: +1 415 225 5579 >=20 > "All that I will do, has been done, All that I have, has not." > =C3=82=20 >=20 >=20 >=20 Hi, I'm using UTM as a wrapper around qemu. This gives me the following in dmes= g which might be a good hint. acpi0: "BOCHS" is also in the output of kenv. Although I'm not sure if this is a good indicator for qemu. Regards, Ronald. =C3=82=20 ------=_Part_0_1079485241.1676366641320 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Van: John-Mark Gurney <jmg@funkthat.com>
Datum: dinsdag, 14 februari 2023 09:05
Aan: freebsd-arm@FreeBSD.org
Onderwerp: detecting qemu/HVF on Apple M1 silicon

I managed to get FreeBSD running = via qemu on Apple M1 silicon, but out
of the box vm detection isn't working causing hz to be set to 1000, and
causing lots of cpu usage to happen.

What are the recommended ways to detect this, so we can get vm_guest set?
A little poking around, shows that there's an ACPI device that is
promising:
        Device (FWCF)
        {
            Nam= e (_HID, "QEMU0002")  // _HID: Hardware ID
            Nam= e (_STA, 0x0B)  // _STA: Status
            Nam= e (_CCA, One)  // _CCA: Cache Coherency Attribute
            Nam= e (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {             &nb= sp;   Memory32Fixed (ReadWrite,
            &nb= sp;       0x09020000,    =      // Address Base
            &nb= sp;       0x00000018,    =      // Address Length
            &nb= sp;       )
            })<= br>         }

Here's a complete list of _HID's:
# acpidump -d | grep _HID | sort -u
            &nb= sp;   Name (_HID, "PNP0C02" /* PNP Motherboard Resources */)=  // _HID: Hardware ID
            &nb= sp;   Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */)=  // _HID: Hardware ID
            Nam= e (_HID, "ACPI0007" /* Processor Device */)  // _HID: Hardware ID
            Nam= e (_HID, "ACPI0013" /* Generic Event Device */)  // _HID: Hardware ID<= br>             Nam= e (_HID, "ARMH0011")  // _HID: Hardware ID
            Nam= e (_HID, "LNRO0005")  // _HID: Hardware ID
            Nam= e (_HID, "PNP0A08" /* PCI Express Bus */)  // _HID: Hardware ID
            Nam= e (_HID, "PNP0C0C" /* Power Button Device */)  // _HID: Hardware ID             Nam= e (_HID, "QEMU0002")  // _HID: Hardware ID

There's also the usual virtio devices as well.
# pciconf -l
hostb0@pci0:0:0:0:  class=3D0x060000 rev=3D0x00 hdr=3D0x00 vendor=3D0x= 1b36 device=3D0x0008 subvendor=3D0x1af4 subdevice=3D0x1100
virtio_pci0@pci0:0:1:0: class=3D0x020000 rev=3D0x00 hdr=3D0x00 vendor=3D0x1= af4 device=3D0x1000 subvendor=3D0x1af4 subdevice=3D0x0001
virtio_pci1@pci0:0:2:0: class=3D0x038000 rev=3D0x01 hdr=3D0x00 vendor=3D0x1= af4 device=3D0x1050 subvendor=3D0x1af4 subdevice=3D0x1100
xhci0@pci0:0:3:0:   class=3D0x0c0330 rev=3D0x01 hdr=3D0x00 vendor= =3D0x1b36 device=3D0x000d subvendor=3D0x1af4 subdevice=3D0x1100
none0@pci0:0:4:0:   class=3D0x040300 rev=3D0x01 hdr=3D0x00 vendor= =3D0x8086 device=3D0x2668 subvendor=3D0x1af4 subdevice=3D0x1100
virtio_pci2@pci0:0:5:0: class=3D0x010000 rev=3D0x00 hdr=3D0x00 vendor=3D0x1= af4 device=3D0x1001 subvendor=3D0x1af4 subdevice=3D0x0002

-- 
  John-Mark Gurney        &nbs= p;     Voice: +1 415 225 5579

     "All that I will do, has been done, All that = I have, has not."
=C3=82 



Hi,

I'm using UTM as a wrapper around qemu. This gives me the following in dmes= g which might be a good hint.
acpi0: <BOCHS BXPC>

"BOCHS" is also in the output of kenv.

Although I'm not sure if this is a good indicator for qemu.

Regards,
Ronald.
=C3=82  ------=_Part_0_1079485241.1676366641320--