From nobody Fri Jun 14 07:27:18 2024 X-Original-To: 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 4W0rTn2kZ6z5NbQc for ; Fri, 14 Jun 2024 07:27:57 +0000 (UTC) (envelope-from marietto2008@gmail.com) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 4W0rTn0Hlcz55rg; Fri, 14 Jun 2024 07:27:57 +0000 (UTC) (envelope-from marietto2008@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-6e41550ae5bso1398302a12.3; Fri, 14 Jun 2024 00:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718350075; x=1718954875; 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=U1OXFkuq5H5O4DuYNfpYfSkE6pq0T7PpqXQ+w41b+LY=; b=IY4QAo54zFjwGADhHsKhrW5UayBKiTvs8FyZZWc1A5iIyltsK51xVwnja1H2MvPI6W Hae1C8Es6iKqwgbL7z9qZl9w5QkkaX3lIqIimb3J7/TKgrSFyICcBg5P66ykxxrrJl3o GBAyWR7CFuYIDG6VNaXqHGXO+gavVPacB9TRy5YfxD0m+0IZcfA9EtSAmboKf69CjxsB snC7JErO9ighqjPsPzClQUx4yaek+eCtlKhCJmNhcRBag9s+z2ep621bgRyV6b+q4mye JHhEnyaR3wdv2jqE2dRcp6wwajEvnfKQiFUkgf/62ZyFAmx7onrZysDTCF7OT2CM7e72 wKow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718350075; x=1718954875; 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=U1OXFkuq5H5O4DuYNfpYfSkE6pq0T7PpqXQ+w41b+LY=; b=EqiKziJF1DK8o0v+GkaI2mkW4zMn23Nte+GMLAYXmhHrN0LVGZaQcrCNXiaM+fgW/x 4UoVJ1ivsiGet7p/W7Y+kyyhf3EUgvsb9SDKlnNyxaCii9dJIefpa93940KgXu7gaHum o0O4JSsoG/m7AuTd04vFH4U/sMKr6/aq04ce3sJ24kQkW7SaNYTnG9VDvVfc64FclVOA 0qmY5TRRA30vBzNWNpuJj/89OcqUicSw+We1IyztHLpAtEs0uYxUUGvUnl3Y0W2PshsF /ucKL9m0jCwhsBdWxkg/Z3NcIN5UomnzlYy2IxPvesPB/nCjGeHiMKEAYfuCCT7oWru4 F4Zg== X-Forwarded-Encrypted: i=1; AJvYcCVjeZaDzzUpRvxNobsGi23T0k46XVI7O5g50oPToJBps+i8J9VnpIJFMJBAwP/fCAkidLn/Ks50FNbfBGp74qDIRB28lnhrXFaZHg== X-Gm-Message-State: AOJu0YyNEjTl2vVp9bxjJbjec/dNrx613mJGuGbSHO5a/EoQUqJcXh0p pKVABJPnEsF26fTNeDKEl4sFGyd5Z4gjUCmX+EFLM284QLjGIlyzqwvAhwnZ94kVpS6WWs6kaUd lTL6DDxfDxwws5xeuAYkuVjWxzRz704Vd X-Google-Smtp-Source: AGHT+IHJMT9Kp7x6VpW5IWFwOxMhUTV7gGHSafEWU/PfgMfxx66f9zJf98W2vfSj26Mra8L2qFpGHm3Rwn/bxOYv5d8= X-Received: by 2002:a17:90a:7146:b0:2c2:deec:8cfb with SMTP id 98e67ed59e1d1-2c4db132da5mr2022457a91.6.1718350075303; Fri, 14 Jun 2024 00:27:55 -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: <38c9656c26fc3cee7ba733168c0fa2cdd01209d9.camel@FreeBSD.org> In-Reply-To: <38c9656c26fc3cee7ba733168c0fa2cdd01209d9.camel@FreeBSD.org> From: Mario Marietto Date: Fri, 14 Jun 2024 09:27:18 +0200 Message-ID: Subject: Re: bhyve passthru problem To: =?UTF-8?Q?Corvin_K=C3=B6hne?= Cc: Oleksandr Kryvulia , virtualization@freebsd.org Content-Type: multipart/alternative; boundary="000000000000d6a81d061ad48d75" X-Spamd-Bar: ---- 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)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4W0rTn0Hlcz55rg --000000000000d6a81d061ad48d75 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Oleksandr,I would like to try an experiment to try to fix your problem. If you agree,I could send you my bhyve and vmm.ko files,if you want. I suspect that they may fix your problem. Let me know if you want to try. On Fri, Jun 14, 2024 at 8:35=E2=80=AFAM Corvin K=C3=B6hne wrote: > On Thu, 2024-06-13 at 10:53 +0300, Oleksandr Kryvulia wrote: > > I'm trying to passthru a wwan-adapter to linux guest using > > sysutils/vm-bhyve-devel. > > > > ppt0@pci0:8:0:0: class=3D0x0d4000 rev=3D0x01 hdr=3D0x00 > > vendor=3D0x8086 device=3D0x7560 subvendor=3D0x1cf8 subdevice=3D0x8654 > > vendor =3D 'Intel Corporation' > > device =3D 'XMM7560 LTE Advanced Pro Modem' > > class =3D wireless controller > > subclass =3D cellular controller/modem > > > > The guest does not start with an error: > > > > bhyve: passthru device 8/0/0 BAR 2: base 0xbc201000 or size 0x100 > > not page aligned > > bhyve: failed to initialize BARs for PCI 8/0/0 > > Device emulation initialization error: No such file or directory > > > > What I am doing wrong? > > > > The BAR size of your device is smaller than a page. Unfortunately, you > can't change it, so there's nothing you can do right now. > > I don't know why bhyve validates the BAR size. The commit adding this > check is old [1] and doesn't explain it. What bhyve could do is > rounding up the BAR size to a full page size when allocating memory for > the BAR. > > [1] https://github.com/freebsd/freebsd- > src/commit/7a902ec0eccc752c9c38533ed123121eaaea1225 > > > -- > Kind regards, > Corvin > --=20 Mario. --000000000000d6a81d061ad48d75 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Oleksandr,I would like to try an experiment to try to fix = your problem. If you agree,I could send you my bhyve and vmm.ko files,if yo= u want. I suspect that they may fix your problem. Let me know if you want t= o try.

