From nobody Tue Nov 30 23:56:07 2021 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 B396B18B23AB for ; Tue, 30 Nov 2021 23:56:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3fHq34HHz3Hjv for ; Tue, 30 Nov 2021 23:56:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 456471F840 for ; Tue, 30 Nov 2021 23:56:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1AUNu77U058491 for ; Tue, 30 Nov 2021 23:56:07 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1AUNu7x6058490 for virtualization@FreeBSD.org; Tue, 30 Nov 2021 23:56:07 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: virtualization@FreeBSD.org Subject: [Bug 260148] passthru stopped working Date: Tue, 30 Nov 2021 23:56:07 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bhyve X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: bhyve X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: bz@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: virtualization@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Discussion List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-virtualization@freebsd.org X-BeenThere: freebsd-virtualization@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638316567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgKcPSaAcpqOuw26k/loVDxfWGDxFBIPJF8GlyZu2zE=; b=deCgaCui+GXDJVQE7ujVUgFh2oud6of9YKMa940aMA/zz3lO/pObzBMW4bjTSvhbAj3Fd0 NV8OVLvgelU5HEtETIBgPacyzS8Xvf2Rmbn37ZE6UWxypdexIVbe+qIm6ohpbNacPrQbga SR0gkgamEC68PFlFzvpCX+xeDwfiEyK30c1s1IT2XbpxVEOS7B50TmpPR7Ldug4v+gYy57 Mt/3yTzkUHZS5E+ckJNW/86e6X47knY1JB94XyMYBGWc4HDDPx+T2uDJ7WyLi7BcD9UlJU A9i24YJtTO51BWiYla+HSl6YpIyW1I67ZlCTBciLxbEYSu3rjdDGRpE/3ig/eA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638316567; a=rsa-sha256; cv=none; b=jHPki2Cvf5ED9TjqW8NqXUddJFWZBgEGx4lsvzhMmcO4bSYQ+T0LJLJVoYpoF/DOofSQr4 0AKT1DaaRCBIIhUkxecRqYsvTCZ+sae++XxdpBVZn/Txgn7Jup+1QRR+nwi9wq5Cie+7X8 xKZPBs4akoWFt8o2XYfk/l1EGyIYMirdJg6GuWWc62Xjet+2ra/P+IeQ6b59MryOFcDLwj BvHRjyGPPXhMpza/KR62OmjpL5fiSU/V4IcZsMjG1/F7f4xIvDa81XlqF/DBIpGw/6+YmO 4zZERN9tq4FtwULxL/MJbWVUzeVjAY3z+Lj+SkiI+/No6i4ueW6f3K1YDKVVjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260148 --- Comment #4 from Bjoern A. Zeeb --- okay, here's a fix:@@ -487,6 +487,7 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *sc) struct pci_bar_io bar; enum pcibar_type bartype; uint64_t base, size; + uint16_t cmd, orig_cmd; pi =3D sc->psc_pi; @@ -533,11 +534,22 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *= sc) sc->psc_bar[i].addr =3D base; sc->psc_bar[i].lobits =3D 0; + orig_cmd =3D pci_get_cfgdata16(pi, PCIR_COMMAND); + /* Allocate the BAR in the guest I/O or MMIO space */ error =3D pci_emul_alloc_bar(pi, i, bartype, size); if (error) return (-1); + /* + * We may need this here and now to enable the BAR + * before pci_msix_table_bar() tries to mmap it as + * the kernel otherwise returns EBUSY from pci_bar_mmap(). + */ + cmd =3D pci_get_cfgdata16(pi, PCIR_COMMAND); + if (cmd !=3D orig_cmd) + write_config(&sc->psc_sel, PCIR_COMMAND, 2, cmd); + /* Use same lobits as physical bar */ uint8_t lobits =3D read_config(&sc->psc_sel, PCIR_BAR(i), 0= x01); if (bartype =3D=3D PCIBAR_MEM32 || bartype =3D=3D PCIBAR_ME= M64) { This is very similar to what @jhb is doing in https://reviews.freebsd.org/D20623 for busmaster. Unfortunately the combined write at the end of cfginit() is too late these days. So we end up with several individual writes to PCIR_COMMAND and possibly yet-another-one not actually chaning anything anymore after all in cfginit(= ). --=20 You are receiving this mail because: You are the assignee for the bug.=