WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 3/6] trace: improve check_tbuf_size()

To: Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 3/6] trace: improve check_tbuf_size()
From: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Date: Wed, 30 Jun 2010 16:15:00 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 30 Jun 2010 08:15:57 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=rFM4rtpZenM4db1T2R5Hm7oEBvFYmcsaiTE53pRqyV0=; b=guIZU/O709w7I+myTLvtrb8Z1iRZr2Vfi+YT++lY7rsB5fRhVcfVgY2o57fEL5cey/ 8Nwc318OcjK1SzAgsDL5OJ8/XKMqzIlNuZOkOCcpi/fBE7KB+jkvzpne4f0iFM9INNwU vPzsErS4vcZ5lhk+Tp4GgqdvxevrUKdnPWGy0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=qKRfmFsA4x4Q0p4cbHla0pOzbMBr/dYkMDS7+4JY5FeY2kDq13RTgCb6unQnCgT9vx eUADPfNyDOfiLYLFOy7B/oqf65x+fmIbNqENXpR/RCaQubfuQB0wHs2eXaiSfiqs31I7 qVGAJdN6vkV4Hj9Ty7ppnU4Rjf1y5AWu+D3DA=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4C2A2E950200007800008A65@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4C2A2E950200007800008A65@xxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
As long as we're being anal, we should be sure to use the actual types
from prod and cons to do the check.  Patch attached.

 -George

On Tue, Jun 29, 2010 at 4:34 PM, Jan Beulich <JBeulich@xxxxxxxxxx> wrote:
> It didn't consider the case of the incoming size not allowing for the
> 2*data_size range for t_buf->{prod,cons}
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
>
> --- 2010-06-15.orig/xen/common/trace.c  2010-06-28 11:58:37.000000000 +0200
> +++ 2010-06-15/xen/common/trace.c       2010-06-28 11:58:37.000000000 +0200
> @@ -77,11 +77,16 @@ static u32 tb_event_mask = TRC_ALL;
>
>  /**
>  * check_tbuf_size - check to make sure that the proposed size will fit
> - * in the currently sized struct t_info.
> + * in the currently sized struct t_info and allows prod and cons to
> + * reach double the value without overflow.
>  */
> -static inline int check_tbuf_size(int size)
> +static int check_tbuf_size(u32 pages)
>  {
> -    return (num_online_cpus() * size + T_INFO_FIRST_OFFSET) > (T_INFO_SIZE / 
> sizeof(uint32_t));
> +    u32 size = pages * PAGE_SIZE;
> +
> +    return (size / PAGE_SIZE != pages) || (size + size < size) ||
> +           (num_online_cpus() * pages + T_INFO_FIRST_OFFSET >
> +            T_INFO_SIZE / sizeof(uint32_t));
>  }
>
>  /**
>
>
>
>

Attachment: trace-check-size-v2.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>