On Fri, Jun 14, 2024 at 8:35=E2=80=AFAM Corvin K=C3=B6hne <corvink@freebsd.org> wrote:
<= /div>
On Thu, 2024-06-13 a= t 10:53 +0300, Oleksandr Kryvulia wrote:
> =C2=A0I'm trying to passthru a wwan-adapter to linux guest using > sysutils/vm-bhyve-devel.
> =C2=A0
> =C2=A0ppt0@pci0:8:0:0: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0class= =3D0x0d4000 rev=3D0x01 hdr=3D0x00
> vendor=3D0x8086 device=3D0x7560 subvendor=3D0x1cf8 subdevice=3D0x8654 =
> =C2=A0=C2=A0=C2=A0=C2=A0vendor =C2=A0=C2=A0=C2=A0=C2=A0=3D 'Intel = Corporation'
> =C2=A0=C2=A0=C2=A0=C2=A0device =C2=A0=C2=A0=C2=A0=C2=A0=3D 'XMM756= 0 LTE Advanced Pro Modem'
> =C2=A0=C2=A0=C2=A0=C2=A0class =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=3D wirele= ss controller
> =C2=A0=C2=A0=C2=A0=C2=A0subclass =C2=A0=C2=A0=3D cellular controller/m= odem
> =C2=A0
> =C2=A0The guest does not start with an error:
> =C2=A0
> =C2=A0bhyve: passthru device 8/0/0 BAR 2: base 0xbc201000 or size 0x10= 0
> not page aligned
> =C2=A0bhyve: failed to initialize BARs for PCI 8/0/0
> =C2=A0Device emulation initialization error: No such file or directory=
> =C2=A0
> =C2=A0What I am doing wrong?
> =C2=A0=C2=A0

The BAR size of your device is smaller than a page. Unfortunately, you
can't change it, so there's nothing you can do right now.

I don't know why bhyve validates the BAR size. The commit adding this check is old [1] and doesn't explain it. What bhyve could do is
rounding up the BAR size to a full page size when allocating memory for
the BAR.

[1] https://github.com/freebsd/freebsd-
src/commit/7a902ec0eccc752c9c38533ed123121eaaea1225


--
Kind regards,
Corvin


--
Mario.
--000000000000d6a81d061ad48d75--