From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 7 15:04:26 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 228EF106566C for ; Tue, 7 Apr 2009 15:04:26 +0000 (UTC) (envelope-from pisymbol@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.244]) by mx1.freebsd.org (Postfix) with ESMTP id A06A08FC0C for ; Tue, 7 Apr 2009 15:04:25 +0000 (UTC) (envelope-from pisymbol@gmail.com) Received: by an-out-0708.google.com with SMTP id d11so1621108and.13 for ; Tue, 07 Apr 2009 08:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=86S2fpiGHpbCVlMP231XtS5VSSyoRhUw8WfXcXD9BMU=; b=VQLzR2USxxp5BN/hzvgnZDty8lWu4hKLAadFC5p0ovXZSgD67078aYOJJtjnUzSaxM hDWvp+dCGw8R4V22yU5c6Yr9gd34r0zwFusQ4ljSQuzy9+BrPCOYPIkop2ib8LSXts4y mHFzfqtR1+WuqF/esmIEoiGv7Dmyv9jbvEFTo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=r+6s25AkxJ2E9Xa9b0jYAsQi0EaAwBOCVaxuwkXG0FDQlpmeadhCEKs8pIsLae+ok0 V5SK+6oB5G2gU8WHfabbZVGH5QyRlvpkszCdJbP6UkGILLaEJAZGSRixvGmGdPhHgzV3 PxqDR6OlhE+TH4v72P8msYDRu4hs4Zr97u2HM= MIME-Version: 1.0 Received: by 10.101.69.6 with SMTP id w6mr318011ank.71.1239116652034; Tue, 07 Apr 2009 08:04:12 -0700 (PDT) In-Reply-To: <200904070921.14294.jhb@freebsd.org> References: <1366225354.253456.1238948619308.JavaMail.root@vms124.mailsrvcs.net> <200904061342.22000.jhb@freebsd.org> <49DAC4A1.589A5FE@verizon.net> <200904070921.14294.jhb@freebsd.org> Date: Tue, 7 Apr 2009 11:04:11 -0400 Message-ID: <3c0b01820904070804s1aa63cc3ife542e7001f5497c@mail.gmail.com> From: Alexander Sack To: John Baldwin Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Sergey Babkin , Ivan Voras Subject: Re: Patch for MS Hyper V (virtualization) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 15:04:26 -0000 On Tue, Apr 7, 2009 at 9:21 AM, John Baldwin wrote: > On Monday 06 April 2009 11:12:33 pm Sergey Babkin wrote: >> John Baldwin wrote: >> > >> > On Monday 06 April 2009 1:07:38 pm Ivan Voras wrote: >> > > 2009/4/6 John Baldwin : >> > > > On Sunday 05 April 2009 12:23:39 pm Sergey Babkin wrote: >> > > >> > > > Hmm, the problem is we need to be able to write to BARs to size th= em. > =C2 Any >> > OS >> > > > needs to be able to do this to know what address space regions are > being >> > > > decoded by devices. =C2 We can't avoid writing to BARs. >> > > >> > > I have only vague idea what BARs are and if it's the correct diagnos= is >> > > in this case, but the fact is that other operating systems (Windows, >> > > Linux tested) work, so either there is a way around it or the origin= al >> > > premise is wrong-ish. >> > >> > Every OS writes to BARs to size them during boot. =9AIt's the defined > procedure >> > for sizing them. =9AA BAR is a base address register, and it is how a = PCI >> > device gets memory and I/O port resources. =9AOS (or BIOS) writes a st= arting >> > address into the register to tell the PCI device where a given >> > resource "starts". >> >> The OS doesn't have to write to the BAR if BIOS has already >> done it. And the BIOS in the Hyper-V VM is obviously special, >> so it doesn't trip on iself. > > Yes it does because we don't know how _big_ the BAR is. =9AThe OS has to = know if > the device is decoding 1MB or 64KB because we need to reserve the entire > window to prevent any other devices from using it. =9AWe don't just write= the > existing value, we write all 1's to it and read it back. =9AThe lower N > bits "stick" at zero and we use that to figure out the BAR's size. =9ASee > pci_add_map() in sys/dev/pci/pci.c John is 100% correct. Every kernel PCI driver has to figure out how big the BAR is and IN FACT typically the BIOS assigns more address space than the register set you are mapping. This is straight out of the PCI spec. -aps