From owner-svn-src-all@freebsd.org Wed Jun 5 19:29:03 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1AB1815B6DD6; Wed, 5 Jun 2019 19:29:03 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B1CD18FC7B; Wed, 5 Jun 2019 19:29:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 859AE97A6; Wed, 5 Jun 2019 19:29:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55JT29Y012515; Wed, 5 Jun 2019 19:29:02 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55JT27D012514; Wed, 5 Jun 2019 19:29:02 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906051929.x55JT27D012514@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 5 Jun 2019 19:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348694 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 348694 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B1CD18FC7B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 19:29:03 -0000 Author: jhb Date: Wed Jun 5 19:29:02 2019 New Revision: 348694 URL: https://svnweb.freebsd.org/changeset/base/348694 Log: Don't simulate PBA access if the PBA is in a separate BAR. bhyve has to virtualize the MSI-X table to trap reads and writes to that table and map those to virtual interrupts that it maps real host interrupts on to. For the pending-bit-array (PBA), bhyve passes accesses from the guest directly to the hardware. bhyve's virtualization of the MSI-X table is done by intercepting all reads and writes to the BAR holding the MSI-X table. However, if the PBA is stored in the same BAR as the MSI-X table, accesses to the PBA portion of this BAR have to be forwarded to the real BAR. However, in the case that the PBA was stored in a separate BAR and it's offset in that separate BAR overlapped with the portion of the MSI-X table BAR that the table used, the handlers for the table BAR would incorrectly think that some accesses were PBA reads and writes. This caused a crash in bhyve when it indirected a NULL pointer. Fix this case by never trying to handle PBA access if the PBA lives in a separate BAR. Reported by: gallatin Tested by: gallatin Reviewed by: markj, Patrick Mooney MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D20523 Modified: head/usr.sbin/bhyve/pci_passthru.c Modified: head/usr.sbin/bhyve/pci_passthru.c ============================================================================== --- head/usr.sbin/bhyve/pci_passthru.c Wed Jun 5 16:01:05 2019 (r348693) +++ head/usr.sbin/bhyve/pci_passthru.c Wed Jun 5 19:29:02 2019 (r348694) @@ -295,7 +295,7 @@ msix_table_read(struct passthru_softc *sc, uint64_t of int index; pi = sc->psc_pi; - if (offset >= pi->pi_msix.pba_offset && + if (pi->pi_msix.pba_page != NULL && offset >= pi->pi_msix.pba_offset && offset < pi->pi_msix.pba_offset + pi->pi_msix.pba_size) { switch(size) { case 1: @@ -374,7 +374,7 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct p int index; pi = sc->psc_pi; - if (offset >= pi->pi_msix.pba_offset && + if (pi->pi_msix.pba_page != NULL && offset >= pi->pi_msix.pba_offset && offset < pi->pi_msix.pba_offset + pi->pi_msix.pba_size) { switch(size) { case 1: