aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/trace.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-07-02 18:53:10 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-07-02 18:53:10 +0100
commit43b0124af6b67ca65a1b4e82cf6b22b6d56119f8 (patch)
tree928737ddd97474f5a5b879bf2ceed5aba33b46e5 /xen/common/trace.c
parent79fdc7a419bd9f4e46b0d24549e6a6ee894d19d9 (diff)
downloadxen-43b0124af6b67ca65a1b4e82cf6b22b6d56119f8.tar.gz
xen-43b0124af6b67ca65a1b4e82cf6b22b6d56119f8.tar.bz2
xen-43b0124af6b67ca65a1b4e82cf6b22b6d56119f8.zip
trace: improve check_tbuf_size()
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@novell.com> Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Diffstat (limited to 'xen/common/trace.c')
-rw-r--r--xen/common/trace.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/xen/common/trace.c b/xen/common/trace.c
index caf9b7f621..8d4f02a458 100644
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -92,11 +92,19 @@ static void calc_tinfo_first_offset(void)
/**
* 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));
+ struct t_buf dummy;
+ typeof(dummy.prod) size;
+
+ size = ((typeof(dummy.prod))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));
}
/**