From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MruSi-0005cC-M5 for qemu-devel@nongnu.org; Sun, 27 Sep 2009 10:10:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MruSd-0005Yq-5t for qemu-devel@nongnu.org; Sun, 27 Sep 2009 10:10:51 -0400 Received: from [199.232.76.173] (port=33357 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MruSc-0005Yn-VK for qemu-devel@nongnu.org; Sun, 27 Sep 2009 10:10:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28546) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MruSc-0000T1-HK for qemu-devel@nongnu.org; Sun, 27 Sep 2009 10:10:46 -0400 Date: Sun, 27 Sep 2009 16:08:41 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCHv2] qemu: target library, use it in msix Message-ID: <20090927140841.GA24769@redhat.com> References: <20090923200635.GA21246@redhat.com> <20090927082020.GA23513@redhat.com> <4ABF4110.80300@redhat.com> <20090927114459.GA24031@redhat.com> <4ABF52A5.5080409@redhat.com> <20090927120041.GB24031@redhat.com> <4ABF585D.7000201@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ABF585D.7000201@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Blue Swirl , qemu-devel@nongnu.org On Sun, Sep 27, 2009 at 02:19:41PM +0200, Avi Kivity wrote: > On 09/27/2009 02:00 PM, Michael S. Tsirkin wrote: >> On Sun, Sep 27, 2009 at 01:55:17PM +0200, Avi Kivity wrote: >> >>> On 09/27/2009 01:45 PM, Michael S. Tsirkin wrote: >>> >>>> >>>> >>>>>> Thinking about this some more, this function just says "align a value to >>>>>> page size". The value might not be a bus address at all, and indeed with >>>>>> msix use, it is not. Makes sense? >>>>>> >>>>>> >>>>>> >>>>> In any case restricting it to unsigned invites truncation. >>>>> >>>>> >>>> If the value we are aligning fits in 32 bit, so does the aligned value. >>>> >>>> >>> It's perfectly reasonable to call a such a function with a >>> target_ulong_t >>> >> [mst@tuck qemu]$ grep -rIi target_ulong_t . >> [mst@tuck qemu]$ >> >> ? >> >> > > target_ulong. > >>> or target_phys_addr_t input and expect it to work. >>> >> Not if it's called target_page_align32 :) >> > > You generally don't know the size of quantities you align. > >>> How would the caller know what size argument they have? They usually >>> have a target_phys_addr_t or a target_ulong_t. >>> >> In practice, the only user is now msix and it does not. It has 0x1000 >> as a constant parameter. For target_phys_addr_t users if we ever have >> them, we'll just add target_phys_page_align. Generally it's unusual for >> devices to care about size of target physical page. >> > > I'd fill better with uint64_t, at least that won't truncate. Doesn't naming it target_page_align32 address this concern? > -- > Do not meddle in the internals of kernels, for they are subtle and quick to panic.