From owner-freebsd-virtualization@freebsd.org Fri Mar 2 15:11:33 2018 Return-Path: Delivered-To: freebsd-virtualization@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 505CCF2B7EC for ; Fri, 2 Mar 2018 15:11:33 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E424856C9; Fri, 2 Mar 2018 15:11:32 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w22FBRs1030532; Fri, 2 Mar 2018 07:11:27 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w22FBQbf030531; Fri, 2 Mar 2018 07:11:26 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201803021511.w22FBQbf030531@pdx.rh.CN85.dnsmgr.net> Subject: Re: bhyve - windows7 installation In-Reply-To: <86woyvgd3v.fsf@gmail.com> To: Ludovit Koren Date: Fri, 2 Mar 2018 07:11:26 -0800 (PST) CC: Andriy Gapon , freebsd-virtualization@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Mar 2018 15:11:33 -0000 > >>>>> Andriy Gapon writes: > > > On 01/03/2018 16:06, Rodney W. Grimes wrote: > >> Due to the design of the IOMMU you can only manage IO space in page > >> (4096 on x86) granually sizes. The device your trying to pass in > >> has a 1024 byte memory region that is part of a 4096 byte page that > >> may have other things in it. > >> > >> At this time bhyve does not have any way to deal with this, though some > >> other hypervisors have techniques that make this work. > >> > >> I do not have or know of any list of USB controller cards that > >> have 4k aligned and 4k sized BAR's. > > > I have this local hack for that problem. > > It comes without any warranty and its use is completely at your own risk. > > Thank you. I will try it. Andriy, Thanks for providing this patch, I tried to find the repository it is in with google and did not, is this a private repository? Either way would it be ok with you if I published, with attribution of cource, your patch first from my people.freebsd.org/~rgrimes#bhyve page, and possibly later from a wiki page? I'll properly dress it in "this has security implications" and enumerate what those are. Thanks, > lk > > > commit 74e0a8d1ae01c7aaabd7d965958b735c7cf18871 > > Author: Andriy Gapon > > Date: Fri Nov 17 20:17:57 2017 +0200 > > > bhyve: allow BAR sizes that are not page aligned by rounding them up > > > This is based on the assumption that drivers won't access the added space. > > > diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c > > index f314679d912b0..14c1384c6c8f8 100644 > > --- a/usr.sbin/bhyve/pci_passthru.c > > +++ b/usr.sbin/bhyve/pci_passthru.c > > @@ -563,13 +563,20 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *sc) > > size = bar.pbi_length; > > > if (bartype != PCIBAR_IO) { > > - if (((base | size) & PAGE_MASK) != 0) { > > + if ((base & PAGE_MASK) != 0) { > > warnx("passthru device %d/%d/%d BAR %d: " > > - "base %#lx or size %#lx not page aligned\n", > > + "base %#lx not page aligned\n", > sc-> psc_sel.pc_bus, sc->psc_sel.pc_dev, > > - sc->psc_sel.pc_func, i, base, size); > > + sc->psc_sel.pc_func, i, base); > > return (-1); > > } > > + if ((size & PAGE_MASK) != 0) { > > + warnx("passthru device %d/%d/%d BAR %d: " > > + "size %#lx not page aligned\n", > > + sc->psc_sel.pc_bus, sc->psc_sel.pc_dev, > > + sc->psc_sel.pc_func, i, size); > > + size = round_page(size); > > + } > > } > > > /* Cache information about the "real" BAR */ > > > > -- > > Andriy Gapon > > > -- > A: Because it fouls the order in which people normally read text. > Q: Why is top-posting such a bad thing? Sorry for the middle posting :-) > A: Top-posting. > Q: What is the most annoying thing on usenet and in e-mail? -- Rod Grimes rgrimes@freebsd.org