From owner-freebsd-virtualization@freebsd.org Thu Mar 1 22:24:42 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 DA5EAF2F985 for ; Thu, 1 Mar 2018 22:24:41 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 530647D7E5 for ; Thu, 1 Mar 2018 22:24:41 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-lf0-f51.google.com with SMTP id t204so10611239lff.9 for ; Thu, 01 Mar 2018 14:24:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dZNaO8uJuWkOTFrjMHgY+oHkR835DL00GQ9z4jXEulU=; b=KoNKQB3NUvcrZ/nLG8kKu3SZVVwtBtmv3rLfusRjbzSaiqeiiEr6uHYN+kpVnNtnmv cSneCUd0E9wE82OjPpgS7BkqyAJjYX8ndaRrf/5usGuI+fAipCd/wIKdL/3ydzLIb3le ULh0fRTrr7oIDxIHi4G5dw6yyuYRNf9UgA6fADpRksx7uZU9FCUUsNkS+J2+ko1xQHpL JmvKJyez+VZe55ywSupzoFcSO3Rj5OSf8PZlf189Xhi2L/ZdFHxrIYSPEzSI1u+gCb8g 3zCJzQeXxO/0WPc+qj1S3G0zWq6VXXx+eP3l8C8ZLXAcpO18NRZrerR3WGjq0HdL9yf5 Bl2w== X-Gm-Message-State: AElRT7FUZ7rCtTSKzUVw9BmAoWbd/gajrnsjQkniL6Gmygxf3V1QqVsn cqKYcpgiovcUeuGaK9qypmeY98YN X-Google-Smtp-Source: AG47ELvg/FZ0NRBWnxQRyeWnXh+zC/0qpBvdhKZ0GpbnlDN48rlJ3uorx5u6uiy0dBdRbI0hSPesrA== X-Received: by 10.46.84.86 with SMTP id y22mr2388185ljd.36.1519942743828; Thu, 01 Mar 2018 14:19:03 -0800 (PST) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id v83sm1035862lje.53.2018.03.01.14.19.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 14:19:03 -0800 (PST) Subject: Re: bhyve - windows7 installation To: "Rodney W. Grimes" , Ludovit Koren Cc: freebsd-virtualization@freebsd.org References: <86efl3j4y5.fsf@gmail.com> <201803011406.w21E62La025815@pdx.rh.CN85.dnsmgr.net> From: Andriy Gapon Message-ID: <3ab0c15f-afb5-c880-91d1-ba09a5c8bbc9@FreeBSD.org> Date: Fri, 2 Mar 2018 00:19:01 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <201803011406.w21E62La025815@pdx.rh.CN85.dnsmgr.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Thu, 01 Mar 2018 22:24:42 -0000 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. 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